switch (bytes() ) {
case 1:
if (v > 128) throw( TLVLengthException());
- fixed_length_field() = v;
+ length_field() = v;
return;
case 2:
if (v > UInt8Parser::max_value + 128) throw( TLVLengthException());
default:
throw( TLVLengthException());
};
- underflow_flag() = v < 128;
+ underflow_flag() = (v <= 128);
+}
+
+
+prefix_ senf::DynamicTLVLengthParser::value_type senf::DynamicTLVLengthParser::maxValue()
+ const
+{
+ switch (bytes() ) {
+ case 1:
+ return 128;
+ case 2:
+ return UInt8Parser::max_value + 128;
+ case 3:
+ return UInt16Parser::max_value + 128;
+ case 4:
+ return UInt24Parser::max_value + 128;
+ case 5:
+ return UInt32Parser::max_value;
+ default:
+ throw( TLVLengthException());
+ };
}
}
-prefix_ void senf::DynamicTLVLengthParser::shrink()
+prefix_ void senf::DynamicTLVLengthParser::finalize()
{
value_type v = value();
size_type b = bytes();
boost::io::ios_all_saver ias(os);
os << "GenericTLVPacket:\n"
<< std::dec
- << " type: " << unsigned( p->type()) << "\n"
- << " length: " << unsigned( p->length()) << "\n"
- << " value\n:";
+ << " type : " << unsigned( p->type()) << "\n"
+ << " length : " << unsigned( p->length()) << "\n"
+ << " value\n : ";
senf::hexdump( p->value().begin(), p->value().end(), os);
}
prefix_ void senf::GenericTLVPacketType::finalize(packet p)
{
- p->shrinkLength();
+ p->finalizeLength();
}