#include <TurnMsgLib.h>
Public Member Functions | |
StunMsg () | |
StunMsg (u08bits *buffer, size_t total_sz, size_t sz, bool constructed) | |
virtual | ~StunMsg () |
void | construct () |
bool | isValid () |
u08bits * | getRawBuffer () |
size_t | getSize () const |
void | setSize (size_t sz) throw (WrongStunBufferFormatException) |
int | addAttr (StunAttr &attr) throw (WrongStunAttrFormatException, WrongStunBufferFormatException) |
Static Public Member Functions | |
static bool | isCommand (u08bits *buffer, size_t sz) |
static bool | isIndication (u08bits *buffer, size_t sz) |
static bool | isRequest (u08bits *buffer, size_t sz) |
static bool | isSuccessResponse (u08bits *buffer, size_t sz) |
static bool | isErrorResponse (u08bits *buffer, size_t sz, int &err_code, u08bits *err_msg, size_t err_msg_size) |
static bool | isChallengeResponse (const u08bits *buf, size_t sz, int &err_code, u08bits *err_msg, size_t err_msg_size, u08bits *realm, u08bits *nonce) |
static bool | isChannel (u08bits *buffer, size_t sz) |
static bool | isFingerprintPresent (u08bits *buffer, size_t sz) |
static bool | checkFingerprint (u08bits *buffer, size_t sz) |
Protected Member Functions | |
virtual void | constructBuffer ()=0 |
virtual bool | check ()=0 |
Protected Attributes | |
u08bits * | _buffer |
bool | _deallocate |
size_t | _allocated_sz |
size_t | _sz |
bool | _constructed |
Generic "STUN Message" class, base class for all messages
Definition at line 458 of file TurnMsgLib.h.
StunMsg::StunMsg | ( | ) | [inline] |
Definition at line 460 of file TurnMsgLib.h.
{ _allocated_sz = 0xFFFF; _buffer = (u08bits*)turn_malloc(_allocated_sz); _deallocate = true; _sz = 0; _constructed = 0; }
StunMsg::StunMsg | ( | u08bits * | buffer, |
size_t | total_sz, | ||
size_t | sz, | ||
bool | constructed | ||
) | [inline] |
Definition at line 468 of file TurnMsgLib.h.
: _buffer(buffer), _deallocate(false), _allocated_sz(total_sz), _sz(sz), _constructed(constructed) {}
virtual StunMsg::~StunMsg | ( | ) | [inline, virtual] |
Definition at line 472 of file TurnMsgLib.h.
{ if(_deallocate && _buffer) { turn_free(_buffer, _allocated_sz); } }
int StunMsg::addAttr | ( | StunAttr & | attr | ) | throw (WrongStunAttrFormatException, WrongStunBufferFormatException) [inline] |
Definition at line 543 of file TurnMsgLib.h.
{ return attr.addToMsg(*this); }
virtual bool StunMsg::check | ( | ) | [protected, pure virtual] |
Implemented in StunMsgChannel, StunMsgIndication, StunMsgResponse, and StunMsgRequest.
static bool StunMsg::checkFingerprint | ( | u08bits * | buffer, |
size_t | sz | ||
) | [inline, static] |
Definition at line 539 of file TurnMsgLib.h.
{ return stun_is_command_message_full_check_str(buffer, sz, 1); }
void StunMsg::construct | ( | ) | [inline] |
Definition at line 477 of file TurnMsgLib.h.
{ constructBuffer(); }
virtual void StunMsg::constructBuffer | ( | ) | [protected, pure virtual] |
Implemented in StunMsgChannel, StunMsgIndication, StunMsgResponse, and StunMsgRequest.
u08bits* StunMsg::getRawBuffer | ( | ) | [inline] |
Definition at line 484 of file TurnMsgLib.h.
{ return _buffer; }
size_t StunMsg::getSize | ( | ) | const [inline] |
Definition at line 488 of file TurnMsgLib.h.
{ return _sz; }
static bool StunMsg::isChallengeResponse | ( | const u08bits * | buf, |
size_t | sz, | ||
int & | err_code, | ||
u08bits * | err_msg, | ||
size_t | err_msg_size, | ||
u08bits * | realm, | ||
u08bits * | nonce | ||
) | [inline, static] |
Definition at line 519 of file TurnMsgLib.h.
{ return stun_is_challenge_response_str(buf, sz, &err_code, err_msg, err_msg_size, realm, nonce); }
static bool StunMsg::isChannel | ( | u08bits * | buffer, |
size_t | sz | ||
) | [inline, static] |
Definition at line 525 of file TurnMsgLib.h.
{ return is_channel_msg_str(buffer, sz); }
static bool StunMsg::isCommand | ( | u08bits * | buffer, |
size_t | sz | ||
) | [inline, static] |
Definition at line 498 of file TurnMsgLib.h.
{ return stun_is_command_message_str(buffer, sz); }
static bool StunMsg::isErrorResponse | ( | u08bits * | buffer, |
size_t | sz, | ||
int & | err_code, | ||
u08bits * | err_msg, | ||
size_t | err_msg_size | ||
) | [inline, static] |
Definition at line 514 of file TurnMsgLib.h.
{ return stun_is_error_response_str(buffer, sz, &err_code, err_msg, err_msg_size); }
static bool StunMsg::isFingerprintPresent | ( | u08bits * | buffer, |
size_t | sz | ||
) | [inline, static] |
Definition at line 529 of file TurnMsgLib.h.
{ if(!stun_is_command_message_str(buffer,sz)) return false; stun_attr_ref sar = stun_attr_get_first_by_type_str(buffer, sz, STUN_ATTRIBUTE_FINGERPRINT); if(!sar) return false; return true; }
static bool StunMsg::isIndication | ( | u08bits * | buffer, |
size_t | sz | ||
) | [inline, static] |
Definition at line 502 of file TurnMsgLib.h.
{ return stun_is_indication_str(buffer, sz); }
static bool StunMsg::isRequest | ( | u08bits * | buffer, |
size_t | sz | ||
) | [inline, static] |
Definition at line 506 of file TurnMsgLib.h.
{ return stun_is_request_str(buffer, sz); }
static bool StunMsg::isSuccessResponse | ( | u08bits * | buffer, |
size_t | sz | ||
) | [inline, static] |
Definition at line 510 of file TurnMsgLib.h.
{ return stun_is_success_response_str(buffer, sz); }
bool StunMsg::isValid | ( | ) | [inline] |
Definition at line 480 of file TurnMsgLib.h.
{ return check(); }
void StunMsg::setSize | ( | size_t | sz | ) | throw (WrongStunBufferFormatException) [inline] |
Definition at line 492 of file TurnMsgLib.h.
{ if(sz>_allocated_sz) throw WrongStunBufferFormatException(); _sz = sz; }
size_t StunMsg::_allocated_sz [protected] |
Definition at line 553 of file TurnMsgLib.h.
u08bits* StunMsg::_buffer [protected] |
Definition at line 551 of file TurnMsgLib.h.
bool StunMsg::_constructed [protected] |
Definition at line 555 of file TurnMsgLib.h.
bool StunMsg::_deallocate [protected] |
Definition at line 552 of file TurnMsgLib.h.
size_t StunMsg::_sz [protected] |
Definition at line 554 of file TurnMsgLib.h.