reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
UdpServer.hxx
Go to the documentation of this file.
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 "RequestHandler.hxx"
11
12namespace reTurn {
13
14class StunMessage;
15
17 : public AsyncUdpSocketBase
18{
19public:
21 explicit UdpServer(asio::io_context& ioService, RequestHandler& requestHandler, const asio::ip::address& address, unsigned short port);
22 UdpServer(const UdpServer&) = delete;
23 UdpServer(UdpServer&&) = delete;
24 ~UdpServer();
25
26 UdpServer& operator=(const UdpServer&) = delete;
28
29 virtual void start() override;
30
34
36 asio::ip::udp::socket& getSocket();
37
38 void cleanupResponseMap(const asio::error_code& e, UInt128 tid);
39
40private:
42 void onReceiveSuccess(const asio::ip::address& address, unsigned short port, const std::shared_ptr<DataBuffer>& data) override;
43 void onReceiveFailure(const asio::error_code& e) override;
44
46 void onSendSuccess() override;
47 void onSendFailure(const asio::error_code& e) override;
48
50 TurnAllocationManager mTurnAllocationManager;
51
53 RequestHandler& mRequestHandler;
54
55 // Stores the local address and port
56 asio::ip::address mLocalAddress;
57 unsigned short mLocalPort;
58
60 UdpServer* mAlternatePortUdpServer;
61 UdpServer* mAlternateIpUdpServer;
62 UdpServer* mAlternateIpPortUdpServer;
63
64 // Response map (for retransmissions)
65 class ResponseEntry
66 {
67 public:
69 ~ResponseEntry();
70
71 UdpServer* mResponseUdpServer;
72 StunMessage* mResponseMessage;
73 asio::steady_timer mCleanupTimer;
74 };
75 typedef std::map<UInt128, ResponseEntry*> ResponseMap;
76 ResponseMap mResponseMap;
77};
78
79}
80
81#endif
82
83
84/* ====================================================================
85
86 Copyright (c) 2007-2008, Plantronics, Inc.
87 All rights reserved.
88
89 Redistribution and use in source and binary forms, with or without
90 modification, are permitted provided that the following conditions are
91 met:
92
93 1. Redistributions of source code must retain the above copyright
94 notice, this list of conditions and the following disclaimer.
95
96 2. Redistributions in binary form must reproduce the above copyright
97 notice, this list of conditions and the following disclaimer in the
98 documentation and/or other materials provided with the distribution.
99
100 3. Neither the name of Plantronics nor the names of its contributors
101 may be used to endorse or promote products derived from this
102 software without specific prior written permission.
103
104 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
105 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
106 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
107 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
108 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
109 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
110 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
111 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
112 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
113 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
114 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115
116 ==================================================================== */
The common handler for all incoming requests.
virtual void start() override
Definition UdpServer.cxx:52
UdpServer & operator=(UdpServer &&)=delete
void setAlternateUdpServers(UdpServer *alternatePort, UdpServer *alternateIp, UdpServer *alternateIpPort)
This method is used if this UdpServer supports RFC3489 operation - note turnFraming in constructor mu...
Definition UdpServer.cxx:61
bool isRFC3489BackwardsCompatServer()
Definition UdpServer.cxx:72
UdpServer(UdpServer &&)=delete
asio::ip::udp::socket & getSocket()
Definition UdpServer.cxx:78
UdpServer & operator=(const UdpServer &)=delete
UdpServer(const UdpServer &)=delete
void cleanupResponseMap(const asio::error_code &e, UInt128 tid)
void list()
Definition userAdmin.cxx:66