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

Annotation of /main/reTurn/TurnAllocation.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7754 - (hide annotations) (download)
Mon May 26 21:55:31 2008 UTC (11 years, 6 months ago) by sgodin
File MIME type: text/plain
File size: 4529 byte(s)
-updated return from behave-turn-05 to behave-turn-07
  - Highlights...
  - removed 4-byte framing for all TURN messaging
  - Uses new Channel Bind mechanism
  - new allocation props header, and reservation token header
  - move requested ip address header
-synchronous reTurn client implementation used asio::socket::cancel which now
 requires ASIO_ENABLE_CANCELIO define on windows platforms in asio version 1.0.0
-updated reflow for reTurn changes

1 sgodin 7321 #ifndef TURNALLOCATION_HXX
2     #define TURNALLOCATION_HXX
3    
4     #include <map>
5     #include <boost/noncopyable.hpp>
6     #include <asio.hpp>
7    
8     #include "StunTuple.hxx"
9     #include "StunAuth.hxx"
10     #include "TurnAllocationKey.hxx"
11 sgodin 7418 #include "AsyncSocketBaseHandler.hxx"
12 sgodin 7521 #include "DataBuffer.hxx"
13 sgodin 7355 #include "ChannelManager.hxx"
14 sgodin 7321
15     namespace reTurn {
16    
17     class TurnPermission;
18     class TurnManager;
19 sgodin 7418 class AsyncSocketBase;
20 sgodin 7321 class UdpRelayServer;
21    
22     class TurnAllocation
23 sgodin 7425 : public AsyncSocketBaseHandler,
24 sgodin 7321 private boost::noncopyable
25     {
26     public:
27     explicit TurnAllocation(TurnManager& turnManager,
28 sgodin 7418 AsyncSocketBase* localTurnSocket,
29 sgodin 7321 const StunTuple& clientLocalTuple,
30     const StunTuple& clientRemoteTuple,
31     const StunAuth& clientAuth,
32     const StunTuple& requestedTuple,
33 sgodin 7754 unsigned int lifetime);
34 sgodin 7321 ~TurnAllocation();
35    
36     const TurnAllocationKey& getKey() { return mKey; }
37     void refresh(unsigned int lifetime); // update expiration time
38    
39     // checks if the permission exists or not - also checks for expired
40     // permissions
41     bool existsPermission(const asio::ip::address& address);
42    
43     // create Permission if not present, otherwise refresh permission timer
44     void refreshPermission(const asio::ip::address& address);
45    
46 sgodin 7418 // this get's called when being notified that the socket that the allocation came from
47 sgodin 7321 // has been destroyed
48 sgodin 7418 void onSocketDestroyed();
49 sgodin 7321
50 sgodin 7347 // Used when framed data is received from client, to forward data to peer
51 sgodin 7754 void sendDataToPeer(unsigned short channelNumber, boost::shared_ptr<DataBuffer>& data, bool isFramed);
52 sgodin 7347 // Used when Send Indication is received from client, to forward data to peer
53 sgodin 7754 void sendDataToPeer(const StunTuple& peerAddress, boost::shared_ptr<DataBuffer>& data, bool isFramed);
54 sgodin 7347 // Used when Data is received from peer, to forward data to client
55 sgodin 7526 void sendDataToClient(const StunTuple& peerAddress, boost::shared_ptr<DataBuffer>& data);
56 sgodin 7321
57 sgodin 7754 // Called when a ChannelBind Request is received
58     bool addChannelBinding(const StunTuple& peerAddress, unsigned short channelNumber);
59 sgodin 7348
60 sgodin 7395 const StunTuple& getRequestedTuple() const { return mRequestedTuple; }
61     time_t getExpires() const { return mExpires; }
62     const StunAuth& getClientAuth() const { return mClientAuth; }
63    
64     private:
65 sgodin 7321 TurnAllocationKey mKey; // contains ClientLocalTuple and clientRemoteTuple
66     StunAuth mClientAuth;
67     StunTuple mRequestedTuple;
68    
69     time_t mExpires;
70     //unsigned int mBandwidth; // future use
71    
72     typedef std::map<asio::ip::address,TurnPermission*> TurnPermissionMap;
73     TurnPermissionMap mTurnPermissionMap;
74    
75     TurnManager& mTurnManager;
76     asio::deadline_timer mAllocationTimer;
77    
78 sgodin 7418 AsyncSocketBase* mLocalTurnSocket;
79 sgodin 7368 boost::shared_ptr<UdpRelayServer> mUdpRelayServer;
80 sgodin 7348
81 sgodin 7355 ChannelManager mChannelManager;
82 sgodin 7321 };
83    
84     }
85    
86     #endif
87    
88    
89 sgodin 7366 /* ====================================================================
90    
91     Original contribution Copyright (C) 2007 Plantronics, Inc.
92     Provided under the terms of the Vovida Software License, Version 2.0.
93    
94     The Vovida Software License, Version 2.0
95    
96     Redistribution and use in source and binary forms, with or without
97     modification, are permitted provided that the following conditions
98     are met:
99    
100     1. Redistributions of source code must retain the above copyright
101     notice, this list of conditions and the following disclaimer.
102    
103     2. Redistributions in binary form must reproduce the above copyright
104     notice, this list of conditions and the following disclaimer in
105     the documentation and/or other materials provided with the
106     distribution.
107    
108     THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
109     WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
110     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
111     NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
112     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
113     IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
114     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
115     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
116     PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
117     OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
118     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
119     USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
120     DAMAGE.
121    
122     ==================================================================== */
123    

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