TURN Server  1.5
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines
Public Member Functions | Friends
turn::StunAttrIterator Class Reference

#include <TurnMsgLib.h>

List of all members.

Public Member Functions

 StunAttrIterator (u08bits *buf, size_t sz) throw (WrongStunBufferFormatException)
template<class T >
 StunAttrIterator (T &msg) throw (WrongStunBufferFormatException)
 StunAttrIterator (u08bits *buf, size_t sz, u16bits attr_type) throw (WrongStunBufferFormatException)
template<class T >
 StunAttrIterator (T &msg, u16bits attr_type) throw (WrongStunBufferFormatException)
void next () throw (EndOfStunMsgException)
bool eof () const
bool isAddr () const
int getAddressFamily () const
int getType () const
virtual ~StunAttrIterator ()
const u08bits * getRawBuffer (size_t &sz) const throw (WrongStunAttrFormatException)

Friends

class StunAttr

Detailed Description

Iterator class for attributes

Definition at line 73 of file TurnMsgLib.h.


Constructor & Destructor Documentation

turn::StunAttrIterator::StunAttrIterator ( u08bits *  buf,
size_t  sz 
) throw (WrongStunBufferFormatException) [inline]

Iterator constructor: creates iterator on raw messagebuffer.

Definition at line 78 of file TurnMsgLib.h.

                                                                                         :
                _buf(buf), _sz(sz)  {
                if(!stun_is_command_message_str(_buf, _sz)) {
                        throw WrongStunBufferFormatException();
                }
                _sar = stun_attr_get_first_str(_buf, _sz);
        }
template<class T >
turn::StunAttrIterator::StunAttrIterator ( T &  msg) throw (WrongStunBufferFormatException) [inline]

Iterator constructor: create iterator over message.

Definition at line 90 of file TurnMsgLib.h.

                                                                        :
                _buf(msg.getRawBuffer()), _sz(msg.getSize())  {
                if(!stun_is_command_message_str(_buf, _sz)) {
                        throw WrongStunBufferFormatException();
                }
                _sar = stun_attr_get_first_str(_buf, _sz);
        }
turn::StunAttrIterator::StunAttrIterator ( u08bits *  buf,
size_t  sz,
u16bits  attr_type 
) throw (WrongStunBufferFormatException) [inline]

Iterator constructor: creates iterator over raw buffer, starting from first location of an attribute of particular type.

Definition at line 102 of file TurnMsgLib.h.

                                                                                                            :
                        _buf(buf), _sz(sz)  {
                if(!stun_is_command_message_str(_buf, _sz)) {
                        throw WrongStunBufferFormatException();
                }
                _sar = stun_attr_get_first_by_type_str(_buf, _sz, attr_type);
        }
template<class T >
turn::StunAttrIterator::StunAttrIterator ( T &  msg,
u16bits  attr_type 
) throw (WrongStunBufferFormatException) [inline]

Iterator constructor: creates iterator over message, starting from first location of an attribute of particular type.

Definition at line 115 of file TurnMsgLib.h.

                                                                                           :
                        _buf(msg.getRawBuffer()), _sz(msg.getSize())  {
                if(!stun_is_command_message_str(_buf, _sz)) {
                        throw WrongStunBufferFormatException();
                }
                _sar = stun_attr_get_first_by_type_str(_buf, _sz, attr_type);
        }
virtual turn::StunAttrIterator::~StunAttrIterator ( ) [inline, virtual]

Destructor

Definition at line 164 of file TurnMsgLib.h.

{}

Member Function Documentation

bool turn::StunAttrIterator::eof ( ) const [inline]

Is the iterator finished

Definition at line 136 of file TurnMsgLib.h.

                         {
                return (!_sar);
        }

Return address family attribute value (if the iterator at the "address family" attribute.

Definition at line 150 of file TurnMsgLib.h.

const u08bits* turn::StunAttrIterator::getRawBuffer ( size_t &  sz) const throw (WrongStunAttrFormatException) [inline]

Return raw memroy field of the attribute value. If the attribute value length is zero (0), then return NULL.

Definition at line 170 of file TurnMsgLib.h.

                                                                                          {
                int len = stun_attr_get_len(_sar);
                if(len<0)
                        throw WrongStunAttrFormatException();
                sz = (size_t)len;
                const u08bits *value = stun_attr_get_value(_sar);
                return value;
        }
int turn::StunAttrIterator::getType ( ) const [inline]

Get attribute type

Definition at line 157 of file TurnMsgLib.h.

                            {
                return stun_attr_get_type(_sar);
        }
bool turn::StunAttrIterator::isAddr ( ) const [inline]

Is the iterator at an address attribute

Definition at line 143 of file TurnMsgLib.h.

                            {
                return stun_attr_is_addr(_sar);
        }

Moves iterator to next attribute location

Definition at line 126 of file TurnMsgLib.h.

                                                 {
                if(!_sar) {
                        throw EndOfStunMsgException();
                }
                _sar = stun_attr_get_next_str(_buf,_sz,_sar);
        }

Friends And Related Function Documentation

friend class StunAttr [friend]

Definition at line 178 of file TurnMsgLib.h.


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