// Custom includes
#include <iomanip>
-#include "../../Utils/hexdump.hh"
+#include <senf/Utils/hexdump.hh>
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-prefix_ senf::safe_data_iterator senf::BaseTLVPacketParser::resizeValueField(
- DynamicTLVLengthParser::value_type size)
+prefix_ senf::safe_data_iterator senf::MIHBaseTLVParser::resizeValueField(
+ MIHTLVLengthParser::value_type size)
{
- DynamicTLVLengthParser::value_type current_length ( length());
- length( size);
+ MIHTLVLengthParser::value_type current_length ( length());
+ length_() << size;
- safe_data_iterator si (data(), boost::next(i(), 1 + length_bytes() ));
+ safe_data_iterator si (data(), boost::next(i(), 1 + length_().bytes() ));
if (current_length > size)
data().erase( si, boost::next(si, current_length-size));
else
}
-prefix_ senf::DynamicTLVLengthParser::value_type senf::DynamicTLVLengthParser::value() const
+prefix_ senf::MIHTLVLengthParser::value_type senf::MIHTLVLengthParser::value() const
{
switch (bytes() ) {
case 1:
case 5:
return parse<UInt32Parser>( 1 ).value() + (underflow_flag() ? 0 : 128u);
default:
- throw(TLVLengthException());
+ throw( MIHTLVLengthException());
};
}
-prefix_ void senf::DynamicTLVLengthParser::value(value_type const & v)
+prefix_ void senf::MIHTLVLengthParser::value(value_type const & v)
{
switch (bytes() ) {
case 1:
- if (v > 128) throw( TLVLengthException());
+ if (v > 128) throw( MIHTLVLengthException());
length_field() = v;
return;
case 2:
- if (v > UInt8Parser::max_value + 128) throw( TLVLengthException());
+ if (v > UInt8Parser::max_value + 128) throw( MIHTLVLengthException());
parse<UInt8Parser>(1) = v - (v>128 ? 128 : 0);
break;
case 3:
- if (v > UInt16Parser::max_value + 128) throw( TLVLengthException());
+ if (v > UInt16Parser::max_value + 128) throw( MIHTLVLengthException());
parse<UInt16Parser>(1) = v - (v>128 ? 128 : 0);
break;;
case 4:
- if (v > UInt24Parser::max_value + 128) throw( TLVLengthException());
+ if (v > UInt24Parser::max_value + 128) throw( MIHTLVLengthException());
parse<UInt24Parser>(1) = v - (v>128 ? 128 : 0);
break;
case 5:
parse<UInt32Parser>(1) = v - (v>128 ? 128 : 0);
break;
default:
- throw( TLVLengthException());
+ throw( MIHTLVLengthException());
};
underflow_flag() = (v <= 128);
}
-prefix_ senf::DynamicTLVLengthParser::value_type senf::DynamicTLVLengthParser::maxValue()
+prefix_ senf::MIHTLVLengthParser::value_type senf::MIHTLVLengthParser::maxValue()
const
{
switch (bytes() ) {
case 5:
return UInt32Parser::max_value;
default:
- throw( TLVLengthException());
+ throw( MIHTLVLengthException());
};
}
-prefix_ senf::DynamicTLVLengthParser const & senf::DynamicTLVLengthParser::operator= (value_type other)
+prefix_ senf::MIHTLVLengthParser const & senf::MIHTLVLengthParser::operator= (value_type other)
{
value(other);
return *this;
}
-prefix_ void senf::DynamicTLVLengthParser::init() const
+prefix_ void senf::MIHTLVLengthParser::init() const
{
defaultInit();
extended_length_flag() = false;
}
-prefix_ void senf::DynamicTLVLengthParser::finalize()
+prefix_ void senf::MIHTLVLengthParser::finalize()
{
value_type v = value();
size_type b = bytes();
if (b != 3) resize(3);
return;
}
- if (v <= UInt24Parser::max_value + 128 ){
+ if (v <= UInt24Parser::max_value + 128 ) {
if (b != 4) resize(4);
return;
}
}
-prefix_ void senf::DynamicTLVLengthParser:: maxValue(DynamicTLVLengthParser::value_type v)
+prefix_ void senf::MIHTLVLengthParser:: maxValue(MIHTLVLengthParser::value_type v)
{
if (v <= 128)
return;
}
-prefix_ void senf::DynamicTLVLengthParser::resize(size_type size)
+prefix_ void senf::MIHTLVLengthParser::resize(size_type size)
{
value_type v = value();
size_type current_size (bytes());
- SafePacketParserWrapper<DynamicTLVLengthParser> safeThis (*this);
+ SafePacketParserWrapper<MIHTLVLengthParser> safeThis (*this);
if (current_size > size)
data().erase( i(), boost::next(i(), current_size-size));
}
-prefix_ senf::PacketInterpreterBase::range senf::GenericTLVPacketParser::value()
- const
-{
- senf::PacketData::iterator begin (boost::next(data().begin(), 1 + length_bytes() ));
- return PacketInterpreterBase::range(
- begin, boost::next( begin, length()) );
-}
+//prefix_ senf::PacketInterpreterBase::range senf::MIHGenericTLVPacketParser::value()
+// const
+//{
+// senf::PacketData::iterator begin (boost::next(data().begin(), 1 + length_().bytes() ));
+// return PacketInterpreterBase::range(
+// begin, boost::next( begin, length()) );
+//}
-prefix_ void senf::GenericTLVPacketType::dump(packet p, std::ostream & os)
+prefix_ void senf::MIHGenericTLVPacketType::dump(packet p, std::ostream & os)
{
boost::io::ios_all_saver ias(os);
- os << "GenericTLVPacket:\n"
+ os << "MIH GenericTLV Packet:\n"
<< std::dec
- << " type : " << unsigned( p->type()) << "\n"
- << " length : " << unsigned( p->length()) << "\n"
- << " value\n : ";
+ << senf::fieldName("type") << unsigned( p->type()) << "\n"
+ << senf::fieldName("length") << unsigned( p->length()) << "\n"
+ << " value:\n";
senf::hexdump( p->value().begin(), p->value().end(), os);
}
-prefix_ void senf::GenericTLVPacketType::finalize(packet p)
-{
- p->finalizeLength();
-}
-
-
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_