reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RequestHandler.hxx
Go to the documentation of this file.
1#ifndef REQUEST_HANDLER_HXX
2#define REQUEST_HANDLER_HXX
3
4#include <string>
5
6#include "DataBuffer.hxx"
7#include "StunMessage.hxx"
8#include "TurnManager.hxx"
10
11namespace reTurn {
12
13class AsyncSocketBase;
14
17{
18public:
20 const asio::ip::address* prim3489Address = 0, unsigned short* prim3489Port = 0,
21 const asio::ip::address* alt3489Address = 0, unsigned short* alt3489Port = 0);
22
25
28
37
41 void processTurnData(TurnAllocationManager& turnAllocationManager, unsigned short channelNumber, const StunTuple& localTuple, const StunTuple& remoteTuple, const std::shared_ptr<DataBuffer>& data);
42
43 const ReTurnConfig& getConfig() { return mTurnManager.getConfig(); }
44 TurnManager& getTurnManager() { return mTurnManager; }
45
46private:
47
48 TurnManager& mTurnManager;
49
50 // RFC3489 Server List
51 bool mRFC3489SupportEnabled;
52 asio::ip::address mPrim3489Address;
53 unsigned short mPrim3489Port;
54 asio::ip::address mAlt3489Address;
55 unsigned short mAlt3489Port;
56
57 resip::Data mPrivateNonceKey;
58
59 // Authentication handler
60 bool handleAuthentication(StunMessage& request, StunMessage& response);
61
62 // Specific request processors
63 ProcessResult processStunBindingRequest(StunMessage& request, StunMessage& response, bool isRFC3489BackwardsCompatServer);
64 ProcessResult processStunSharedSecretRequest(StunMessage& request, StunMessage& response);
69
70 // Specific Indication processors
71 void processTurnSendIndication(TurnAllocationManager& turnAllocationManager, StunMessage& request);
72
73 // Utility methods
74 void buildErrorResponse(StunMessage& response, unsigned short errorCode, const char* msg);
75 void buildErrorResponseWithRealmAndNonce(StunMessage& response, unsigned short errorCode, const char* msg, const resip::Data& realm, const StunMessage& request);
76 void generateNonce(const resip::Data& timestamp, resip::Data& nonce, const StunMessage& request);
77 enum CheckNonceResult { Valid, NotValid, Expired };
78 CheckNonceResult checkNonce(const resip::Data& nonce, const StunMessage& request);
79};
80
81}
82
83#endif
84
85
86/* ====================================================================
87
88 Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
89 Copyright (c) 2007-2008, Plantronics, Inc.
90 All rights reserved.
91
92 Redistribution and use in source and binary forms, with or without
93 modification, are permitted provided that the following conditions are
94 met:
95
96 1. Redistributions of source code must retain the above copyright
97 notice, this list of conditions and the following disclaimer.
98
99 2. Redistributions in binary form must reproduce the above copyright
100 notice, this list of conditions and the following disclaimer in the
101 documentation and/or other materials provided with the distribution.
102
103 3. Neither the name of Plantronics nor the names of its contributors
104 may be used to endorse or promote products derived from this
105 software without specific prior written permission.
106
107 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
108 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
109 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
110 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
111 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
112 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
113 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
114 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
115 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
116 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
117 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
118
119 ==================================================================== */
The common handler for all incoming requests.
void processTurnData(TurnAllocationManager &turnAllocationManager, unsigned short channelNumber, const StunTuple &localTuple, const StunTuple &remoteTuple, const std::shared_ptr< DataBuffer > &data)
RequestHandler(const RequestHandler &)=delete
TurnManager & getTurnManager()
RequestHandler & operator=(RequestHandler &&)=delete
const ReTurnConfig & getConfig()
RequestHandler(RequestHandler &&)=delete
RequestHandler & operator=(const RequestHandler &)=delete
ProcessResult processStunMessage(AsyncSocketBase *turnSocket, TurnAllocationManager &turnAllocationManager, StunMessage &request, StunMessage &response, bool isRFC3489BackwardsCompatServer=false)
Process a received StunMessage, and produce a reply Returns true if the response message is to be sen...
const ReTurnConfig & getConfig()
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
void list()
Definition userAdmin.cxx:66