X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2F80221Bundle%2FTLVPacket.cc;h=e37c1a0c61e51014657b2e7edf41a39541946e2c;hb=29a39b247b75454ad25f3f9dc7a524debf8e805c;hp=1e0e997cd70c56d659147dcca1c29c1b0a93b8e3;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/Packets/80221Bundle/TLVPacket.cc b/senf/Packets/80221Bundle/TLVPacket.cc index 1e0e997..e37c1a0 100644 --- a/senf/Packets/80221Bundle/TLVPacket.cc +++ b/senf/Packets/80221Bundle/TLVPacket.cc @@ -28,18 +28,18 @@ // Custom includes #include -#include "../../Utils/hexdump.hh" +#include #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 @@ -48,7 +48,7 @@ prefix_ senf::safe_data_iterator senf::BaseTLVPacketParser::resizeValueField( } -prefix_ senf::DynamicTLVLengthParser::value_type senf::DynamicTLVLengthParser::value() const +prefix_ senf::MIHTLVLengthParser::value_type senf::MIHTLVLengthParser::value() const { switch (bytes() ) { case 1: @@ -62,41 +62,41 @@ prefix_ senf::DynamicTLVLengthParser::value_type senf::DynamicTLVLengthParser::v case 5: return parse( 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(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(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(1) = v - (v>128 ? 128 : 0); break; case 5: parse(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() ) { @@ -111,26 +111,26 @@ prefix_ senf::DynamicTLVLengthParser::value_type senf::DynamicTLVLengthParser::m 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(); @@ -146,7 +146,7 @@ prefix_ void senf::DynamicTLVLengthParser::finalize() if (b != 3) resize(3); return; } - if (v <= UInt24Parser::max_value + 128 ){ + if (v <= UInt24Parser::max_value + 128 ) { if (b != 4) resize(4); return; } @@ -154,7 +154,7 @@ prefix_ void senf::DynamicTLVLengthParser::finalize() } -prefix_ void senf::DynamicTLVLengthParser:: maxValue(DynamicTLVLengthParser::value_type v) +prefix_ void senf::MIHTLVLengthParser:: maxValue(MIHTLVLengthParser::value_type v) { if (v <= 128) return; @@ -175,11 +175,11 @@ prefix_ void senf::DynamicTLVLengthParser:: maxValue(DynamicTLVLengthParser::val } -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 safeThis (*this); + SafePacketParserWrapper safeThis (*this); if (current_size > size) data().erase( i(), boost::next(i(), current_size-size)); @@ -196,33 +196,27 @@ prefix_ void senf::DynamicTLVLengthParser::resize(size_type 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_