/[resiprocate]/main/reTurn/UdpServer.hxx
ViewVC logotype

Contents of /main/reTurn/UdpServer.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11159 - (show annotations) (download)
Fri Apr 25 14:03:32 2014 UTC (5 years, 6 months ago) by sgodin
File MIME type: text/plain
File size: 3965 byte(s)
-modified asio and boost include file ordering to avoid multiply defined symbol errors on linking
 -in preparation for upgrade of asio drop and support for latest boost 
 -include asio/ssh.hpp everywhere asio.hpp is included
 -include boost headers before others, to ensure we are not redefining stdint definitions in some includes
  and not others

1 #ifndef UDP_SERVER_HXX
2 #define UDP_SERVER_HXX
3
4 #include <asio.hpp>
5 #ifdef USE_SSL
6 #include <asio/ssl.hpp>
7 #endif
8 #include <string>
9 #include <boost/noncopyable.hpp>
10 #include "RequestHandler.hxx"
11 #include "AsyncUdpSocketBase.hxx"
12
13 namespace reTurn {
14
15 class StunMessage;
16
17 class UdpServer
18 : public AsyncUdpSocketBase,
19 private boost::noncopyable
20 {
21 public:
22 /// Create the server to listen on the specified UDP address and port
23 explicit UdpServer(asio::io_service& ioService, RequestHandler& requestHandler, const asio::ip::address& address, unsigned short port);
24 ~UdpServer();
25
26 void start();
27
28 /// This method is used if this UdpServer supports RFC3489 operation - note turnFraming in contructor must be false
29 void setAlternateUdpServers(UdpServer* alternatePort, UdpServer* alternateIp, UdpServer* alternateIpPort);
30 bool isRFC3489BackwardsCompatServer();
31
32 ///// Returns the socket for this server
33 asio::ip::udp::socket& getSocket();
34
35 void cleanupResponseMap(const asio::error_code& e, UInt128 tid);
36
37 private:
38 /// Handle completion of a receive operation
39 virtual void onReceiveSuccess(const asio::ip::address& address, unsigned short port, boost::shared_ptr<DataBuffer>& data);
40 virtual void onReceiveFailure(const asio::error_code& e);
41
42 /// Handle completion of a send operation
43 virtual void onSendSuccess();
44 virtual void onSendFailure(const asio::error_code& e);
45
46 /// Manages turn allocations
47 TurnAllocationManager mTurnAllocationManager;
48
49 /// The handler for all incoming requests.
50 RequestHandler& mRequestHandler;
51
52 // Stores the local address and port
53 asio::ip::address mLocalAddress;
54 unsigned short mLocalPort;
55
56 /// The RFC3489 Alternate Server
57 UdpServer* mAlternatePortUdpServer;
58 UdpServer* mAlternateIpUdpServer;
59 UdpServer* mAlternateIpPortUdpServer;
60
61 // Response map (for retransmissions)
62 class ResponseEntry
63 {
64 public:
65 ResponseEntry(UdpServer* requestUdpServer, UdpServer* responseUdpServer, StunMessage* responseMessage);
66 ~ResponseEntry();
67
68 UdpServer* mResponseUdpServer;
69 StunMessage* mResponseMessage;
70 asio::deadline_timer mCleanupTimer;
71 };
72 typedef std::map<UInt128, ResponseEntry*> ResponseMap;
73 ResponseMap mResponseMap;
74 };
75
76 }
77
78 #endif
79
80
81 /* ====================================================================
82
83 Copyright (c) 2007-2008, Plantronics, Inc.
84 All rights reserved.
85
86 Redistribution and use in source and binary forms, with or without
87 modification, are permitted provided that the following conditions are
88 met:
89
90 1. Redistributions of source code must retain the above copyright
91 notice, this list of conditions and the following disclaimer.
92
93 2. Redistributions in binary form must reproduce the above copyright
94 notice, this list of conditions and the following disclaimer in the
95 documentation and/or other materials provided with the distribution.
96
97 3. Neither the name of Plantronics nor the names of its contributors
98 may be used to endorse or promote products derived from this
99 software without specific prior written permission.
100
101 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
102 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
103 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
104 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
105 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
106 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
107 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
108 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
109 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
110 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
111 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
112
113 ==================================================================== */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27