Packets/80221Bundle: added MIHFId class
[senf.git] / Packets / 80221Bundle / TLVPacket.cc
index 0b94056..3c28c5b 100644 (file)
@@ -72,7 +72,7 @@ prefix_ void senf::DynamicTLVLengthParser::value(value_type const & v)
     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());
@@ -92,7 +92,27 @@ prefix_ void senf::DynamicTLVLengthParser::value(value_type const & v)
     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());
+    };
 }
 
 
@@ -110,7 +130,7 @@ prefix_ void senf::DynamicTLVLengthParser::init() const
 }
 
 
-prefix_ void senf::DynamicTLVLengthParser::shrink()
+prefix_ void senf::DynamicTLVLengthParser::finalize()
 {
     value_type v = value();
     size_type b = bytes();
@@ -199,7 +219,7 @@ prefix_ void senf::GenericTLVPacketType::dump(packet p, std::ostream & os)
 
 prefix_ void senf::GenericTLVPacketType::finalize(packet p)
 {
-    p->shrinkLength();
+    p->finalizeLength();
 }