Stun Server  Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
CStunMessageReader Class Reference

#include <stunreader.h>

Collaboration diagram for CStunMessageReader:

Public Types

enum  ReaderParseState { HeaderNotRead, HeaderValidated, BodyValidated, ParseError }
 

Public Member Functions

 CStunMessageReader ()
 
void Reset ()
 
void SetAllowLegacyFormat (bool fAllowLegacyFormat)
 
ReaderParseState AddBytes (const uint8_t *pData, uint32_t size)
 
uint16_t HowManyBytesNeeded ()
 
ReaderParseState GetState ()
 
bool IsMessageLegacyFormat ()
 
bool HasFingerprintAttribute ()
 
bool IsFingerprintAttributeValid ()
 
bool HasMessageIntegrityAttribute ()
 
HRESULT ValidateMessageIntegrityShort (const char *pszPassword)
 
HRESULT ValidateMessageIntegrityLong (const char *pszUser, const char *pszRealm, const char *pszPassword)
 
HRESULT GetAttributeByType (uint16_t attributeType, StunAttribute *pAttribute)
 
HRESULT GetAttributeByIndex (int index, StunAttribute *pAttribute)
 
int GetAttributeCount ()
 
void GetTransactionId (StunTransactionId *pTransId)
 
StunMessageClass GetMessageClass ()
 
uint16_t GetMessageType ()
 
HRESULT GetResponsePort (uint16_t *pPort)
 
HRESULT GetChangeRequest (StunChangeRequestAttribute *pChangeRequest)
 
HRESULT GetPaddingAttributeSize (uint16_t *pSizePadding)
 
HRESULT GetErrorCode (uint16_t *pErrorNumber)
 
HRESULT GetBuffer (CRefCountedBuffer *pRefBuffer)
 
HRESULT GetXorMappedAddress (CSocketAddress *pAddress)
 
HRESULT GetMappedAddress (CSocketAddress *pAddress)
 
HRESULT GetOtherAddress (CSocketAddress *pAddress)
 
HRESULT GetResponseOriginAddress (CSocketAddress *pAddress)
 
HRESULT GetStringAttributeByType (uint16_t attributeType, char *pszValue, size_t size)
 
CDataStreamGetStream ()
 

Private Types

typedef FastHash< uint16_t, StunAttribute, MAX_NUM_ATTRIBUTES, 53 > AttributeHashTable
 

Private Member Functions

HRESULT ReadHeader ()
 
HRESULT ReadBody ()
 
HRESULT GetAddressHelper (uint16_t attribType, CSocketAddress *pAddr)
 
HRESULT ValidateMessageIntegrity (uint8_t *key, size_t keylength)
 

Private Attributes

CDataStream _stream
 
bool _fAllowLegacyFormat
 
bool _fMessageIsLegacyFormat
 
ReaderParseState _state
 
AttributeHashTable _mapAttributes
 
int _indexFingerprint
 
int _indexMessageIntegrity
 
int _countAttributes
 
StunTransactionId _transactionid
 
uint16_t _msgTypeNormalized
 
StunMessageClass _msgClass
 
uint16_t _msgLength
 

Static Private Attributes

static const size_t MAX_NUM_ATTRIBUTES = 30
 

Detailed Description

Definition at line 30 of file stunreader.h.

Member Typedef Documentation

Definition at line 51 of file stunreader.h.

Member Enumeration Documentation

Enumerator
HeaderNotRead 
HeaderValidated 
BodyValidated 
ParseError 

Definition at line 33 of file stunreader.h.

Constructor & Destructor Documentation

CStunMessageReader::CStunMessageReader ( )

Definition at line 42 of file stunreader.cpp.

Member Function Documentation

CStunMessageReader::ReaderParseState CStunMessageReader::AddBytes ( const uint8_t *  pData,
uint32_t  size 
)

Definition at line 750 of file stunreader.cpp.

HRESULT CStunMessageReader::GetAddressHelper ( uint16_t  attribType,
CSocketAddress pAddr 
)
private

Definition at line 489 of file stunreader.cpp.

HRESULT CStunMessageReader::GetAttributeByIndex ( int  index,
StunAttribute pAttribute 
)

Definition at line 346 of file stunreader.cpp.

HRESULT CStunMessageReader::GetAttributeByType ( uint16_t  attributeType,
StunAttribute pAttribute 
)

Definition at line 362 of file stunreader.cpp.

int CStunMessageReader::GetAttributeCount ( )

Definition at line 379 of file stunreader.cpp.

HRESULT CStunMessageReader::GetBuffer ( CRefCountedBuffer pRefBuffer)

Definition at line 844 of file stunreader.cpp.

HRESULT CStunMessageReader::GetChangeRequest ( StunChangeRequestAttribute pChangeRequest)

Definition at line 407 of file stunreader.cpp.

HRESULT CStunMessageReader::GetErrorCode ( uint16_t *  pErrorNumber)

Definition at line 461 of file stunreader.cpp.

HRESULT CStunMessageReader::GetMappedAddress ( CSocketAddress pAddress)

Definition at line 505 of file stunreader.cpp.

StunMessageClass CStunMessageReader::GetMessageClass ( )

Definition at line 834 of file stunreader.cpp.

uint16_t CStunMessageReader::GetMessageType ( )

Definition at line 839 of file stunreader.cpp.

HRESULT CStunMessageReader::GetOtherAddress ( CSocketAddress pAddress)

Definition at line 513 of file stunreader.cpp.

HRESULT CStunMessageReader::GetPaddingAttributeSize ( uint16_t *  pSizePadding)

Definition at line 442 of file stunreader.cpp.

HRESULT CStunMessageReader::GetResponseOriginAddress ( CSocketAddress pAddress)

Definition at line 548 of file stunreader.cpp.

HRESULT CStunMessageReader::GetResponsePort ( uint16_t *  pPort)

Definition at line 384 of file stunreader.cpp.

CStunMessageReader::ReaderParseState CStunMessageReader::GetState ( )

Definition at line 820 of file stunreader.cpp.

CDataStream & CStunMessageReader::GetStream ( )

Definition at line 855 of file stunreader.cpp.

HRESULT CStunMessageReader::GetStringAttributeByType ( uint16_t  attributeType,
char *  pszValue,
size_t  size 
)

Definition at line 565 of file stunreader.cpp.

void CStunMessageReader::GetTransactionId ( StunTransactionId pTransId)

Definition at line 825 of file stunreader.cpp.

HRESULT CStunMessageReader::GetXorMappedAddress ( CSocketAddress pAddress)

Definition at line 529 of file stunreader.cpp.

bool CStunMessageReader::HasFingerprintAttribute ( )

Definition at line 93 of file stunreader.cpp.

bool CStunMessageReader::HasMessageIntegrityAttribute ( )

Definition at line 140 of file stunreader.cpp.

uint16_t CStunMessageReader::HowManyBytesNeeded ( )

Definition at line 76 of file stunreader.cpp.

bool CStunMessageReader::IsFingerprintAttributeValid ( )

Definition at line 99 of file stunreader.cpp.

bool CStunMessageReader::IsMessageLegacyFormat ( )

Definition at line 71 of file stunreader.cpp.

HRESULT CStunMessageReader::ReadBody ( )
private

Definition at line 654 of file stunreader.cpp.

HRESULT CStunMessageReader::ReadHeader ( )
private

Definition at line 586 of file stunreader.cpp.

void CStunMessageReader::Reset ( )

Definition at line 47 of file stunreader.cpp.

void CStunMessageReader::SetAllowLegacyFormat ( bool  fAllowLegacyFormat)

Definition at line 66 of file stunreader.cpp.

HRESULT CStunMessageReader::ValidateMessageIntegrity ( uint8_t *  key,
size_t  keylength 
)
private

Definition at line 145 of file stunreader.cpp.

HRESULT CStunMessageReader::ValidateMessageIntegrityLong ( const char *  pszUser,
const char *  pszRealm,
const char *  pszPassword 
)

Definition at line 282 of file stunreader.cpp.

HRESULT CStunMessageReader::ValidateMessageIntegrityShort ( const char *  pszPassword)

Definition at line 277 of file stunreader.cpp.

Member Data Documentation

int CStunMessageReader::_countAttributes
private

Definition at line 58 of file stunreader.h.

bool CStunMessageReader::_fAllowLegacyFormat
private

Definition at line 44 of file stunreader.h.

bool CStunMessageReader::_fMessageIsLegacyFormat
private

Definition at line 45 of file stunreader.h.

int CStunMessageReader::_indexFingerprint
private

Definition at line 56 of file stunreader.h.

int CStunMessageReader::_indexMessageIntegrity
private

Definition at line 57 of file stunreader.h.

AttributeHashTable CStunMessageReader::_mapAttributes
private

Definition at line 53 of file stunreader.h.

StunMessageClass CStunMessageReader::_msgClass
private

Definition at line 63 of file stunreader.h.

uint16_t CStunMessageReader::_msgLength
private

Definition at line 64 of file stunreader.h.

uint16_t CStunMessageReader::_msgTypeNormalized
private

Definition at line 62 of file stunreader.h.

ReaderParseState CStunMessageReader::_state
private

Definition at line 47 of file stunreader.h.

CDataStream CStunMessageReader::_stream
private

Definition at line 42 of file stunreader.h.

StunTransactionId CStunMessageReader::_transactionid
private

Definition at line 61 of file stunreader.h.

const size_t CStunMessageReader::MAX_NUM_ATTRIBUTES = 30
staticprivate

Definition at line 49 of file stunreader.h.


The documentation for this class was generated from the following files: