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

Annotation of /main/reTurn/TurnAllocation.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7395 - (hide annotations) (download)
Fri Nov 2 21:42:41 2007 UTC (12 years, 1 month ago) by sgodin
File MIME type: text/plain
File size: 5037 byte(s)
-implemented 3489-bis11 bind request on client api
-implemented synchronous DNS hostname resolution for client api
-implemented automatic client allocation refreshes
-fixed client TCP socket reading to handle TCP messages that are received in multiple packets
-cleanup up TurnAllocation accessors
-implemented proper xor handling for turn address attributes

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

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