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

Contents of /main/reTurn/RequestHandler.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10481 - (show annotations) (download)
Thu Sep 12 07:59:36 2013 UTC (6 years, 2 months ago) by dpocock
File MIME type: text/plain
File size: 4816 byte(s)
reTurn: revert commits 10472 and 10473, now on branch b-reTurn-async
1 #ifndef REQUEST_HANDLER_HXX
2 #define REQUEST_HANDLER_HXX
3
4 #include <string>
5 #include <boost/noncopyable.hpp>
6
7 #include "DataBuffer.hxx"
8 #include "StunMessage.hxx"
9 #include "TurnManager.hxx"
10 #include "TurnAllocationManager.hxx"
11
12 namespace reTurn {
13
14 class AsyncSocketBase;
15
16 /// The common handler for all incoming requests.
17 class RequestHandler
18 : private boost::noncopyable
19 {
20 public:
21 explicit RequestHandler(TurnManager& turnManager,
22 const asio::ip::address* prim3489Address = 0, unsigned short* prim3489Port = 0,
23 const asio::ip::address* alt3489Address = 0, unsigned short* alt3489Port = 0);
24
25 typedef enum
26 {
27 NoResponseToSend,
28 RespondFromReceiving,
29 RespondFromAlternatePort,
30 RespondFromAlternateIp,
31 RespondFromAlternateIpPort
32 } ProcessResult;
33
34 /// Process a received StunMessage, and produce a reply
35 /// Returns true if the response message is to be sent
36 ProcessResult processStunMessage(AsyncSocketBase* turnSocket, TurnAllocationManager& turnAllocationManager, StunMessage& request, StunMessage& response, bool isRFC3489BackwardsCompatServer=false);
37 void processTurnData(TurnAllocationManager& turnAllocationManager, unsigned short channelNumber, const StunTuple& localTuple, const StunTuple& remoteTuple, boost::shared_ptr<DataBuffer>& data);
38
39 const ReTurnConfig& getConfig() { return mTurnManager.getConfig(); }
40
41 private:
42
43 TurnManager& mTurnManager;
44
45 // RFC3489 Server List
46 bool mRFC3489SupportEnabled;
47 asio::ip::address mPrim3489Address;
48 unsigned short mPrim3489Port;
49 asio::ip::address mAlt3489Address;
50 unsigned short mAlt3489Port;
51
52 resip::Data mPrivateNonceKey;
53
54 // Authentication handler
55 bool handleAuthentication(StunMessage& request, StunMessage& response);
56
57 // Specific request processors
58 ProcessResult processStunBindingRequest(StunMessage& request, StunMessage& response, bool isRFC3489BackwardsCompatServer);
59 ProcessResult processStunSharedSecretRequest(StunMessage& request, StunMessage& response);
60 ProcessResult processTurnAllocateRequest(AsyncSocketBase* turnSocket, TurnAllocationManager& turnAllocationManager, StunMessage& request, StunMessage& response);
61 ProcessResult processTurnRefreshRequest(TurnAllocationManager& turnAllocationManager, StunMessage& request, StunMessage& response);
62 ProcessResult processTurnCreatePermissionRequest(TurnAllocationManager& turnAllocationManager, StunMessage& request, StunMessage& response);
63 ProcessResult processTurnChannelBindRequest(TurnAllocationManager& turnAllocationManager, StunMessage& request, StunMessage& response);
64
65 // Specific Indication processors
66 void processTurnSendIndication(TurnAllocationManager& turnAllocationManager, StunMessage& request);
67
68 // Utility methods
69 void buildErrorResponse(StunMessage& response, unsigned short errorCode, const char* msg, const char* realm = 0);
70 void generateNonce(const resip::Data& timestamp, resip::Data& nonce);
71 enum CheckNonceResult { Valid, NotValid, Expired };
72 CheckNonceResult checkNonce(const resip::Data& nonce);
73 };
74
75 }
76
77 #endif
78
79
80 /* ====================================================================
81
82 Copyright (c) 2007-2008, Plantronics, Inc.
83 All rights reserved.
84
85 Redistribution and use in source and binary forms, with or without
86 modification, are permitted provided that the following conditions are
87 met:
88
89 1. Redistributions of source code must retain the above copyright
90 notice, this list of conditions and the following disclaimer.
91
92 2. Redistributions in binary form must reproduce the above copyright
93 notice, this list of conditions and the following disclaimer in the
94 documentation and/or other materials provided with the distribution.
95
96 3. Neither the name of Plantronics nor the names of its contributors
97 may be used to endorse or promote products derived from this
98 software without specific prior written permission.
99
100 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
101 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
102 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
103 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
104 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
105 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
106 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
107 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
108 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
109 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
110 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
111
112 ==================================================================== */

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