sipxportlib  Version 3.3
IStunSocket.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Pingtel Corp.
3 //
4 // $$
6 
7 #ifndef _IStunSocket_h_
8 #define _IStunSocket_h_
9 
10 #include "os/OsDateTime.h"
11 #include "os/OsMsg.h"
12 #include "utl/UtlString.h"
13 
14 // DEFINES
15 #define NAT_MSG_TYPE (OsMsg::USER_START + 1)
17 // The follow defines are used to keep track of what has been recorded for
18 // various time-based metrics.
19 #define ONDS_MARK_NONE 0x00000000
20 #define ONDS_MARK_FIRST_READ 0x00000001
21 #define ONDS_MARK_LAST_READ 0x00000002
22 #define ONDS_MARK_FIRST_WRITE 0x00000004
23 #define ONDS_MARK_LAST_WRITE 0x00000008
24 
25 #define MAX_RTP_BYTES 4096
26 
27 typedef enum
28 {
37 } PacketType ;
38 
42  typedef enum
43  {
44  RTP_TRANSPORT_UNKNOWN = 0x00000000,
45  RTP_TRANSPORT_UDP = 0x00000001,
46  RTP_TRANSPORT_TCP = 0x00000002,
47  RTP_TCP_ROLE_ACTIVE = 0x00000004,
48  RTP_TCP_ROLE_PASSIVE = 0x00000008,
49  RTP_TCP_ROLE_ACTPASS = 0x00000010,
51 } RTP_TRANSPORT ;
52 
53 typedef int RtpTransportOptions;
54 typedef int RtpTcpRoles;
55 
56 class OsSocket;
57 class OsNotification;
58 
59 typedef enum
60 {
61  STUN = 0x02,
62  DATA = 0x03
64 
71 {
72 /* //////////////////////////// PUBLIC //////////////////////////////////// */
73 public:
74 
75 /* ============================ MANIPULATORS ============================== */
76 
80  virtual ~IStunSocket() {};
81 
82 
83  virtual OsSocket* getSocket() = 0;
84 
88  virtual int socketWrite(const char* buffer, int bufferLength,
89  const char* ipAddress, int port, PacketType packetType=UNKNOWN_PACKET) = 0;
90 
91  virtual UtlBoolean getRelayIp(UtlString* ip, int* port) = 0;
92  virtual UtlBoolean getMappedIp(UtlString* ip, int* port) = 0;
93 
94  virtual void enableTransparentReads(bool bEnable) = 0;
95 
106  virtual void enableStun(const char* szStunServer,
107  int stunPort,
108  int iKeepAlive,
109  int stunOptions,
110  bool bReadFromSocket) = 0;
111 
112 
113 
121  virtual void setStunAddress(const UtlString& address, const int iPort) = 0;
122 
129  virtual void setTurnAddress(const UtlString& address, const int iPort) = 0;
130 
131 
135  virtual void markStunFailure() = 0;
136 
137 
141  virtual void markStunSuccess(bool bAddressChanged) = 0;
142 
143 
147  virtual void markTurnFailure() = 0;
148 
149 
153  virtual void markTurnSuccess() = 0;
154 
155 
165  virtual void evaluateDestinationAddress(const UtlString& address, int iPort, int priority) = 0;
166 
167 
179  virtual void enableTurn(const char* szTurnSever,
180  int turnPort,
181  int iKeepAlive,
182  const char* username,
183  const char* password,
184  bool bReadFromSocket) = 0;
185 
189  virtual void readyDestination(const char* szAddress, int iPort) = 0;
190 
194  virtual UtlBoolean applyDestinationAddress(const char* szAddress, int iPort) = 0;
195 
199  virtual UtlBoolean getBestDestinationAddress(UtlString& address, int& iPort) = 0;
200 
212  virtual void addAlternateDestination(const char* szAddress, int iPort, int priority) = 0;
213 
214 
220  virtual void setReadNotification(OsNotification* pNotification) = 0 ;
221 
222 /* ============================ ACCESSORS ================================= */
223 
228  virtual bool getFirstReadTime(OsDateTime& time) = 0 ;
229 
234  virtual bool getLastReadTime(OsDateTime& time) = 0 ;
235 
240  virtual bool getFirstWriteTime(OsDateTime& time) = 0 ;
241 
246  virtual bool getLastWriteTime(OsDateTime& time) = 0 ;
247 
251  virtual void destroy() = 0;
252 
253 };
254 
255 
256 
257 
258 #endif // #ifndef _IStunSocket_h_
virtual void readyDestination(const char *szAddress, int iPort)=0
Definition: IStunSocket.h:32
Definition: OsSocket.h:79
Definition: IStunSocket.h:45
virtual UtlBoolean applyDestinationAddress(const char *szAddress, int iPort)=0
virtual bool getLastReadTime(OsDateTime &time)=0
virtual bool getLastWriteTime(OsDateTime &time)=0
Definition: IStunSocket.h:36
RTP_TRANSPORT
Definition: IStunSocket.h:42
virtual void evaluateDestinationAddress(const UtlString &address, int iPort, int priority)=0
Definition: IStunSocket.h:47
virtual void enableTurn(const char *szTurnSever, int turnPort, int iKeepAlive, const char *username, const char *password, bool bReadFromSocket)=0
Definition: IStunSocket.h:70
int RtpTransportOptions
Definition: IStunSocket.h:53
virtual void destroy()=0
Definition: IStunSocket.h:33
virtual void markStunSuccess(bool bAddressChanged)=0
Definition: IStunSocket.h:34
virtual int socketWrite(const char *buffer, int bufferLength, const char *ipAddress, int port, PacketType packetType=UNKNOWN_PACKET)=0
time_t __cdecl time(time_t *ptt)
PacketType
Definition: IStunSocket.h:27
Definition: OsNotification.h:35
virtual void addAlternateDestination(const char *szAddress, int iPort, int priority)=0
Definition: IStunSocket.h:44
virtual void setReadNotification(OsNotification *pNotification)=0
virtual UtlBoolean getBestDestinationAddress(UtlString &address, int &iPort)=0
virtual void setStunAddress(const UtlString &address, const int iPort)=0
Definition: UtlString.h:48
virtual UtlBoolean getMappedIp(UtlString *ip, int *port)=0
Definition: IStunSocket.h:61
TURN_FRAMING_TYPE
Definition: IStunSocket.h:59
int RtpTcpRoles
Definition: IStunSocket.h:54
Definition: IStunSocket.h:49
virtual void markStunFailure()=0
Definition: IStunSocket.h:31
virtual void enableStun(const char *szStunServer, int stunPort, int iKeepAlive, int stunOptions, bool bReadFromSocket)=0
virtual void enableTransparentReads(bool bEnable)=0
virtual UtlBoolean getRelayIp(UtlString *ip, int *port)=0
virtual ~IStunSocket()
Definition: IStunSocket.h:80
Definition: IStunSocket.h:46
int UtlBoolean
Definition: UtlDefs.h:41
Definition: IStunSocket.h:35
virtual bool getFirstWriteTime(OsDateTime &time)=0
virtual bool getFirstReadTime(OsDateTime &time)=0
Definition: IStunSocket.h:30
virtual OsSocket * getSocket()=0
Definition: IStunSocket.h:50
Definition: IStunSocket.h:62
virtual void markTurnFailure()=0
virtual void setTurnAddress(const UtlString &address, const int iPort)=0
virtual void markTurnSuccess()=0
Definition: IStunSocket.h:48
Definition: IStunSocket.h:29