/usr/include/sipxtapi/os/IStunSocket.h is in libsipxtapi-dev 3.3.0~test17-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | //
// Copyright (C) 2006 Pingtel Corp.
//
// $$
//////////////////////////////////////////////////////////////////////////////
#ifndef _IStunSocket_h_
#define _IStunSocket_h_
#include "os/OsDateTime.h"
#include "os/OsMsg.h"
#include "utl/UtlString.h"
// DEFINES
#define NAT_MSG_TYPE (OsMsg::USER_START + 1) /**< Stun Msg type/Id */
// The follow defines are used to keep track of what has been recorded for
// various time-based metrics.
#define ONDS_MARK_NONE 0x00000000
#define ONDS_MARK_FIRST_READ 0x00000001
#define ONDS_MARK_LAST_READ 0x00000002
#define ONDS_MARK_FIRST_WRITE 0x00000004
#define ONDS_MARK_LAST_WRITE 0x00000008
#define MAX_RTP_BYTES 4096
typedef enum
{
UNKNOWN_PACKET,
MEDIA_PACKET,
STUN_PROBE_PACKET,
STUN_DISCOVERY_PACKET,
TURN_PACKET,
CRLF_KEEPALIVE_PACKET,
STUN_KEEPALIVE_PACKET,
OTHER_PACKET
} PacketType ;
/**
* Possible roles that a Media connection can have.
*/
typedef enum
{
RTP_TRANSPORT_UNKNOWN = 0x00000000,
RTP_TRANSPORT_UDP = 0x00000001,
RTP_TRANSPORT_TCP = 0x00000002,
RTP_TCP_ROLE_ACTIVE = 0x00000004,
RTP_TCP_ROLE_PASSIVE = 0x00000008,
RTP_TCP_ROLE_ACTPASS = 0x00000010,
RTP_TCP_ROLE_CONNECTION = 0x00000020,
} RTP_TRANSPORT ;
typedef int RtpTransportOptions;
typedef int RtpTcpRoles;
class OsSocket;
class OsNotification;
typedef enum
{
STUN = 0x02,
DATA = 0x03
} TURN_FRAMING_TYPE;
/**
* Generic interface representing a media transport object.
* Implemented by VoiceEngineDatagramSocket, VoiceEngineConnectionSocket,
* and any other class which provides RTP transport for VoiceEngine.
*/
class IStunSocket
{
/* //////////////////////////// PUBLIC //////////////////////////////////// */
public:
/* ============================ MANIPULATORS ============================== */
/**
* virtual destructor.
*/
virtual ~IStunSocket() {};
virtual OsSocket* getSocket() = 0;
/**
* Standard write - should be used to invoke the base class's write method
*/
virtual int socketWrite(const char* buffer, int bufferLength,
const char* ipAddress, int port, PacketType packetType=UNKNOWN_PACKET) = 0;
virtual UtlBoolean getRelayIp(UtlString* ip, int* port) = 0;
virtual UtlBoolean getMappedIp(UtlString* ip, int* port) = 0;
virtual void enableTransparentReads(bool bEnable) = 0;
/**
* Enable STUN. Enabling STUN will reset the the keep alive timer and
* will force a binding refresh.
*
* @param szStunServer
* @param stunPort
* @param iKeepAlive
* @param stunOptions
* @param bReadFromSocket
*/
virtual void enableStun(const char* szStunServer,
int stunPort,
int iKeepAlive,
int stunOptions,
bool bReadFromSocket) = 0;
/**
* Sets the STUN-resolved address and port for this socket.
*
* @param address String containing the stunned address.
* @param iPort integer value of the stunned port.
*/
virtual void setStunAddress(const UtlString& address, const int iPort) = 0;
/**
* Set the TURN-dervied relay address for this socket.
*
* @param address TURN-derived hostname/IP address
* @param iPort TURN-derived port address
*/
virtual void setTurnAddress(const UtlString& address, const int iPort) = 0;
/**
* Report that a stun attempt failed.
*/
virtual void markStunFailure() = 0;
/**
* Report that a stun attempt succeeded.
*/
virtual void markStunSuccess(bool bAddressChanged) = 0;
/**
* Report that a stun attempt failed.
*/
virtual void markTurnFailure() = 0;
/**
* Report that a stun attempt succeeded.
*/
virtual void markTurnSuccess() = 0;
/**
* Reset the destination address for this OsNatDatagramSocket. This
* method is called by the OsStunAgentTask when a better address is
* found via STUN/ICE.
*
* @param address The new destination address
* @param iPort The new destination port
* @param priority Priority of the destination address
*/
virtual void evaluateDestinationAddress(const UtlString& address, int iPort, int priority) = 0;
/**
* Enable STUN. Enabling STUN will reset the the keep alive timer and
* will force a binding refresh.
*
* @param szTurnSever
* @param turnPort
* @param iKeepAlive
* @param username
* @param password
* @param bReadFromSocket
*/
virtual void enableTurn(const char* szTurnSever,
int turnPort,
int iKeepAlive,
const char* username,
const char* password,
bool bReadFromSocket) = 0;
/**
* Prepares a destination under TURN usage.
*/
virtual void readyDestination(const char* szAddress, int iPort) = 0;
/**
* TODO: DOCS
*/
virtual UtlBoolean applyDestinationAddress(const char* szAddress, int iPort) = 0;
/**
* TODO: DOCS
*/
virtual UtlBoolean getBestDestinationAddress(UtlString& address, int& iPort) = 0;
/**
* Add an alternate destination to this OsNatDatagramSocket. Alternate
* destinations are tested by sending stun packets. If a stun response is
* received and the priority is greater than what has already been selected
* then that address is used.
*
* @param szAddress IP address of the alternate destination
* @param iPort port number of the alternate destination
* @param priority priority of the alternate where a higher number
* indicates a higher priority.
*/
virtual void addAlternateDestination(const char* szAddress, int iPort, int priority) = 0;
/**
* Set a notification object to be signaled when the first the data
* packet is received from the socket. Once this is signaled, the
* notification object is discarded.
*/
virtual void setReadNotification(OsNotification* pNotification) = 0 ;
/* ============================ ACCESSORS ================================= */
/**
* Get the timestamp of the first read data packet (excluding any
* STUN/TURN/NAT packets).
*/
virtual bool getFirstReadTime(OsDateTime& time) = 0 ;
/**
* Get the timestamp of the last read data packet (excluding any
* STUN/TURN/NAT packets).
*/
virtual bool getLastReadTime(OsDateTime& time) = 0 ;
/**
* Get the timestamp of the first written data packet (excluding any
* STUN/TURN/NAT packets).
*/
virtual bool getFirstWriteTime(OsDateTime& time) = 0 ;
/**
* Get the timestamp of the last written data packet (excluding any
* STUN/TURN/NAT packets).
*/
virtual bool getLastWriteTime(OsDateTime& time) = 0 ;
/**
* Cleanup routine.
*/
virtual void destroy() = 0;
};
#endif // #ifndef _IStunSocket_h_
|