sipxportlib  Version 3.3
StunUtils.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 #ifndef _StunUtils_h_
12 #define _StunUtils_h_
13 
14 // SYSTEM INCLUDES
15 
16 // APPLICATION INCLUDES
17 #include "os/OsDatagramSocket.h"
18 #include "os/StunMessage.h"
19 #include "os/TurnMessage.h"
20 
21 // DEFINES
22 #define DEFAULT_STUN_PORT 3478
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 // STRUCTS
28 // TYPEDEFS
29 typedef enum
30 {
39 } STUN_NAT_TYPE ;
40 
41 // FORWARD DECLARATIONS
42 
46 class StunUtils
47 {
48 /* //////////////////////////// PUBLIC //////////////////////////////////// */
49  public:
50 
51 /* ============================ CREATORS ================================== */
52 
53 /* ============================ MANIPULATORS ============================== */
54 
55 static STUN_NAT_TYPE determineStunNatType(const char* szServer, const int port) ;
56 
57 static bool sendStunNatTest(OsDatagramSocket* pSocket,
58  const char* szServerIp,
59  const int port,
60  bool bChangePort,
61  bool bChangeIP,
62  char* szMappedIp,
63  uint16_t* piMappedPort,
64  char* szChangedIp,
65  uint16_t* piChangedPort) ;
66 
67 static bool allocateTurnAddress(OsDatagramSocket* pSocket,
68  const char* szServerIp,
69  const int port,
70  char* szRelayIp,
71  uint16_t* piRelayPort,
72  uint32_t* plLifetime) ;
73 
74 
75 static const char* natTypeToString(STUN_NAT_TYPE type) ;
76 
77 static void debugDump(char* pPacket, size_t nPacket, UtlString& output) ;
78 
79 
80 /* ============================ ACCESSORS ================================= */
81 
82 /* ============================ INQUIRY =================================== */
83 
84 /* //////////////////////////// PROTECTED ///////////////////////////////// */
85  protected:
86 
87 /* //////////////////////////// PRIVATE /////////////////////////////////// */
88  private:
89 
91  StunUtils();
92 
94  StunUtils(const StunUtils& rStunUtils);
95 
97  StunUtils& operator=(const StunUtils& rhs);
98 
100  virtual ~StunUtils();
101 };
102 
103 /* ============================ INLINE METHODS ============================ */
104 
105 #endif // _StunUtils_h_
static void debugDump(char *pPacket, size_t nPacket, UtlString &output)
Definition: StunUtils.cpp:480
static bool sendStunNatTest(OsDatagramSocket *pSocket, const char *szServerIp, const int port, bool bChangePort, bool bChangeIP, char *szMappedIp, uint16_t *piMappedPort, char *szChangedIp, uint16_t *piChangedPort)
Definition: StunUtils.cpp:194
Definition: StunUtils.h:34
Definition: StunUtils.h:38
Definition: StunUtils.h:31
unsigned short uint16_t
Definition: stdint.h:79
Definition: StunUtils.h:33
Definition: StunUtils.h:32
static const char * natTypeToString(STUN_NAT_TYPE type)
Definition: StunUtils.cpp:273
Definition: StunUtils.h:37
unsigned int uint32_t
Definition: stdint.h:80
Definition: UtlString.h:48
Definition: OsDatagramSocket.h:37
Definition: StunUtils.h:35
static bool allocateTurnAddress(OsDatagramSocket *pSocket, const char *szServerIp, const int port, char *szRelayIp, uint16_t *piRelayPort, uint32_t *plLifetime)
Definition: StunUtils.cpp:123
static STUN_NAT_TYPE determineStunNatType(const char *szServer, const int port)
Definition: StunUtils.cpp:38
Definition: StunUtils.h:36
STUN_NAT_TYPE
Definition: StunUtils.h:29
Definition: StunUtils.h:46