From: pug Date: Fri, 25 Sep 2009 09:31:14 +0000 (+0000) Subject: added dump() methods for ICMPv6 PacketTypes X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=6c3e14487152691aeaecf210e324225a1168dff4;p=senf.git added dump() methods for ICMPv6 PacketTypes git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1445 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc b/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc index a995c38..96fe4ad 100644 --- a/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc +++ b/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc @@ -23,45 +23,106 @@ // Definition of non-inline non-template functions // Custom includes -#include #include #include "ICMPv6Packet.hh" #include "ICMPv6TypePacket.hh" #define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// +namespace { +//Implementing the ICMPv6 Type registry + senf::PacketRegistry::RegistrationProxy + registerICMPv6ErrDestUnreachable (1); + senf::PacketRegistry::RegistrationProxy + registerICMPv6ErrTooBig (2); + senf::PacketRegistry::RegistrationProxy + registerICMPv6ErrTimeExceeded (3); + senf::PacketRegistry::RegistrationProxy + registerICMPv6ErrParamProblem (4); + senf::PacketRegistry::RegistrationProxy + registerICMPv6EchoRequest (128); + senf::PacketRegistry::RegistrationProxy + registerICMPv6EchoReply (129); + senf::PacketRegistry::RegistrationProxy + registerMLDv2ListenerQuery (130); + senf::PacketRegistry::RegistrationProxy + registerMLDv2ListenerReport (143); +} -#ifndef DOXYGEN +prefix_ void senf::ICMPv6EchoRequestType::dump(packet p, std::ostream & os){ + os << "ICMPv6 Echo Request:\n" + <<" Identifier : " << unsigned(p->identifier() ) + <<"\n SequenceNumber : " << unsigned(p->seqNr() ) << "\n"; +} -SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 1, senf::ICMPv6ErrDestUnreachable ); -SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 2, senf::ICMPv6ErrTooBig ); -SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 3, senf::ICMPv6ErrTimeExceeded ); -SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 4, senf::ICMPv6ErrParamProblem ); -SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 128, senf::ICMPv6EchoRequest ); -SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 129, senf::ICMPv6EchoReply ); -SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 130, senf::MLDv2ListenerQuery ); -SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 143, senf::MLDv2ListenerReport ); +prefix_ void senf::ICMPv6EchoReplyType::dump(packet p, std::ostream & os){ + os << "ICMPv6 Echo Reply:\n" + <<" Identifier : " << unsigned(p->identifier() ) + <<"\n SequenceNumber : " << unsigned(p->seqNr() ) << "\n"; +} -#endif +prefix_ void senf::ICMPv6ErrDestUnreachableType::dump(packet p, std::ostream & os){ + os << "ICMPv6 Error Destination Unreachable (no further fields available here)\n"; +} -prefix_ void senf::ICMPv6EchoRequestType::dump(packet p, std::ostream & os) -{ - boost::io::ios_all_saver ias(os); - os << "ICMPv6 Echo Request:\n" - << " identifier : " << p->identifier() << "\n" - << " sequence nr. : " << p->seqNr() << "\n"; +prefix_ void senf::ICMPv6ErrTooBigType::dump(packet p, std::ostream & os){ + os << "ICMPv6 Error Packet Too Big:\n" + <<" MTU : " << unsigned(p->mtu() ) << "\n"; +} + +prefix_ void senf::ICMPv6ErrTimeExceededType::dump(packet p, std::ostream & os){ + os << "ICMPv6 Error Time Exceeded:\n" + <<" Unused(32Bit) : " << unsigned(p->unused() ) << "\n"; } -///////////////////////////////cc.e//////////////////////////////////////// -#undef prefix_ +prefix_ void senf::ICMPv6ErrParamProblemType::dump(packet p, std::ostream & os){ + os << "ICMPv6 Error Parameter Problem:\n" + <<" Pointer : " << unsigned(p->pointer() ) << "\n"; +} + +prefix_ void senf::MLDv2ListenerQueryType::dump(packet p, std::ostream & os){ + os << "ICMPv6 Multicast Listener Query:\n" + <<" Max. ResponseCode : " << unsigned(p->maxResponseCode() ) + <<" \nReserved(16Bit) : " << unsigned(p->reserved() ) + <<" \nMulticast Address : " << p->mcAddress() + <<" \nReserver(4Bit) : " << unsigned(p->resv() ) + <<" \nSuppress Router-Side Processing: " << unsigned(p->sFlag() ) + <<" \nQuerier's Robustness Variable: " << unsigned(p->qrv() ) + <<" \nQuerier's Query Interval Code: " << unsigned(p->qqic() ) + <<" \nSource Addresses: " << "\n"; + senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container c (p->srcAddresses() ); + senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container::iterator i (c.begin() ); + for (unsigned int nr =1; i != c.end(); ++i, ++nr) + os << " " << nr << ".) " <<*i << "\n"; + os << "\n"; +} + +prefix_ void senf::MLDv2ListenerReportType::dump(packet p, std::ostream & os){ + os << "ICMPv6 Multicast Listener Report Message:\n" + <<" Reserved : " << unsigned(p->reserved() ) + <<" Multicast Address Records:\n"; + + senf::MLDv2ListenerReport::Parser::mcastAddrRecords_t::container cAddrR (p->mcastAddrRecords() ); + senf::MLDv2ListenerReport::Parser::mcastAddrRecords_t::container::iterator iAddrR (cAddrR.begin() ); + for (; iAddrR != cAddrR.end(); ++iAddrR){ + os << " Record Type : " << unsigned(iAddrR->recordType() ) + <<" \nMulticast Address : " << iAddrR->mcAddress() + <<" \nSource Addresses :\n"; + + senf::MLDv2AddressRecordParser::srcAddresses_t::container cSrcAddr (iAddrR->srcAddresses() ); + senf::MLDv2AddressRecordParser::srcAddresses_t::container::iterator iSrcAddr ( cSrcAddr.begin() ); + for (;iSrcAddr != cSrcAddr.end();++iSrcAddr) + os <<" " << *iSrcAddr << "\n"; + os << " Auxiliary Data:\n"; + senf::MLDv2AddressRecordParser::auxData_t::container cAuxD ( iAddrR->auxData() ); + senf::MLDv2AddressRecordParser::auxData_t::container::iterator iAuxD (cAuxD.begin() ); + for (;iAuxD != cAuxD.end(); ++iAuxD) + os <<" " << *iAuxD << "\n"; + } +} + + + + -// Local Variables: -// mode: c++ -// fill-column: 100 -// c-file-style: "senf" -// indent-tabs-mode: nil -// ispell-local-dictionary: "american" -// compile-command: "scons -u test" -// comment-column: 40 -// End: +#undef prefix_ \ No newline at end of file diff --git a/senf/Packets/DefaultBundle/ICMPv6TypePacket.hh b/senf/Packets/DefaultBundle/ICMPv6TypePacket.hh index 067f34e..5e41f40 100644 --- a/senf/Packets/DefaultBundle/ICMPv6TypePacket.hh +++ b/senf/Packets/DefaultBundle/ICMPv6TypePacket.hh @@ -106,6 +106,8 @@ namespace senf { using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + + static void dump(packet p, std::ostream & os); }; typedef ConcretePacket ICMPv6EchoReply; @@ -161,6 +163,8 @@ namespace senf { using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + + static void dump(packet p, std::ostream & os); }; typedef ConcretePacket ICMPv6ErrDestUnreachable; @@ -174,10 +178,10 @@ namespace senf { SENF_PARSER_FIELD ( mtu, UInt32Parser ); /* Code static set to 0 */ - // SENF_PARSER_INIT() { - // ICMPv6Packet icmpv6 (packet().rfind(senf::nothrow)); - // icmpv6->code() = 0; - // } + SENF_PARSER_INIT() { + ICMPv6Packet icmpv6 (packet().rfind(senf::nothrow)); + icmpv6->code() = 0; + } SENF_PARSER_FINALIZE ( ICMPv6ErrTooBigParser ); }; @@ -204,6 +208,8 @@ namespace senf { using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + + static void dump(packet p, std::ostream & os); }; typedef ConcretePacket ICMPv6ErrTooBig; @@ -248,6 +254,8 @@ namespace senf { using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + + static void dump(packet p, std::ostream & os); }; typedef ConcretePacket ICMPv6ErrTimeExceeded; @@ -292,6 +300,8 @@ namespace senf { using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + + static void dump(packet p, std::ostream & os); }; typedef ConcretePacket ICMPv6ErrParamProblem; @@ -351,6 +361,8 @@ namespace senf { using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + + static void dump(packet p, std::ostream & os); }; typedef ConcretePacket MLDv2ListenerQuery; @@ -411,6 +423,8 @@ namespace senf { using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + + static void dump(packet p, std::ostream & os); }; typedef ConcretePacket MLDv2ListenerReport;