189 :
type((WORD)newType)
235 memcpy(m_string, (
const char *)str,
length);
243 bool IsValidStringAttr(
Types checkType)
const
245 return (
type == checkType) && (
length == strlen(m_string));
258 memset(flags, 0,
sizeof(flags));
259 SetChangeIP(changeIP);
260 SetChangePort(changePort);
266 void SetChangeIP(
bool on) {
if (on) flags[3] |= 4;
else flags[3] &= ~4; }
282 memset(m_hmac, 0,
sizeof(m_hmac));
284 memcpy(m_hmac, hmac,
sizeof(m_hmac));
317 SetErrorCode(code, reason);
327 void SetErrorCode(
int code,
const PString & reason);
348 BYTE transactionId[16];
365 PNatMethod::Component component
368 virtual const char * GetNatName()
const;
371 virtual void GetCandidateInfo(PNatCandidate & candidate);
389 PNatMethod::NatTypes m_natType;
400 BindingRequest = 0x0001,
401 BindingResponse = 0x0101,
402 BindingError = 0x0111,
404 SharedSecretRequest = 0x0002,
405 SharedSecretResponse = 0x0102,
406 SharedSecretError = 0x0112,
409 AllocateResponse = 0x0103,
410 AllocateError = 0x0113,
415 CreatePermission = 0x0008,
416 ChannelBind = 0x0009,
425 void PrintOn(ostream & strm)
const;
428 bool IsValid()
const;
431 const BYTE * GetTransactionID()
const;
433 bool IsRFC5389()
const;
437 MsgType GetType()
const;
438 void SetType(MsgType newType,
const BYTE *
id = NULL);
439 void SetErrorType(
int code,
const BYTE *
id,
const char * reason = NULL);
446 {
return static_cast<Type *
>(FindAttribute(type)); }
456 void AddMessageIntegrity(
const BYTE * credentialsHashPtr, PINDEX credentialsHashLen,
PSTUNMessageIntegrity * mi = NULL);
459 bool CheckMessageIntegrity(
const BYTE * credentialsHashPtr, PINDEX credentialsHashLen)
const;
462 bool CheckFingerprint(
bool required)
const;
466 void CalculateMessageIntegrity(
const BYTE * credentialsHash, PINDEX credentialsHashLen,
PSTUNMessageIntegrity * mi, BYTE * hmac)
const;
480 enum { DefaultPriority = 40 };
486 static const char * MethodName();
502 virtual PString GetServer()
const;
504 virtual bool GetServerAddress(
508 virtual bool GetInterfaceAddress(
516 virtual bool IsAvailable(
521 virtual void Close();
535 virtual bool CreateSocket(
540 Component component = eComponent_Unknown
556 virtual bool CreateSocketPair(
564 virtual PNATUDPSocket * InternalCreateSocket(Component component,
PObject * context);
565 virtual void InternalUpdate();
572 PINDEX m_numSocketsForPairing;
585 ProtocolUDP = IPPROTO_UDP,
586 ProtocolTCP = IPPROTO_TCP
594 { Initialise(protocol); }
596 void Initialise(BYTE protocol = ProtocolUDP);
607 : m_lifetime(lifetime)
626 bool IsEven()
const {
return (m_bits & 1) != 0; }
649 PNatMethod::Component component
653 virtual const char * GetNatName()
const;
655 virtual bool Close();
657 virtual void GetCandidateInfo(PNatCandidate & candidate);
697 static const char * MethodName();
700 enum { DefaultPriority = 30 };
709 Component component = eComponent_Unknown
712 bool CreateSocketPair(
722 virtual RTPSupportTypes GetRTPSupport(
727 virtual PNATUDPSocket * InternalCreateSocket(Component component,
PObject * context);
729 virtual bool RefreshAllocation(DWORD lifetime = 600);
735 #endif // PTLIB_PSTUN_H