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

Contents of /main/reTurn/TurnAllocation.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7321 - (show annotations) (download)
Sun Oct 14 18:18:46 2007 UTC (12 years, 1 month ago) by sgodin
File MIME type: text/plain
File size: 4473 byte(s)
- initial checkin of reTurn project - Stun/Turn Server and Client Library
- see README.txt for more info and status
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 "TurnTransportHandler.hxx"
12
13 namespace reTurn {
14
15 class TurnPermission;
16 class TurnManager;
17 class UdpRelayServer;
18 class TurnTransportBase;
19
20 class TurnAllocation
21 : public TurnTransportHandler,
22 private boost::noncopyable
23 {
24 public:
25 explicit TurnAllocation(TurnManager& turnManager,
26 TurnTransportBase* localTurnTransport,
27 const StunTuple& clientLocalTuple,
28 const StunTuple& clientRemoteTuple,
29 const StunAuth& clientAuth,
30 const StunTuple& requestedTuple,
31 unsigned int lifetime=0,
32 UInt32 requestedPortProps=0, // requested props are only store for comparison later
33 UInt32 requestedTransport=StunTuple::None,
34 asio::ip::address* requestedIpAddress=0);
35 ~TurnAllocation();
36
37 const TurnAllocationKey& getKey() { return mKey; }
38 void refresh(unsigned int lifetime); // update expiration time
39
40 void setActiveDestination(const StunTuple& activeDestination);
41 bool isActiveDestinationSet() { return mActiveDestinationSet; }
42 void clearActiveDestination();
43
44 // checks if the permission exists or not - also checks for expired
45 // permissions
46 bool existsPermission(const asio::ip::address& address);
47
48 // create Permission if not present, otherwise refresh permission timer
49 void refreshPermission(const asio::ip::address& address);
50
51 // this get's called when being notified that the transport that the allocation came from
52 // has been destroyed
53 void onTransportDestroyed();
54
55 void sendDataToRemote(const resip::Data& data);
56 void sendDataToRemote(const StunTuple& remoteAddress, const resip::Data& data);
57 void sendDataToLocal(const StunTuple& fromAddress, const resip::Data& data);
58
59 // !slg! todo - should be private with accessors
60 TurnAllocationKey mKey; // contains ClientLocalTuple and clientRemoteTuple
61 StunAuth mClientAuth;
62 StunTuple mRequestedTuple;
63 UInt32 mRequestedPortProps;
64 UInt32 mRequestedTransport;
65 asio::ip::address mRequestedIpAddress;
66
67 time_t mExpires;
68 //unsigned int mBandwidth; // future use
69
70 StunTuple mActiveDestination;
71 bool mActiveDestinationSet;
72
73 private:
74 typedef std::map<asio::ip::address,TurnPermission*> TurnPermissionMap;
75 TurnPermissionMap mTurnPermissionMap;
76
77 TurnManager& mTurnManager;
78 asio::deadline_timer mAllocationTimer;
79
80 TurnTransportBase* mLocalTurnTransport;
81 UdpRelayServer* mUdpRelayServer;
82 };
83
84 }
85
86 #endif
87
88
89 /* ====================================================================
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:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27