senf::MIHBaseTLVParser Class Reference

Base class for MIH TLV parsers. More...

#include <senf/Packets/80221Bundle/TLVParser.hh>

Inheritance diagram for senf::MIHBaseTLVParser:
Inheritance graph
[legend]

List of all members.


Detailed Description

Base class for MIH TLV parsers.

MIHBaseTLVParser is the abstract base class for MIH TLV parsers. It defines the type() field as an senf::UInt8Parser and the length() field as a MIHTLVLengthParser. The length field is read-only.

To create your own TLVParser you have to inherit from MIHBaseTLVParser (don't forget SENF_PARSER_INHERIT) and define the value field. In the following example the value is a vector of MacAddresses:

struct MacAddressesTLVParser : public MIHBaseTLVParser {
#   include SENF_PARSER()
    SENF_PARSER_INHERIT ( MIHBaseTLVParser );
    SENF_PARSER_VECTOR  ( value, bytes(length), senf::MACAddressParser );
    SENF_PARSER_FINALIZE( MacAddressesTLVParser );
};

You have to adjust the maximum length value with the maxLength function before the length value is set. The default maximum value is 128. So, in the above example adding more than 21 MACAddresses to the vector will throw a TLVLengthException if you don't call maxLength( some_value) before.

See also:
MIHTLVLengthParser
MIHGenericTLVParser

Definition at line 99 of file TLVParser.hh.


Public Types

typedef UInt8Parser  type_t
typedef MIHTLVLengthParser  length_t
typedef
GenericTLVParserRegistry
< MIHBaseTLVParser
Registry

Public Member Functions

UInt8Parser  type () const
MIHTLVLengthParser::value_type  length () const
void  finalize ()
  shrink size of the TLV length field to minimum

Protected Member Functions

MIHTLVLengthParser  length_ () const
void  maxLength (MIHTLVLengthParser::value_type maxl) const
  set maximum value of TLV length field
void  validateType (boost::uint8_t type) const
void  validateTypeLength (boost::uint8_t type, MIHTLVLengthParser::value_type length) const

Member Typedef Documentation

typedef MIHTLVLengthParser senf::MIHBaseTLVParser::
length_t

Definition at line 104 of file TLVParser.hh.

typedef GenericTLVParserRegistry<MIHBaseTLVParser> senf::MIHBaseTLVParser::
Registry

Definition at line 114 of file TLVParser.hh.

typedef UInt8Parser senf::MIHBaseTLVParser::
type_t

Definition at line 103 of file TLVParser.hh.


Member Function Documentation

void senf::MIHBaseTLVParser::
finalize ()

shrink size of the TLV length field to minimum

The size of the length field will be decreased to minimum necessary to hold the current length value.

Reimplemented in senf::MIHFIdTLVParser.

Definition at line 153 of file TLVParser.cci.

MIHTLVLengthParser ::value_type senf::MIHBaseTLVParser::
length ()

MIHTLVLengthParser senf::MIHBaseTLVParser::
length_ ()

void senf::MIHBaseTLVParser::
maxLength ( MIHTLVLengthParser::value_type  maxl )

set maximum value of TLV length field

The size of the length field will be increased if necessary.

Parameters:
v  maximum value of length field

Definition at line 147 of file TLVParser.cci.

UInt8Parser senf::MIHBaseTLVParser::
type ()

void senf::MIHBaseTLVParser::
validateType ( boost::uint8_t  type )

Definition at line 45 of file TLVParser.cc.

void senf::MIHBaseTLVParser::
validateTypeLength ( boost::uint8_t  type,
MIHTLVLengthParser::value_type  length )

Definition at line 54 of file TLVParser.cc.


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