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

Annotation of /main/reTurn/TurnAllocation.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7418 - (hide annotations) (download)
Wed Nov 21 22:28:22 2007 UTC (12 years ago) by sgodin
File MIME type: text/plain
File size: 5118 byte(s)
-major restructuring in preparation for async client api
-optimized data copying
-Tcp and Tls servers currently disabled - still need some work to update to new structure
-fix in client handling of channel number
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 7355 #include "ChannelManager.hxx"
13 sgodin 7321
14     namespace reTurn {
15    
16     class TurnPermission;
17     class TurnManager;
18 sgodin 7418 class AsyncSocketBase;
19 sgodin 7321 class UdpRelayServer;
20    
21     class TurnAllocation
22 sgodin 7418 : public AsyncSocketBaseDestroyedHandler,
23 sgodin 7321 private boost::noncopyable
24     {
25     public:
26     explicit TurnAllocation(TurnManager& turnManager,
27 sgodin 7418 AsyncSocketBase* localTurnSocket,
28 sgodin 7321 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 sgodin 7418 // this get's called when being notified that the socket that the allocation came from
49 sgodin 7321 // has been destroyed
50 sgodin 7418 void onSocketDestroyed();
51 sgodin 7321
52 sgodin 7347 // Used when framed data is received from client, to forward data to peer
53 sgodin 7418 void sendDataToPeer(unsigned short channelNumber, resip::SharedPtr<resip::Data> data, bool framed);
54 sgodin 7347 // Used when Send Indication is received from client, to forward data to peer
55 sgodin 7418 void sendDataToPeer(unsigned short channelNumber, const StunTuple& peerAddress, resip::SharedPtr<resip::Data> data, bool framed);
56 sgodin 7347 // Used when Data is received from peer, to forward data to client
57 sgodin 7418 void sendDataToClient(const StunTuple& peerAddress, resip::SharedPtr<resip::Data> data);
58 sgodin 7321
59 sgodin 7348 // Called when a ChannelConfirmed Indication is received
60 sgodin 7408 void serverToClientChannelConfirmed(unsigned short channelNumber, const StunTuple& peerAddress);
61 sgodin 7348
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 sgodin 7418 void sendDataToPeer(const StunTuple& peerAddress, resip::SharedPtr<resip::Data> data, bool framed);
69 sgodin 7395
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 sgodin 7418 AsyncSocketBase* mLocalTurnSocket;
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