From: tho Date: Wed, 23 Sep 2009 12:20:34 +0000 (+0000) Subject: Packets: use SENF_PACKET_REGISTRY_REGISTER macro for packet registration X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=ccff925ac3c102822a38617d00aef1bcf5217706;p=senf.git Packets: use SENF_PACKET_REGISTRY_REGISTER macro for packet registration Packets/DefaultBundle: fixed IPv6 Extension Header documentation git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1433 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/80221Bundle/MIHPacket.cc b/senf/Packets/80221Bundle/MIHPacket.cc index 964389b..748bec4 100644 --- a/senf/Packets/80221Bundle/MIHPacket.cc +++ b/senf/Packets/80221Bundle/MIHPacket.cc @@ -36,9 +36,7 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy - registerMIHPacket (0x86dd); - + SENF_PACKET_REGISTRY_REGISTER( senf::EtherTypes, 0x86dd, senf::MIHPacket); } /////////////////////////////////////////////////////////////////////////// diff --git a/senf/Packets/DefaultBundle/EthernetPacket.cc b/senf/Packets/DefaultBundle/EthernetPacket.cc index b3ba75b..4e009d1 100644 --- a/senf/Packets/DefaultBundle/EthernetPacket.cc +++ b/senf/Packets/DefaultBundle/EthernetPacket.cc @@ -35,8 +35,7 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy - registerEthVLanPacket(0x8100); + SENF_PACKET_REGISTRY_REGISTER( senf::EtherTypes, 0x8100, senf::EthVLanPacket); } /////////////////////////////////////////////////////////////////////////// diff --git a/senf/Packets/DefaultBundle/ICMPv6Packet.cc b/senf/Packets/DefaultBundle/ICMPv6Packet.cc index 8692539..d35e2ae 100644 --- a/senf/Packets/DefaultBundle/ICMPv6Packet.cc +++ b/senf/Packets/DefaultBundle/ICMPv6Packet.cc @@ -35,8 +35,7 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy - registerICMPv6Packet (58); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 58, senf::ICMPv6Packet); } prefix_ boost::uint16_t senf::ICMPv6PacketParser::calcChecksum() diff --git a/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc b/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc index 0cb9b3b..57d1dca 100644 --- a/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc +++ b/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc @@ -30,23 +30,14 @@ #ifndef DOXYGEN 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); + 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 ); } #endif diff --git a/senf/Packets/DefaultBundle/IPv4Packet.cc b/senf/Packets/DefaultBundle/IPv4Packet.cc index 3268575..1cdab2e 100644 --- a/senf/Packets/DefaultBundle/IPv4Packet.cc +++ b/senf/Packets/DefaultBundle/IPv4Packet.cc @@ -39,11 +39,8 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy - registerIPv4Packet (0x0800); - - senf::PacketRegistry::RegistrationProxy - regsiterIPv4Packet2 (4); // IP-in-IP encapsulation + SENF_PACKET_REGISTRY_REGISTER( senf::EtherTypes, 0x0800, senf::IPv4Packet); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 4, senf::IPv4Packet); // IP-in-IP encapsulation } /////////////////////////////////////////////////////////////////////////// diff --git a/senf/Packets/DefaultBundle/IPv6Extensions.cc b/senf/Packets/DefaultBundle/IPv6Extensions.cc index 270a307..8a162b5 100644 --- a/senf/Packets/DefaultBundle/IPv6Extensions.cc +++ b/senf/Packets/DefaultBundle/IPv6Extensions.cc @@ -34,14 +34,10 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy - registerIPv6FragmentPacketType (44); - senf::PacketRegistry::RegistrationProxy - registerIPv6RoutingPacketType (43); - senf::PacketRegistry::RegistrationProxy - registerIPv6HopByHopOptionsPacketType (0u); - senf::PacketRegistry::RegistrationProxy - registerIPv6DestinationOptionsPacketType (60u); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 44, senf::IPv6FragmentPacket ); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 43, senf::IPv6RoutingPacket ); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 0u, senf::IPv6HopByHopOptionsPacket ); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 60u, senf::IPv6DestinationOptionsPacket ); } prefix_ void senf::IPv6FragmentPacketType::dump(packet p, std::ostream & os) diff --git a/senf/Packets/DefaultBundle/IPv6Extensions.hh b/senf/Packets/DefaultBundle/IPv6Extensions.hh index 7d1aab6..ee4e18e 100644 --- a/senf/Packets/DefaultBundle/IPv6Extensions.hh +++ b/senf/Packets/DefaultBundle/IPv6Extensions.hh @@ -42,7 +42,7 @@ namespace senf { /** \brief Parse in IPv6 fragment extension header Parser implementing the IPv6 fragment extension. The fields implemented are: - \image html IPv6Extensions_Fragment.png + \image html IPv6FragmentPacket.png \see IPv6ExtensionType_Fragment \n RFC 2460 @@ -113,12 +113,12 @@ namespace senf { Parser implementing the IPv6 routing Header extension (type 0 only). The fields implemented are: - \image html IPv6Extensions_Routing.png + \image html IPv6RoutingPacket.png \see IPv6ExtensionType_Routing \n RFC 2460 */ - struct IPv6PRoutingPacketParser : public PacketParserBase + struct IPv6RoutingPacketParser : public PacketParserBase { /* The Type 0 Routing header has the following format: (RFC 2460) @@ -158,7 +158,7 @@ namespace senf { SENF_PARSER_FIELD ( reserved, UInt32Parser ); //set to zero by RFC SENF_PARSER_VECTOR ( hopAddresses, segmentsLeft, INet6AddressParser ); - SENF_PARSER_FINALIZE ( IPv6PRoutingPacketParser ); + SENF_PARSER_FINALIZE ( IPv6RoutingPacketParser ); //provisionary, since only type 0 is implemented SENF_PARSER_INIT() { @@ -193,7 +193,7 @@ namespace senf { /** \brief IPv6 routing extension packet typedef */ typedef ConcretePacket packet; /** \brief typedef to the parser of IPv6 routing extension packet */ - typedef IPv6PRoutingPacketParser parser; + typedef IPv6RoutingPacketParser parser; using mixin::nextPacketRange; using mixin::nextPacketType; @@ -218,7 +218,7 @@ namespace senf { /** \brief Parse in IPv6 Hop-By-Hop extension header Parser implementing the IPv6 routing Header extension. The fields implemented are: - \image html IPv6Extensions_HopByHop.png + \image html IPv6HopByHopOptionsPacket.png \see IPv6ExtensionType_HopByHop \n RFC 2460 @@ -291,7 +291,7 @@ namespace senf { Parser implementing the IPv6 Destination Options Header extension. The fields implemented are: - \image html IPv6Extensions_Destination.png + \image html IPv6DestinationOptionsPacket.png \see IPv6ExtensionType_Destination \n RFC 2460 diff --git a/senf/Packets/DefaultBundle/IPv6Packet.cc b/senf/Packets/DefaultBundle/IPv6Packet.cc index 4599276..60f7929 100644 --- a/senf/Packets/DefaultBundle/IPv6Packet.cc +++ b/senf/Packets/DefaultBundle/IPv6Packet.cc @@ -36,11 +36,8 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy - registerIPv6Packet (0x86dd); - - senf::PacketRegistry::RegistrationProxy - registerIPv6Packet2 (41); // IP6-in-IP(6) encapsulation + SENF_PACKET_REGISTRY_REGISTER( senf::EtherTypes, 0x86dd, senf::IPv6Packet); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 41, senf::IPv6Packet); // IP6-in-IP(6) encapsulation } prefix_ void senf::IPv6PacketType::dump(packet p, std::ostream & os) diff --git a/senf/Packets/DefaultBundle/TCPPacket.cc b/senf/Packets/DefaultBundle/TCPPacket.cc index 60b4beb..5af6c47 100644 --- a/senf/Packets/DefaultBundle/TCPPacket.cc +++ b/senf/Packets/DefaultBundle/TCPPacket.cc @@ -38,8 +38,7 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy - registerTCPPacket (6); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 6, senf::TCPPacket); } /////////////////////////////////////////////////////////////////////////// diff --git a/senf/Packets/DefaultBundle/UDPPacket.cc b/senf/Packets/DefaultBundle/UDPPacket.cc index 33065ea..3c7980f 100644 --- a/senf/Packets/DefaultBundle/UDPPacket.cc +++ b/senf/Packets/DefaultBundle/UDPPacket.cc @@ -38,8 +38,7 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy - registerUDPPacket (17); + SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 17, senf::UDPPacket); } /////////////////////////////////////////////////////////////////////////// diff --git a/senf/Packets/PacketRegistry.hh b/senf/Packets/PacketRegistry.hh index 932dfec..19c70d5 100644 --- a/senf/Packets/PacketRegistry.hh +++ b/senf/Packets/PacketRegistry.hh @@ -78,6 +78,11 @@ namespace senf { static registration only works when the symbol is included into the final binary. To force this inclusion, you should not put packet registrations into a library but into an object file. + + To simplify static registration the SENF_PACKET_REGISTRY_REGISTER macro can be used: + \code + SENF_PACKET_REGISTRY_REGISTER(SomeTag, SomePacket, key_of_somePacket); + \endcode \ingroup packet_module */ @@ -196,6 +201,7 @@ namespace senf { This macro will declare an anonymous global variable in such a way, that constructing this variable will add a registration to the given packet registry. + \ingroup packet_module \hideinitializer */ # define SENF_PACKET_REGISTRY_REGISTER( registry, value, type ) \ diff --git a/senf/Packets/SConscript b/senf/Packets/SConscript index 68ea6cb..da9f023 100644 --- a/senf/Packets/SConscript +++ b/senf/Packets/SConscript @@ -20,14 +20,14 @@ SENFSCons.AutoRules(env, doc_extra_sources = [ env.PkgDraw("DefaultBundle/LlcSnapPacket.hh"), env.PkgDraw("DefaultBundle/UDPPacket.hh"), env.PkgDraw("DefaultBundle/TCPPacket.hh"), - env.PkgDraw("DefaultBundle/IPv6Extensions_Fragment.png", "DefaultBundle/IPv6Extensions.hh", - PKGDRAWPACKETS = "IPv6PacketParserExtension_Fragment"), - env.PkgDraw("DefaultBundle/IPv6Extensions_Routing.png", "DefaultBundle/IPv6Extensions.hh", - PKGDRAWPACKETS = "IPv6PacketParserExtension_Routing"), - env.PkgDraw("DefaultBundle/IPv6Extensions_HopByHop.png", "DefaultBundle/IPv6Extensions.hh", - PKGDRAWPACKETS = "IPv6PacketParserExtension_HopByHop"), - env.PkgDraw("DefaultBundle/IPv6Extensions_Destination.png", "DefaultBundle/IPv6Extensions.hh", - PKGDRAWPACKETS = "IPv6PacketParserExtension_Destination"), + env.PkgDraw("DefaultBundle/IPv6FragmentPacket.png", "DefaultBundle/IPv6Extensions.hh", + PKGDRAWPACKETS = "IPv6FragmentPacketParser"), + env.PkgDraw("DefaultBundle/IPv6RoutingPacket.png", "DefaultBundle/IPv6Extensions.hh", + PKGDRAWPACKETS = "IPv6RoutingPacketParser"), + env.PkgDraw("DefaultBundle/IPv6HopByHopOptionsPacket.png", "DefaultBundle/IPv6Extensions.hh", + PKGDRAWPACKETS = "IPv6HopByHopOptionsPacketParser"), + env.PkgDraw("DefaultBundle/IPv6DestinationOptionsPacket.png", "DefaultBundle/IPv6Extensions.hh", + PKGDRAWPACKETS = "IPv6DestinationOptionsPacketParser"), env.PkgDraw("DefaultBundle/ICMPv6Packet.hh"), env.PkgDraw("DefaultBundle/ICMPv6EchoRequest.png", "DefaultBundle/ICMPv6TypePacket.hh", PKGDRAWPACKETS = "ICMPv6EchoRequestParser"),