X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2F80221Bundle%2FTLVParser.cc;h=729b1ece583706b2247f715f54a849d628afe42b;hb=57daeae6f2e924ce3f16f9677c3474f531cba9e5;hp=373478bbaceb0ab4f87b3a820efed1354b4d9acb;hpb=92d091c2e5b387ca0c9930c7bc88d9b45630a845;p=senf.git diff --git a/senf/Packets/80221Bundle/TLVParser.cc b/senf/Packets/80221Bundle/TLVParser.cc index 373478b..729b1ec 100644 --- a/senf/Packets/80221Bundle/TLVParser.cc +++ b/senf/Packets/80221Bundle/TLVParser.cc @@ -29,7 +29,6 @@ // Custom includes #include #include -#include #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// @@ -46,17 +45,17 @@ prefix_ void senf::MIHBaseTLVParser::validateType(boost::uint8_t expectedType) const { if (! check( 1 + senf::bytes(length_()) + length()) ) - throw InvalidMIHPacketException("truncated TLV.") << " Type: " << senf::str(type()); + throw InvalidMIHPacketException("truncated TLV.") << " Type: " << unsigned(type()); if (type() != expectedType) - throw InvalidMIHPacketException("invalid TLV type: ") << senf::str(type()); + throw InvalidMIHPacketException("wrong TLV type. expected ") << unsigned(expectedType) << " got " << unsigned(type()); } prefix_ void senf::MIHBaseTLVParser::validateTypeLength(boost::uint8_t expectedType, MIHTLVLengthParser::value_type expectedLength) const { - validateType( expectedLength); + validateType( expectedType); if (length() != expectedLength) - throw InvalidMIHPacketException("invalid length in TLV.") << " Type: " << senf::str(type()); + throw InvalidMIHPacketException("invalid length in TLV.") << " Type: " << unsigned(type()); } //-///////////////////////////////////////////////////////////////////////////////////////////////// @@ -190,10 +189,7 @@ prefix_ void senf::MIHFSrcIdTLVParser::dump(std::ostream & os) prefix_ void senf::MIHFSrcIdTLVParser::validate() const { - if (! check( 1 + senf::bytes(length_()) + length()) ) - throw InvalidMIHPacketException("truncated TLV.") << " Type: " << senf::str(type()); - if (type() != typeId) - throw InvalidMIHPacketException("invalid TLV type: ") << senf::str(type()); + validateType( typeId); } @@ -211,10 +207,7 @@ prefix_ void senf::MIHFDstIdTLVParser::dump(std::ostream & os) prefix_ void senf::MIHFDstIdTLVParser::validate() const { - if (! check( 1 + senf::bytes(length_()) + length()) ) - throw InvalidMIHPacketException("truncated TLV.") << " Type: " << senf::str(type()); - if (type() != typeId) - throw InvalidMIHPacketException("invalid TLV type: ") << senf::str(type()); + validateType( typeId); } //-///////////////////////////////////////////////////////////////////////////////////////////////// @@ -254,7 +247,7 @@ prefix_ void senf::MIHStatusTLVParser::validate() { validateTypeLength( typeId, 1); if (value() >= 4) - throw InvalidMIHPacketException("invalid value in MIHStatusTLV ") << senf::str(value()); + throw InvalidMIHPacketException("invalid value in MIHStatusTLV ") << unsigned( value()); } //-///////////////////////////////////////////////////////////////////////////////////////////////// @@ -285,7 +278,7 @@ prefix_ void senf::MIHRegisterReqCodeTLVParser::validate() { validateTypeLength( typeId, 1); if (value() >= 2) - throw InvalidMIHPacketException("invalid value in MIHRegisterReqCodeTLV ") << senf::str(value()); + throw InvalidMIHPacketException("invalid value in MIHRegisterReqCodeTLV ") << unsigned( value()); } //-/////////////////////////////////////////////////////////////////////////////////////////////////