X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2F80221Bundle%2FTLVParser.cc;h=373478bbaceb0ab4f87b3a820efed1354b4d9acb;hb=92d091c2e5b387ca0c9930c7bc88d9b45630a845;hp=5f35f25a2bcbf056fdc7a0b9b5c915ce026050ee;hpb=be253d22a60afc49fa9265fcff4728742e9f9a2d;p=senf.git diff --git a/senf/Packets/80221Bundle/TLVParser.cc b/senf/Packets/80221Bundle/TLVParser.cc index 5f35f25..373478b 100644 --- a/senf/Packets/80221Bundle/TLVParser.cc +++ b/senf/Packets/80221Bundle/TLVParser.cc @@ -42,13 +42,19 @@ SENF_PACKET_TLV_REGISTRY_REGISTER( senf::MIHValidTimeIntervalTLVParser ); //-///////////////////////////////////////////////////////////////////////////////////////////////// // MIHBaseTLVParser -prefix_ void senf::MIHBaseTLVParser::validateTL(boost::uint8_t expectedType, MIHTLVLengthParser::value_type expectedLength) +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()); if (type() != expectedType) - throw InvalidMIHPacketException("invalid TLV type") << " Type: " << senf::str(type()); + throw InvalidMIHPacketException("invalid TLV type: ") << senf::str(type()); +} + +prefix_ void senf::MIHBaseTLVParser::validateTypeLength(boost::uint8_t expectedType, MIHTLVLengthParser::value_type expectedLength) + const +{ + validateType( expectedLength); if (length() != expectedLength) throw InvalidMIHPacketException("invalid length in TLV.") << " Type: " << senf::str(type()); } @@ -63,7 +69,6 @@ prefix_ void senf::MIHBaseListTLVParser::maxListSize(MIHTLVLengthParser::value_t maxLength( maxl + senf::bytes(listSize_())); } - //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::MIHFIdTLVParser @@ -247,7 +252,7 @@ prefix_ void senf::MIHStatusTLVParser::dump(std::ostream & os) prefix_ void senf::MIHStatusTLVParser::validate() const { - validateTL( typeId, 1); + validateTypeLength( typeId, 1); if (value() >= 4) throw InvalidMIHPacketException("invalid value in MIHStatusTLV ") << senf::str(value()); } @@ -278,7 +283,7 @@ prefix_ void senf::MIHRegisterReqCodeTLVParser::dump(std::ostream & os) prefix_ void senf::MIHRegisterReqCodeTLVParser::validate() const { - validateTL( typeId, 1); + validateTypeLength( typeId, 1); if (value() >= 2) throw InvalidMIHPacketException("invalid value in MIHRegisterReqCodeTLV ") << senf::str(value()); } @@ -301,7 +306,7 @@ prefix_ void senf::MIHValidTimeIntervalTLVParser::dump(std::ostream & os) prefix_ void senf::MIHValidTimeIntervalTLVParser::validate() const { - validateTL( typeId, 4); + validateTypeLength( typeId, 4); } //-/////////////////////////////////////////////////////////////////////////////////////////////////