sipxportlib  Version 3.3
StunMessage.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Robert J. Andreasen, Jr.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 #ifndef _StunMessage_h_
15 #define _StunMessage_h_
16 
17 // SYSTEM INCLUDES
18 // APPLICATION INCLUDES
19 #include "os/OsIntTypes.h"
20 #include "utl/UtlRandom.h"
21 
22 // DEFINES
23 #define STUN_MAX_STRING_LENGTH 128
24 #define STUN_MAX_UNKNOWN_ATTRIBUTES 16
25 #define STUN_MAX_MESSAGE_INTEGRITY_LENGTH 20
26 #define STUN_MIN_CHAR_PAD 4
27 #define STUN_MAGIC_COOKIE 0x2112A442
28 
32 #define MSG_STUN_BIND_REQUEST 0x0001
33 #define MSG_STUN_BIND_RESPONSE 0x0101
34 #define MSG_STUN_BIND_ERROR_RESPONSE 0x0111
35 #define MSG_STUN_SHARED_SECRET_REQUEST 0x0002
36 #define MSG_STUN_SHARED_SECRET_RESPONSE 0x0102
37 #define MSG_STUN_SHARED_SECRET_ERROR_RESPONSE 0x0112
38 
42 #define ATTR_STUN_MAPPED_ADDRESS 0x0001
43 #define ATTR_STUN_RESPONSE_ADDRESS 0x0002 // deprecated
44 #define ATTR_STUN_CHANGE_REQUEST 0x0003 // deprecated
45 #define ATTR_STUN_SOURCE_ADDRESS 0x0004 // deprecated
46 #define ATTR_STUN_CHANGED_ADDRESS 0x0005 // deprecated
47 #define ATTR_STUN_USERNAME 0x0006
48 #define ATTR_STUN_PASSWORD 0x0007 // deprecated
49 #define ATTR_STUN_MESSAGE_INTEGRITY 0x0008
50 #define ATTR_STUN_ERROR_CODE 0x0009
51 #define ATTR_STUN_UNKNOWN_ATTRIBUTE 0x000A
52 #define ATTR_STUN_REFLECTED_FROM 0x000B // deprecated
53 #define ATTR_STUN_ALTERNATE_SERVER2 0x000E // deprecated
54 #define ATTR_STUN_REALM 0x0014
55 #define ATTR_STUN_NONCE 0x0015
56 #define ATTR_STUN_XOR_MAPPED_ADDRESS 0x0020
57 #define ATTR_STUN_XOR_ONLY 0x0021 // deprecated
58 #define ATTR_STUN_FINGERPRINT 0x0023
59 #define ATTR_STUN_XOR_MAPPED_ADDRESS2 0x8020 // deprecated
60 #define ATTR_STUN_SERVER 0x8022
61 #define ATTR_STUN_SERVER2 0x0022 // deprecated
62 #define ATTR_STUN_ALTERNATE_SERVER 0x8023
63 #define ATTR_STUN_BINDING_LIFETIME 0x8024
64 
65 #define ATTR_CHANGE_FLAG_PORT 0x0002 // deprecated
66 #define ATTR_CHANGE_FLAG_IP 0x0004 // deprecated
67 
68 #define ATTR_ADDRESS_FAMILY_IPV4 0x01
69 #define ATTR_ADDRESS_FAMILY_IPV6 0x02
70 
71 // Error Defines
72 
73 #define STUN_ERROR_TRY_ALTERNATE_CODE 300
74 #define STUN_ERROR_TRY_ALTERNATE_TEXT "Try Alternative"
75 
76 #define STUN_ERROR_BAD_REQUEST_CODE 400
77 #define STUN_ERROR_BAD_REQUEST_TEXT "Bad request"
78 
79 #define STUN_ERROR_UNAUTHORIZED_CODE 401
80 #define STUN_ERROR_UNAUTHORIZED_TEXT "Unauthorized"
81 
82 #define STUN_ERROR_UNKNOWN_ATTRIBUTE_CODE 420
83 #define STUN_ERROR_UNKNOWN_ATTRIBUTE_TEXT "Unknown attribute"
84 
85 #define STUN_ERROR_STALE_CREDENTIAL_CODE 430
86 #define STUN_ERROR_STALE_CREDENTIAL_TEXT "Stale credential"
87 
88 #define STUN_ERROR_BAD_INTEGRITY_CODE 431
89 #define STUN_ERROR_BAD_INTEGRITY_TEXT "Bad integrity"
90 
91 #define STUN_ERROR_MISSING_USERNAME_CODE 432
92 #define STUN_ERROR_MISSING_USERNAME_TEXT "Missing username"
93 
94 #define STUN_ERROR_USE_TLS_CODE 433
95 #define STUN_ERROR_USE_TLS_TEXT "Use TLS"
96 
97 #define STUN_ERROR_MISSING_REALM_CODE 434
98 #define STUN_ERROR_MISSING_REALM_TEXT "Missing Realm"
99 
100 #define STUN_ERROR_MISSING_NONCE_CODE 435
101 #define STUN_ERROR_MISSING_NONCE_TEXT "Missing Nonce"
102 
103 #define STUN_ERROR_UNKNOWN_USERNAME_CODE 436
104 #define STUN_ERROR_UNKNOWN_USERNAME_TEXT "Unknown username"
105 
106 #define STUN_ERROR_STALE_NONCE_CODE 438
107 #define STUN_ERROR_STALE_NONCE_TEXT "Stale Nonce"
108 
109 #define STUN_ERROR_SERVER_CODE 500
110 #define STUN_ERROR_SERVER_TEXT "Server error"
111 
112 #define STUN_ERROR_GLOBAL_CODE 600
113 #define STUN_ERROR_GLOBAL_TEXT "Global error"
114 
115 // MACROS
116 // EXTERNAL FUNCTIONS
117 // EXTERNAL VARIABLES
118 // CONSTANTS
119 // STRUCTS
120 // TYPEDEFS
121 typedef struct
122 {
124 } STUN_MAGIC_ID ;
125 
126 typedef struct {
127  uint8_t id[12];
129 
130 typedef struct
131 {
137 
138 typedef struct
139 {
143 
144 typedef struct
145 {
147  uint8_t family ; /* unused today */
151 
152 typedef struct
153 {
155  uint8_t unused2:4 ;
156  uint8_t errorClass:4 ; // between 1 and 6
157  uint8_t errorNumber ; // between 0 and 99
158  char szReasonPhrase[STUN_MAX_STRING_LENGTH+1] ;
160 
161 typedef struct
162 {
163  //size_t nTypes ;
167 
168 
169 // FORWARD DECLARATIONS
170 
212 {
213 /* //////////////////////////// PUBLIC //////////////////////////////////// */
214  public:
215 
216 /* ============================ CREATORS ================================== */
217 
222  StunMessage(StunMessage* pRequest = NULL,
223  bool bLegacyMode = true) ;
224 
228  virtual ~StunMessage() ;
229 
230 /* ============================ MANIPULATORS ============================== */
231 
232  virtual void reset() ;
233 
234  virtual bool parse(const char* pBuf, size_t nBufLength) ;
235 
236  virtual bool encode(char* pBuf, size_t nBufLength, size_t& nActualLength) ;
237 
238  virtual bool encodeBody(char* pBuf, size_t nBufLength, size_t& nBytesUsed) ;
239 
240  void setMagicId(STUN_MAGIC_ID& rMagicId) ;
241 
242  void setTransactionId(STUN_TRANSACTION_ID& rTransactionId) ;
243 
244  void allocTransactionId() ;
245 
246  void setType(uint16_t type) ;
247 
248  void setMappedAddress(const char* szIp, const uint16_t port) ;
249 
250  void setResponseAddress(const char* szIp, const uint16_t port) ;
251 
252  void setChangePort(const bool bChange) ;
253 
254  void setChangeIp(const bool bChange) ;
255 
256  void setSourceAddress(const char* szIp, const uint16_t port) ;
257 
258  void setChangedAddress(const char* szIp, const uint16_t port) ;
259 
260  void setUsername(const char* szUsername) ;
261 
262  void setPassword(const char* szPassword) ;
263 
264  void setRealm(const char* szRealm) ;
265 
266  void setNonce(const char* szNonce) ;
267 
268  void setError(const uint16_t code, const char* szReason) ;
269 
270  void addUnknownAttribute(uint16_t attributeId) ;
271 
272  void setReflectedFrom(const char* szIp, const uint16_t port) ;
273 
274  void setServer(const char* szServer) ;
275 
276  void setRequestXorOnly() ;
277 
278  void setSendXorOnly() ;
279 
280  void setIncludeMessageIntegrity(bool bInclude) ;
281 
282  void setIncludeFingerPrint(bool bInclude) ;
283 
284  void setAltServer(const char* szIp, uint16_t port) ;
285 
286 /* ============================ ACCESSORS ================================= */
287 
288  void getMagicId(STUN_MAGIC_ID* pMagicId) ;
289 
290  void getTransactionId(STUN_TRANSACTION_ID* pTransactionId) ;
291 
292  uint16_t getType() ;
293 
294  bool getMappedAddress(char* szIp, uint16_t& rPort) ;
295 
296  bool getResponseAddress(char* szIp, uint16_t& rPort) ;
297 
298  bool getChangePort() ;
299 
300  bool getChangeIp() ;
301 
302  bool getSourceAddress(char* szIp, uint16_t& rPort) ;
303 
304  bool getChangedAddress(char* szIp, uint16_t& rPort) ;
305 
306  bool getUsername(char* szUsername) ;
307 
308  bool getPassword(char* szPassword) ;
309 
310  bool getRealm(char *szRealm) ;
311 
312  bool getNonce(char* szNonce) ;
313 
314  bool getMessageIntegrity(char* cMessageIntegrity) ;
315 
316  bool getError(uint16_t& rCode, char* szReason) ;
317 
318  bool getUnknownAttributes(uint16_t* pList, size_t nMaxItems, size_t& nActualItems) ;
319 
320  bool getReflectedFrom(char* szIp, uint16_t& rPort) ;
321 
322  bool getServer(char* szServer) ;
323 
324  bool getUnknownParsedAttributes(uint16_t* pList, size_t nMaxItems, size_t& nActualItems) ;
325 
326  bool getRequestXorOnly() ;
327 
328  bool getAltServer(char* szIp, uint16_t& rPort) ;
329 
330  bool getFingerPrint(bool& bValid) ;
331 
332 /* ============================ INQUIRY =================================== */
333 
334  virtual bool validateMessageType(uint16_t type) ;
335 
336  static bool isStunMessage(const char* pBuf, uint16_t nBufLength) ;
337 
338  static bool isFingerPrintValid(const char* pBuf, uint16_t nBufLength, bool bMissingOk) ;
339 
340  virtual bool isRequestOrNonErrorResponse() ;
341 
342  virtual bool isMessageIntegrityValid(const char* cPassword, size_t nPassword) ;
343 
344  virtual bool isFingerPrintValid() ;
345 
346 /* //////////////////////////// PROTECTED ///////////////////////////////// */
347  protected:
348 
349  bool encodeByte(char c, char*& pBuf, size_t& nBytesLeft) ;
350 
351  bool encodeShort(uint16_t value, char*& pBuf, size_t& nBytesLeft) ;
352 
353  bool encodeLong(uint32_t value, char*& pBuf, size_t& nBytesLeft) ;
354 
355  bool encodeRaw(const char* cRaw, size_t length, char*& pBuf, size_t& nBytesLeft) ;
356 
357  bool encodeHeader(STUN_MESSAGE_HEADER* pHeader, char*& pBuf, size_t& nBytesLeft) ;
358 
359  bool encodeAttributeHeader(int16_t type, int16_t length, char*& pBuf, size_t& nBytesLeft) ;
360 
361  bool encodeAttributeAddress(uint16_t type, STUN_ATTRIBUTE_ADDRESS* pAddress, char*& pBuf, size_t& nBytesLeft) ;
362 
363  bool encodeXorAttributeAddress(uint16_t type, STUN_ATTRIBUTE_ADDRESS* pAddress, char*& pBuf, size_t& nBytesLeft) ;
364 
365  bool encodeString(uint16_t type, const char* szString, char*& pBuf, size_t& nBytesLeft) ;
366 
367  bool encodeAttributeError(STUN_ATTRIBUTE_ERROR* pError, char*& pBuf, size_t& nBytesLeft) ;
368 
369  bool encodeAttributesUnknown(STUN_ATTRIBUTE_UNKNOWN* pAttributes, char*& pBuf, size_t& nBytesLeft) ;
370 
371  virtual bool parseAttribute(STUN_ATTRIBUTE_HEADER* pHeader, char* pBuf) ;
372 
373  bool parseAddressAttribute(char *pBuf, size_t nLength, STUN_ATTRIBUTE_ADDRESS* pAddress) ;
374 
375  bool parseXorAddressAttribute(char *pBuf, size_t nLength, STUN_ATTRIBUTE_ADDRESS* pAddress) ;
376 
377  bool parseShortAttribute(char *pBuf, size_t nLength, uint16_t* pShort) ;
378 
379  bool parseLongAttribute(char *pBuf, size_t nLength, uint32_t* pLong) ;
380 
381  bool parseStringAttribute(char* pBuf, size_t nLength, char* pString) ;
382 
383  bool parseRawAttribute(char* pBuf, size_t nLength, char* pDest, size_t nDest) ;
384 
385  bool parseErrorAttribute(char *pBuf, size_t nLength, STUN_ATTRIBUTE_ERROR* pError) ;
386 
387  bool parseUnknownAttribute(char* pBuf, size_t nLength, STUN_ATTRIBUTE_UNKNOWN* pAttributes) ;
388 
392  static void calculateHmacSha1(const char* pDataIn,
393  size_t nDataIn,
394  const char* pKey,
395  size_t nKey,
396  char results[20]) ;
397 
398 /* //////////////////////////// PRIVATE /////////////////////////////////// */
399  private:
400  STUN_MESSAGE_HEADER mMsgHeader ;
401  bool mbMsgHeaderValid ;
402  STUN_ATTRIBUTE_ADDRESS mMappedAddress ;
403  bool mbMappedAddressValid ;
404  STUN_ATTRIBUTE_ADDRESS mResponseAddress ;
405  bool mbResponseAddressValid ;
406  STUN_ATTRIBUTE_ADDRESS mChangedAddress ;
407  bool mbChangedAddressValid ;
408  uint32_t mChangeRequest ;
409  bool mbChangeRequestValid ;
410  STUN_ATTRIBUTE_ADDRESS mSourceAddress ;
411  bool mbSourceAddressValid ;
412  char mUsername[STUN_MAX_STRING_LENGTH+1] ;
413  bool mbUsernameValid ;
414  char mPassword[STUN_MAX_STRING_LENGTH+1] ;
415  bool mbPasswordValid ;
416  char mRealm[STUN_MAX_STRING_LENGTH+1] ;
417  bool mbRealmValid ;
418  char mNonce[STUN_MAX_STRING_LENGTH+1] ;
419  bool mbNonceValid ;
420  char mMessageIntegrity[STUN_MAX_MESSAGE_INTEGRITY_LENGTH] ;
421  bool mbMessageIntegrityValid ;
422  STUN_ATTRIBUTE_ERROR mError ;
423  bool mbErrorValid;
424  STUN_ATTRIBUTE_UNKNOWN mUnknownAttributes ;
425  bool mbUnknownAttributesValid ;
426  STUN_ATTRIBUTE_ADDRESS mReflectedFrom ;
427  bool mbReflectedFromValid ;
428  char mServer[STUN_MAX_STRING_LENGTH+1];
429  bool mbServerValid ;
430  bool mbSendXorOnly ;
431  bool mbRequestXorOnly ;
432  UtlRandom mbRandomGenerator ;
433  bool mbIncludeMessageIntegrity ;
434  STUN_ATTRIBUTE_ADDRESS mAltServer ;
435  bool mbAltServerValid ;
436  bool mbIncludeFingerPrint ;
437  char mbFingerPrintValid ;
438  uint32_t mFingerPrint ;
439  char* mpRawData ;
440  size_t mnRawData ;
441  bool mbLegacyMode ;
442 
443  STUN_ATTRIBUTE_UNKNOWN mUnknownParsedAttributes ;
444 
446  StunMessage(const StunMessage& rStunMessage);
447 
449  StunMessage& operator=(const StunMessage& rhs);
450 };
451 
452 /* ============================ INLINE METHODS ============================ */
453 
454 #endif // _StunMessage_h_
#define STUN_MAX_UNKNOWN_ATTRIBUTES
Definition: StunMessage.h:24
StunMessage(StunMessage *pRequest=NULL, bool bLegacyMode=true)
Definition: StunMessage.cpp:48
void setIncludeFingerPrint(bool bInclude)
Definition: StunMessage.cpp:614
Definition: UtlRandom.h:35
bool parseUnknownAttribute(char *pBuf, size_t nLength, STUN_ATTRIBUTE_UNKNOWN *pAttributes)
Definition: StunMessage.cpp:1491
bool getUsername(char *szUsername)
Definition: StunMessage.cpp:726
bool getChangePort()
Definition: StunMessage.cpp:671
bool encodeByte(char c, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1020
void setSourceAddress(const char *szIp, const uint16_t port)
Definition: StunMessage.cpp:512
bool getRealm(char *szRealm)
Definition: StunMessage.cpp:746
uint8_t family
Definition: StunMessage.h:147
virtual bool parseAttribute(STUN_ATTRIBUTE_HEADER *pHeader, char *pBuf)
Definition: StunMessage.cpp:1269
bool getReflectedFrom(char *szIp, uint16_t &rPort)
Definition: StunMessage.cpp:802
uint16_t length
Definition: StunMessage.h:141
void setUsername(const char *szUsername)
Definition: StunMessage.cpp:528
Definition: StunMessage.h:130
bool parseLongAttribute(char *pBuf, size_t nLength, uint32_t *pLong)
Definition: StunMessage.cpp:1418
Include this file if you want use C99 integer types with specified width and corresponding set of mac...
Definition: StunMessage.h:121
bool getError(uint16_t &rCode, char *szReason)
Definition: StunMessage.cpp:775
bool encodeAttributeHeader(int16_t type, int16_t length, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1112
void setChangeIp(const bool bChange)
Definition: StunMessage.cpp:498
virtual bool validateMessageType(uint16_t type)
Definition: StunMessage.cpp:861
bool getMappedAddress(char *szIp, uint16_t &rPort)
Definition: StunMessage.cpp:645
uint8_t errorNumber
Definition: StunMessage.h:157
void setMagicId(STUN_MAGIC_ID &rMagicId)
Definition: StunMessage.cpp:434
Definition: StunMessage.h:138
void setTransactionId(STUN_TRANSACTION_ID &rTransactionId)
Definition: StunMessage.cpp:439
bool parseShortAttribute(char *pBuf, size_t nLength, uint16_t *pShort)
Definition: StunMessage.cpp:1404
unsigned short uint16_t
Definition: stdint.h:79
void setResponseAddress(const char *szIp, const uint16_t port)
Definition: StunMessage.cpp:474
virtual ~StunMessage()
Definition: StunMessage.cpp:78
void setServer(const char *szServer)
Definition: StunMessage.cpp:590
bool encodeHeader(STUN_MESSAGE_HEADER *pHeader, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1095
bool getSourceAddress(char *szIp, uint16_t &rPort)
Definition: StunMessage.cpp:702
unsigned char uint8_t
Definition: stdint.h:78
virtual bool isFingerPrintValid()
Definition: StunMessage.cpp:1012
bool getServer(char *szServer)
Definition: StunMessage.cpp:814
void setPassword(const char *szPassword)
Definition: StunMessage.cpp:537
bool getMessageIntegrity(char *cMessageIntegrity)
Definition: StunMessage.cpp:766
#define NULL
Definition: UtlDefs.h:29
virtual bool isMessageIntegrityValid(const char *cPassword, size_t nPassword)
Definition: StunMessage.cpp:1006
bool getUnknownParsedAttributes(uint16_t *pList, size_t nMaxItems, size_t &nActualItems)
Definition: StunMessage.cpp:831
bool encodeRaw(const char *cRaw, size_t length, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1075
void setReflectedFrom(const char *szIp, const uint16_t port)
Definition: StunMessage.cpp:582
void setChangePort(const bool bChange)
Definition: StunMessage.cpp:483
void setAltServer(const char *szIp, uint16_t port)
Definition: StunMessage.cpp:619
bool parseXorAddressAttribute(char *pBuf, size_t nLength, STUN_ATTRIBUTE_ADDRESS *pAddress)
Definition: StunMessage.cpp:1384
virtual void reset()
Definition: StunMessage.cpp:86
bool getChangeIp()
Definition: StunMessage.cpp:687
void setRequestXorOnly()
Definition: StunMessage.cpp:599
void setRealm(const char *szRealm)
Definition: StunMessage.cpp:546
virtual bool isRequestOrNonErrorResponse()
Definition: StunMessage.cpp:983
bool parseStringAttribute(char *pBuf, size_t nLength, char *pString)
Definition: StunMessage.cpp:1433
virtual bool parse(const char *pBuf, size_t nBufLength)
Definition: StunMessage.cpp:134
virtual bool encode(char *pBuf, size_t nBufLength, size_t &nActualLength)
Definition: StunMessage.cpp:204
unsigned int uint32_t
Definition: stdint.h:80
bool getFingerPrint(bool &bValid)
signed short int16_t
Definition: stdint.h:76
uint32_t address
Definition: StunMessage.h:149
bool encodeLong(uint32_t value, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1056
void setNonce(const char *szNonce)
Definition: StunMessage.cpp:555
uint16_t unused
Definition: StunMessage.h:154
Definition: StunMessage.h:126
virtual bool encodeBody(char *pBuf, size_t nBufLength, size_t &nBytesUsed)
Definition: StunMessage.cpp:317
bool parseRawAttribute(char *pBuf, size_t nLength, char *pDest, size_t nDest)
Definition: StunMessage.cpp:1457
void getTransactionId(STUN_TRANSACTION_ID *pTransactionId)
Definition: StunMessage.cpp:635
uint16_t port
Definition: StunMessage.h:148
bool getChangedAddress(char *szIp, uint16_t &rPort)
Definition: StunMessage.cpp:714
static bool isStunMessage(const char *pBuf, uint16_t nBufLength)
Definition: StunMessage.cpp:882
bool getAltServer(char *szIp, uint16_t &rPort)
Definition: StunMessage.cpp:846
STUN_MAGIC_ID magicId
Definition: StunMessage.h:134
uint16_t length
Definition: StunMessage.h:133
bool getUnknownAttributes(uint16_t *pList, size_t nMaxItems, size_t &nActualItems)
Definition: StunMessage.cpp:786
static void calculateHmacSha1(const char *pDataIn, size_t nDataIn, const char *pKey, size_t nKey, char results[20])
Definition: StunMessage.cpp:1513
#define STUN_MAX_MESSAGE_INTEGRITY_LENGTH
Definition: StunMessage.h:25
Definition: StunMessage.h:144
uint8_t unused
Definition: StunMessage.h:146
uint16_t type
Definition: StunMessage.h:132
uint16_t type
Definition: StunMessage.h:140
bool parseAddressAttribute(char *pBuf, size_t nLength, STUN_ATTRIBUTE_ADDRESS *pAddress)
Definition: StunMessage.cpp:1369
bool encodeAttributeAddress(uint16_t type, STUN_ATTRIBUTE_ADDRESS *pAddress, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1126
void setError(const uint16_t code, const char *szReason)
Definition: StunMessage.cpp:564
Definition: StunMessage.h:152
void allocTransactionId()
Definition: StunMessage.cpp:445
bool getNonce(char *szNonce)
Definition: StunMessage.cpp:756
void setType(uint16_t type)
Definition: StunMessage.cpp:459
STUN_TRANSACTION_ID transactionId
Definition: StunMessage.h:135
bool getRequestXorOnly()
Definition: StunMessage.cpp:825
bool encodeAttributesUnknown(STUN_ATTRIBUTE_UNKNOWN *pAttributes, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1240
bool getResponseAddress(char *szIp, uint16_t &rPort)
Definition: StunMessage.cpp:658
bool encodeString(uint16_t type, const char *szString, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1167
bool encodeShort(uint16_t value, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1037
bool encodeAttributeError(STUN_ATTRIBUTE_ERROR *pError, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1212
uint32_t id
Definition: StunMessage.h:123
Definition: StunMessage.h:211
void setSendXorOnly()
Definition: StunMessage.cpp:604
uint32_t nTypes
Definition: StunMessage.h:164
Definition: StunMessage.h:161
void addUnknownAttribute(uint16_t attributeId)
Definition: StunMessage.cpp:573
uint16_t getType()
Definition: StunMessage.cpp:640
bool encodeXorAttributeAddress(uint16_t type, STUN_ATTRIBUTE_ADDRESS *pAddress, char *&pBuf, size_t &nBytesLeft)
Definition: StunMessage.cpp:1143
bool parseErrorAttribute(char *pBuf, size_t nLength, STUN_ATTRIBUTE_ERROR *pError)
Definition: StunMessage.cpp:1471
void getMagicId(STUN_MAGIC_ID *pMagicId)
Definition: StunMessage.cpp:629
bool getPassword(char *szPassword)
Definition: StunMessage.cpp:736
void setMappedAddress(const char *szIp, const uint16_t port)
Definition: StunMessage.cpp:465
#define STUN_MAX_STRING_LENGTH
Definition: StunMessage.h:23
void setChangedAddress(const char *szIp, const uint16_t port)
Definition: StunMessage.cpp:520
void setIncludeMessageIntegrity(bool bInclude)
Definition: StunMessage.cpp:609