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

Contents of /main/reTurn/TurnAllocation.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7425 - (show annotations) (download)
Sun Nov 25 22:31:16 2007 UTC (12 years ago) by sgodin
File MIME type: text/plain
File size: 5109 byte(s)
- asynchronous reTurn client work started - not completed yet
1 #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 "AsyncSocketBaseHandler.hxx"
12 #include "ChannelManager.hxx"
13
14 namespace reTurn {
15
16 class TurnPermission;
17 class TurnManager;
18 class AsyncSocketBase;
19 class UdpRelayServer;
20
21 class TurnAllocation
22 : public AsyncSocketBaseHandler,
23 private boost::noncopyable
24 {
25 public:
26 explicit TurnAllocation(TurnManager& turnManager,
27 AsyncSocketBase* localTurnSocket,
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 socket that the allocation came from
49 // has been destroyed
50 void onSocketDestroyed();
51
52 // Used when framed data is received from client, to forward data to peer
53 void sendDataToPeer(unsigned short channelNumber, resip::SharedPtr<resip::Data> data, bool framed);
54 // Used when Send Indication is received from client, to forward data to peer
55 void sendDataToPeer(unsigned short channelNumber, const StunTuple& peerAddress, resip::SharedPtr<resip::Data> data, bool framed);
56 // Used when Data is received from peer, to forward data to client
57 void sendDataToClient(const StunTuple& peerAddress, resip::SharedPtr<resip::Data> data);
58
59 // Called when a ChannelConfirmed Indication is received
60 void serverToClientChannelConfirmed(unsigned short channelNumber, const StunTuple& peerAddress);
61
62 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, resip::SharedPtr<resip::Data> data, bool framed);
69
70 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 AsyncSocketBase* mLocalTurnSocket;
87 boost::shared_ptr<UdpRelayServer> mUdpRelayServer;
88
89 ChannelManager mChannelManager;
90 };
91
92 }
93
94 #endif
95
96
97 /* ====================================================================
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