#include <TurnMsgLib.h>
Public Member Functions | |
StunAttr () | |
StunAttr (const StunAttrIterator &iter) throw (WrongStunAttrFormatException, EndOfStunMsgException) | |
virtual | ~StunAttr () |
const u08bits * | getRawValue (size_t &sz) const |
void | setRawValue (u08bits *value, size_t sz) throw (WrongStunAttrFormatException) |
u16bits | getType () const |
void | setType (u16bits at) |
template<class T > | |
int | addToMsg (T &msg) throw (WrongStunAttrFormatException, WrongStunBufferFormatException) |
Protected Member Functions | |
virtual int | addToBuffer (u08bits *buffer, size_t &sz) throw (WrongStunAttrFormatException, WrongStunBufferFormatException) |
Static Protected Member Functions | |
static stun_attr_ref | getSar (const StunAttrIterator &iter) |
Generic root class of all STUN attributes
Definition at line 136 of file TurnMsgLib.h.
StunAttr::StunAttr | ( | ) | [inline] |
Definition at line 138 of file TurnMsgLib.h.
: _attr_type(0), _value(0), _sz(0) {}
StunAttr::StunAttr | ( | const StunAttrIterator & | iter | ) | throw (WrongStunAttrFormatException, EndOfStunMsgException) [inline] |
Definition at line 139 of file TurnMsgLib.h.
{ if(iter.eof()) { throw EndOfStunMsgException(); } size_t sz = 0; const u08bits *ptr = iter.getRawBuffer(sz); if(sz>=0xFFFF) throw WrongStunAttrFormatException(); int at = iter.getType(); if(at<0) throw WrongStunAttrFormatException(); _attr_type = (u16bits)at; _sz = sz; _value=(u08bits*)turn_malloc(_sz); ns_bcopy(ptr,_value,_sz); }
virtual StunAttr::~StunAttr | ( | ) | [inline, virtual] |
Definition at line 155 of file TurnMsgLib.h.
{
if(_value)
turn_free(_value,_sz);
}
virtual int StunAttr::addToBuffer | ( | u08bits * | buffer, |
size_t & | sz | ||
) | throw (WrongStunAttrFormatException, WrongStunBufferFormatException) [inline, protected, virtual] |
Reimplemented in StunAttrPadding, StunAttrResponsePort, StunAttrChangeRequest, StunAttrAddr, StunAttrReservationToken, StunAttrEvenPort, and StunAttrChannelNumber.
Definition at line 197 of file TurnMsgLib.h.
{ if(buffer) { if(!_value) throw WrongStunAttrFormatException(); if(stun_attr_add_str(buffer, &sz, _attr_type, _value, _sz)<0) { throw WrongStunBufferFormatException(); } return 0; } throw WrongStunBufferFormatException(); }
int StunAttr::addToMsg | ( | T & | msg | ) | throw (WrongStunAttrFormatException, WrongStunBufferFormatException) [inline] |
Definition at line 182 of file TurnMsgLib.h.
{ if(!_attr_type) throw WrongStunAttrFormatException(); u08bits *buffer = msg.getRawBuffer(); if(buffer) { size_t sz = msg.getSize(); if(addToBuffer(buffer, sz)<0) { throw WrongStunBufferFormatException(); } msg.setSize(sz); return 0; } throw WrongStunBufferFormatException(); }
const u08bits* StunAttr::getRawValue | ( | size_t & | sz | ) | const [inline] |
Definition at line 159 of file TurnMsgLib.h.
{
sz=_sz;
return _value;
}
static stun_attr_ref StunAttr::getSar | ( | const StunAttrIterator & | iter | ) | [inline, static, protected] |
Definition at line 208 of file TurnMsgLib.h.
{
return iter._sar;
}
u16bits StunAttr::getType | ( | ) | const [inline] |
Definition at line 173 of file TurnMsgLib.h.
{
return _attr_type;
}
void StunAttr::setRawValue | ( | u08bits * | value, |
size_t | sz | ||
) | throw (WrongStunAttrFormatException) [inline] |
Definition at line 163 of file TurnMsgLib.h.
{ if(sz>0xFFFF) throw WrongStunAttrFormatException(); if(_value) turn_free(_value,_sz); _sz = sz; _value=(u08bits*)turn_malloc(_sz); ns_bcopy(value,_value,_sz); }
void StunAttr::setType | ( | u16bits | at | ) | [inline] |
Definition at line 177 of file TurnMsgLib.h.
{ _attr_type = at; }