From: g0dil Date: Thu, 19 Jul 2007 14:14:47 +0000 (+0000) Subject: Packets: Completely restructured #includes, introduced central Packets.hh file X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=2d6585ff852e9d282c17003ba1db0b73eb3a8500;p=senf.git Packets: Completely restructured #includes, introduced central Packets.hh file Packets: Fix parser-inheritance example Packets: Change PacketRegistry 'Type' argument to be the ConcretePacket instantiation Packets: Updated PacketRegistry documentation Packets/DefaultBundle: Update to use new Packets.hh include git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@322 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/DataPacket.hh b/Packets/DataPacket.hh index a6d936e..0d4b615 100644 --- a/Packets/DataPacket.hh +++ b/Packets/DataPacket.hh @@ -40,6 +40,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_DataPacket_impl_) +#define HH_DataPacket_impl_ //#include "DataPacket.cci" //#include "DataPacket.ct" //#include "DataPacket.cti" diff --git a/Packets/DefaultBundle/EthernetPacket.cc b/Packets/DefaultBundle/EthernetPacket.cc index 4a50ee2..99e61bb 100644 --- a/Packets/DefaultBundle/EthernetPacket.cc +++ b/Packets/DefaultBundle/EthernetPacket.cc @@ -34,7 +34,7 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy + senf::PacketRegistry::RegistrationProxy registerEthVLanPacket(0x8100); } diff --git a/Packets/DefaultBundle/EthernetPacket.hh b/Packets/DefaultBundle/EthernetPacket.hh index 1267488..ffa1f4b 100644 --- a/Packets/DefaultBundle/EthernetPacket.hh +++ b/Packets/DefaultBundle/EthernetPacket.hh @@ -26,10 +26,7 @@ // Custom includes #include #include -#include "Packets/PacketType.hh" -#include "Packets/ParseInt.hh" -#include "Packets/PacketRegistry.hh" -#include "Packets/PacketParser.hh" +#include "Packets/Packets.hh" //#include "EthernetPacket.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -155,6 +152,8 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#ifndef SENF_PACKETS_DECL_ONLY //#include "EthernetPacket.cci" #include "EthernetPacket.ct" //#include "EthernetPacket.cti" diff --git a/Packets/DefaultBundle/EthernetPacket.test.cc b/Packets/DefaultBundle/EthernetPacket.test.cc index e569894..48f5500 100644 --- a/Packets/DefaultBundle/EthernetPacket.test.cc +++ b/Packets/DefaultBundle/EthernetPacket.test.cc @@ -27,7 +27,6 @@ // Custom includes #include "EthernetPacket.hh" -#include "Packets/DataPacket.hh" #include #include diff --git a/Packets/DefaultBundle/IpV4Packet.cc b/Packets/DefaultBundle/IpV4Packet.cc index 8daed86..4241379 100644 --- a/Packets/DefaultBundle/IpV4Packet.cc +++ b/Packets/DefaultBundle/IpV4Packet.cc @@ -35,10 +35,10 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy + senf::PacketRegistry::RegistrationProxy registerIpV4Packet (0x0800); - senf::PacketRegistry::RegistrationProxy + senf::PacketRegistry::RegistrationProxy regsiterIpV4Packet2 (4); // IP-in-IP encapsulation } diff --git a/Packets/DefaultBundle/IpV4Packet.hh b/Packets/DefaultBundle/IpV4Packet.hh index e8879a2..4c3d977 100644 --- a/Packets/DefaultBundle/IpV4Packet.hh +++ b/Packets/DefaultBundle/IpV4Packet.hh @@ -1,4 +1,4 @@ -// $Id: IpV4Packet.hh 307 2007-07-14 21:31:12Z g0dil $ +// $Id$ // // Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) @@ -24,10 +24,7 @@ #define HH_IpV4Packet_ 1 // Custom includes -#include "Packets/PacketType.hh" -#include "Packets/ParseInt.hh" -#include "Packets/PacketRegistry.hh" -#include "Packets/PacketParser.hh" +#include "Packets/Packets.hh" //#include "IpV4Packet.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -106,6 +103,8 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#ifndef SENF_PACKETS_DECL_ONLY //#include IpV4Packet.cci" //#include "IpV4Packet.ct" //#include "IpV4Packet.cti" diff --git a/Packets/DefaultBundle/IpV6Extensions.cc b/Packets/DefaultBundle/IpV6Extensions.cc index cf2d344..288197e 100644 --- a/Packets/DefaultBundle/IpV6Extensions.cc +++ b/Packets/DefaultBundle/IpV6Extensions.cc @@ -31,7 +31,7 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy + senf::PacketRegistry::RegistrationProxy registerIpV6ExtensionType_Fragment (44); } diff --git a/Packets/DefaultBundle/IpV6Extensions.hh b/Packets/DefaultBundle/IpV6Extensions.hh index 348a1a5..50ace78 100644 --- a/Packets/DefaultBundle/IpV6Extensions.hh +++ b/Packets/DefaultBundle/IpV6Extensions.hh @@ -82,6 +82,8 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#ifndef SENF_PACKETS_DECL_ONLY //#include "IpV6Extensions.cci" //#include "IpV6Extensions.ct" //#include "IpV6Extensions.cti" diff --git a/Packets/DefaultBundle/IpV6Extensions.test.cc b/Packets/DefaultBundle/IpV6Extensions.test.cc index 0c7ac31..6c7a09b 100644 --- a/Packets/DefaultBundle/IpV6Extensions.test.cc +++ b/Packets/DefaultBundle/IpV6Extensions.test.cc @@ -28,7 +28,6 @@ #include "IpV6Extensions.hh" #include "IpV6Packet.hh" #include "UDPPacket.hh" -#include "Packets/DataPacket.hh" #include "Socket/INetAddressing.hh" #include diff --git a/Packets/DefaultBundle/IpV6Packet.cc b/Packets/DefaultBundle/IpV6Packet.cc index 899e21a..7a72d0f 100644 --- a/Packets/DefaultBundle/IpV6Packet.cc +++ b/Packets/DefaultBundle/IpV6Packet.cc @@ -26,7 +26,6 @@ // Custom includes #include "EthernetPacket.hh" -#include "Packets/DataPacket.hh" #include "Socket/INetAddressing.hh" //#include "IpV6Packet.mpp" @@ -34,13 +33,13 @@ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy + senf::PacketRegistry::RegistrationProxy registerIpV6Packet (0x86dd); - senf::PacketRegistry::RegistrationProxy + senf::PacketRegistry::RegistrationProxy registerIpV6Packet2 (41); // IP6-in-IP(6) encapsulation - senf::PacketRegistry::RegistrationProxy + senf::PacketRegistry::RegistrationProxy registerNoNextHeader (59); } diff --git a/Packets/DefaultBundle/IpV6Packet.hh b/Packets/DefaultBundle/IpV6Packet.hh index 0f1aafb..b332a98 100644 --- a/Packets/DefaultBundle/IpV6Packet.hh +++ b/Packets/DefaultBundle/IpV6Packet.hh @@ -25,11 +25,7 @@ #define HH_IpV6Packet_ 1 // Custom includes -#include "Packets/PacketType.hh" -#include "Packets/ParseInt.hh" -#include "Packets/PacketRegistry.hh" -#include "Packets/PacketParser.hh" -#include "Packets/ParseArray.hh" +#include "Packets/Packets.hh" #include "IpV4Packet.hh" //#include "IpV6Packet.mpp" @@ -95,6 +91,8 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#ifndef SENF_PACKETS_DECL_ONLY //#include "IpV6Packet.cci" //#include "IpV6Packet.ct" //#include "IpV6Packet.cti" diff --git a/Packets/DefaultBundle/UDPPacket.cc b/Packets/DefaultBundle/UDPPacket.cc index 3c8247c..4b6fe1e 100644 --- a/Packets/DefaultBundle/UDPPacket.cc +++ b/Packets/DefaultBundle/UDPPacket.cc @@ -27,13 +27,13 @@ #include "IpV4Packet.hh" // Custom includes -#include "Packets/DataPacket.hh" +#include "Packets/Packets.hh" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// namespace { - senf::PacketRegistry::RegistrationProxy + senf::PacketRegistry::RegistrationProxy registerUDPPacket (17); } diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh index 2648548..bc3ab1d 100644 --- a/Packets/DefaultBundle/UDPPacket.hh +++ b/Packets/DefaultBundle/UDPPacket.hh @@ -1,4 +1,4 @@ -// $Id: UDPPacket.hh 308 2007-07-14 22:31:20Z g0dil $ +// $Id$ // // Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) @@ -24,10 +24,7 @@ #define HH_UDPPacket_ 1 // Custom includes -#include "Packets/PacketType.hh" -#include "Packets/ParseInt.hh" -#include "Packets/PacketRegistry.hh" -#include "Packets/PacketParser.hh" +#include "Packets/Packets.hh" //#include "UDPPacket.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -75,6 +72,8 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#ifndef SENF_PACKETS_DECL_ONLY //#include UDPPacket.cci" //#include "UDPPacket.ct" //#include "UDPPacket.cti" diff --git a/Packets/Mainpage.dox b/Packets/Mainpage.dox index d1437a7..f62651f 100644 --- a/Packets/Mainpage.dox +++ b/Packets/Mainpage.dox @@ -15,18 +15,30 @@ packet parsing and creation. \section intro Introduction + + Whenever using the library, you will probably need to \c \#include it's header: + + \code + #include "Packets/Packets.hh" + \endcode + + \warning Never include any other Packets library header directly, always include \c + Packets/Packets.hh. + + Additionally you will have to include the header files for the packet types you use, e.g. \c + Packets/DefaultBundle/EthernetPacket.hh etc. Most every use of the packet library starts with some concrete packet typedef. Some fundamental - packet typedefs are provided by \ref protocolbundle_default. The first example will build a - complex packet: This will be an Ethernet packet containing an IPv4 UDP packet. We begin by - building the raw packet skeleton: + packet types are provided by \ref protocolbundle_default. Building on those packet types, this + example will build a complex packet: This will be an Ethernet packet containing an IPv4 UDP + packet. We begin by building the raw packet skeleton: \code - senf::EthernetPacket eth (senf::EthernetPacket::create()); - senf::IpV4Packet ip (senf::IpV4Packet::createAfter(ethernet)); - senf::UDPPacket udp (senf::UDPPacket::createAfter(ip)); - senf::DataPacket payload (senf::DataPacket::createAfter(udp, - std::string("Hello, world!"))); + senf::EthernetPacket eth (senf::EthernetPacket::create()); + senf::IpV4Packet ip (senf::IpV4Packet ::createAfter(ethernet)); + senf::UDPPacket udp (senf::UDPPacket ::createAfter(ip)); + senf::DataPacket payload (senf::DataPacket ::createAfter(udp, + std::string("Hello, world!"))); \endcode These commands create what is called an interpreter chain. This chain consists of four @@ -42,15 +54,15 @@ empty. We need to set those protocol fields: \code - udp->source() = 2000u; - udp->destination() = 2001u; - ip->ttl() = 255u; - ip->source() = senf::INet4Address("192.168.0.1"); // (*) - ip->destination() = senf::INet4Address("192.168.0.2"); // (*) - eth->source() = senf::MACAddress("00:11:22:33:44:55"); - eth->destination() = senf::MACAddress("00:11:22:33:44:66"); + udp->source() = 2000u; + udp->destination() = 2001u; + ip->ttl() = 255u; + ip->source() = senf::INet4Address("192.168.0.1"); // (*) + ip->destination() = senf::INet4Address("192.168.0.2"); // (*) + eth->source() = senf::MACAddress("00:11:22:33:44:55"); + eth->destination() = senf::MACAddress("00:11:22:33:44:66"); - eth.finalize(); // (*) + eth.finalize(); // (*) \endcode As seen above, packet fields are accessed using the -> operator whereas other packet @@ -60,26 +72,26 @@ checksums etc). Now the packet is ready. We may now send it out using a packet socket \code - senf::PacketSocketHandle sock ("eth0"); - sock.write(eth.data()); + senf::PacketSocketHandle sock ("eth0"); + sock.write(eth.data()); \endcode The packet library also provides lot's of facilities to navigate the packet chain: \code - eth.next() == ip; // true - eth.next().is(); // true - eth.next().next() == udp; // true - eth.next().is(); // false - eth.next() == udp; // true - - udp.next(); // throws InvalidPacketChainException - udp.next(senf::nothrow); // a senf::Packet testing as false - udp.findNext == udp; // true - udp.first() == ip; // true - - udp.prev() == ip; // true - udp.prev() == eth // true + eth.next() == ip; // true + eth.next().is(); // true + eth.next().next() == udp; // true + eth.next().is(); // false + eth.next() == udp; // true + + udp.next(); // throws InvalidPacketChainException + udp.next(senf::nothrow); // a senf::Packet testing as false + udp.findNext == udp; // true + udp.first() == ip; // true + + udp.prev() == ip; // true + udp.prev() == eth // true \endcode ... and so on. It is therefore not necessary to stash away a reference for every interpreter (as @@ -89,23 +101,23 @@ from a packet socket handle: \code - senf::PacketSocketHandle sock ("eth0"); - senf::EthernetPacket packet (senf::EthernetPacket::create(senf::Packet::noinit)); - sock.read(packet.data(),0u); + senf::PacketSocketHandle sock ("eth0"); + senf::EthernetPacket packet (senf::EthernetPacket::create(senf::Packet::noinit)); + sock.read(packet.data(),0u); \endcode This first creates an uninitialized Ethernet packet and then reads into this packet. We can now parse this packet. Let's find out, whether this is a UDP packet destined to port 2001: \code - try { - senf::UDPPacket udp (packet.findNext(senf::nothrow)); - if (udp && udp->destination() == 2001u) { - // Voila ... - } - } catch (senf::TruncatedPacketException const &) { - std::cerr << "Ooops !! Broken packet received ...\n" - } + try { + senf::UDPPacket udp (packet.findNext(senf::nothrow)); + if (udp && udp->destination() == 2001u) { + // Voila ... + } + } catch (senf::TruncatedPacketException const &) { + std::cerr << "Ooops !! Broken packet received ...\n" + } \endcode TruncatedPacketException is thrown by udp->destination() if that field cannot be @@ -131,4 +143,4 @@ // LocalWords: udp endcode li senf EthernetPacket eth IpV createAfter ip std // LocalWords: ethernet UDPPacket DataPacket ttl INet MACAddress nothrow prev // LocalWords: PacketSocketHandle InvalidPacketChainException findNext noinit -// LocalWords: tt TruncatedPacketException const cerr Ooops +// LocalWords: tt TruncatedPacketException const cerr Ooops hh diff --git a/Packets/Packet.cc b/Packets/Packet.cc index 02cc5ec..1522add 100644 --- a/Packets/Packet.cc +++ b/Packets/Packet.cc @@ -21,12 +21,10 @@ /** \file \brief Packet non-inline non-template implementation */ -#include "PacketInterpreter.hh" -#include "Packet.hh" //#include "Packet.ih" // Custom includes -#include "DataPacket.hh" +#include "Packets.hh" //#include "Packet.mpp" #define prefix_ diff --git a/Packets/Packet.hh b/Packets/Packet.hh index c2c8b92..fabd6a4 100644 --- a/Packets/Packet.hh +++ b/Packets/Packet.hh @@ -580,6 +580,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_Packet_i_) +#define HH_Packet_i_ #include "Packet.cci" #include "Packet.ct" #include "Packet.cti" @@ -604,4 +607,4 @@ namespace senf { // LocalWords: PacketTypeBase TruncatedPacketException http www org Institut // LocalWords: Fraunhofer fuer offene Kommunikationssysteme FOKUS SatCom Bund // LocalWords: Kompetenzzentrum Satelitenkommunikation berlios de hh -// LocalWords: addtogroup Structors PacketType dil +// LocalWords: addtogroup Structors PacketType dil PacketType's diff --git a/Packets/Packet.test.cc b/Packets/Packet.test.cc index 509039e..a33ccd4 100644 --- a/Packets/Packet.test.cc +++ b/Packets/Packet.test.cc @@ -26,12 +26,7 @@ // Custom includes #include -#include "PacketType.hh" -#include "PacketRegistry.hh" -#include "Packet.hh" -#include "ParseInt.hh" -#include "PacketParser.hh" -#include "DataPacket.hh" +#include "Packets.hh" #include #include @@ -105,8 +100,8 @@ namespace { typedef BarPacketType::packet BarPacket; namespace reg { - senf::PacketRegistry::RegistrationProxy registerFoo(1u); - senf::PacketRegistry::RegistrationProxy registerBar(2u); + senf::PacketRegistry::RegistrationProxy registerFoo(1u); + senf::PacketRegistry::RegistrationProxy registerBar(2u); } } diff --git a/Packets/PacketData.cc b/Packets/PacketData.cc index 8751951..7e50a00 100644 --- a/Packets/PacketData.cc +++ b/Packets/PacketData.cc @@ -21,11 +21,10 @@ /** \file \brief PacketData non-inline non-template implementation */ -#include "PacketData.hh" //#include "PacketData.ih" // Custom includes -#include "PacketImpl.hh" +#include "Packets.hh" //#include "PacketData.mpp" #define prefix_ diff --git a/Packets/PacketData.hh b/Packets/PacketData.hh index fee2c00..8d94d9c 100644 --- a/Packets/PacketData.hh +++ b/Packets/PacketData.hh @@ -186,8 +186,8 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_PacketData_DeclOnly) &&!defined(HH_PacketData_def) -#define HH_PacketData_def +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketData_i_) +#define HH_PacketData_i_ #include "PacketData.cci" //#include "PacketData.ct" #include "PacketData.cti" diff --git a/Packets/PacketData.test.cc b/Packets/PacketData.test.cc index e9e3f3a..91c5447 100644 --- a/Packets/PacketData.test.cc +++ b/Packets/PacketData.test.cc @@ -25,8 +25,7 @@ //#include "PacketData.test.ih" // Custom includes -#include "PacketData.hh" -#include "PacketType.hh" +#include "Packets.hh" #include #include diff --git a/Packets/PacketImpl.cc b/Packets/PacketImpl.cc index e4db066..8dfd75e 100644 --- a/Packets/PacketImpl.cc +++ b/Packets/PacketImpl.cc @@ -21,12 +21,11 @@ /** \file \brief PacketImpl non-inline non-template implementation */ -#include "PacketImpl.hh" //#include "PacketImpl.ih" // Custom includes #include -#include "PacketInterpreter.hh" +#include "Packets.hh" //#include "PacketImpl.mpp" #define prefix_ diff --git a/Packets/PacketImpl.hh b/Packets/PacketImpl.hh index 39ccd47..516d272 100644 --- a/Packets/PacketImpl.hh +++ b/Packets/PacketImpl.hh @@ -114,6 +114,9 @@ namespace detail { }} ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketImpl_i_) +#define HH_PacketImpl_i_ #include "PacketImpl.cci" //#include "PacketImpl.ct" #include "PacketImpl.cti" diff --git a/Packets/PacketImpl.test.cc b/Packets/PacketImpl.test.cc index 83e5373..e4e5bcb 100644 --- a/Packets/PacketImpl.test.cc +++ b/Packets/PacketImpl.test.cc @@ -25,9 +25,7 @@ //#include "PacketImpl.test.ih" // Custom includes -#include "PacketImpl.hh" -#include "PacketInterpreter.hh" -#include "PacketType.hh" +#include "Packets.hh" #include "main.test.hh" #include diff --git a/Packets/PacketInterpreter.cc b/Packets/PacketInterpreter.cc index 7cd389a..a9ca163 100644 --- a/Packets/PacketInterpreter.cc +++ b/Packets/PacketInterpreter.cc @@ -21,10 +21,10 @@ /** \file \brief PacketInterpreter non-inline non-template implementation */ -#include "PacketInterpreter.hh" //#include "PacketInterpreter.ih" // Custom includes +#include "Packets.hh" //#include "PacketInterpreter.mpp" #define prefix_ diff --git a/Packets/PacketInterpreter.ct b/Packets/PacketInterpreter.ct index b2f455b..a8d0095 100644 --- a/Packets/PacketInterpreter.ct +++ b/Packets/PacketInterpreter.ct @@ -194,7 +194,7 @@ prefix_ void senf::PacketInterpreter::v_dump(std::ostream & os) template prefix_ senf::TypeIdValue senf::PacketInterpreter::v_type() { - return typeIdValue(); + return typeIdValue< ConcretePacket >(); } template diff --git a/Packets/PacketInterpreter.hh b/Packets/PacketInterpreter.hh index aed5c56..878de5b 100644 --- a/Packets/PacketInterpreter.hh +++ b/Packets/PacketInterpreter.hh @@ -352,6 +352,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketInterpreter_i_) +#define HH_PacketInterpreter_i_ #include "PacketInterpreter.cci" #include "PacketInterpreter.ct" #include "PacketInterpreter.cti" diff --git a/Packets/PacketInterpreter.test.cc b/Packets/PacketInterpreter.test.cc index c26dc07..2428699 100644 --- a/Packets/PacketInterpreter.test.cc +++ b/Packets/PacketInterpreter.test.cc @@ -25,9 +25,7 @@ //#include "PacketInterpreter.test.ih" // Custom includes -#include "PacketImpl.hh" -#include "PacketInterpreter.hh" -#include "PacketType.hh" +#include "Packets.hh" #include #include diff --git a/Packets/PacketParser.hh b/Packets/PacketParser.hh index 6c40b2f..b963955 100644 --- a/Packets/PacketParser.hh +++ b/Packets/PacketParser.hh @@ -74,9 +74,7 @@ #include #include "Utils/SafeBool.hh" #include "PacketTypes.hh" -#define HH_PacketData_DeclOnly #include "PacketData.hh" -#undef HH_PacketData_DeclOnly #include "PacketParser.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -459,7 +457,7 @@ namespace senf { \code struct ExtendedParser : public BaseParser { - SENF_PACKET_PARSER_NO_INIT(ExtendedParser); + ExtendedParser(data_iterator i, state_type s) : BaseParser(i,s) {} SENF_PACKET_PARSER_DEFINE_FIELDS_OFFSET(senf::bytes(BaseParser(*this)), ( ... fields ... ) ); @@ -499,7 +497,7 @@ namespace senf { \code struct ExtendedParser : public BaseParser { - SENF_PACKET_PARSER_NO_INIT(ExtendedParser); + ExtendedParser(data_iterator i, state_type s) : BaseParser(i,s) {} SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS_OFFSET(BaseParser::fixed_bytes, ( ... fields ... ) ); @@ -582,6 +580,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketParser_i_) +#define HH_PacketParser_i_ #include "PacketParser.cci" #include "PacketParser.ct" #include "PacketParser.cti" diff --git a/Packets/PacketParser.test.cc b/Packets/PacketParser.test.cc index 5db0e60..23b1be9 100644 --- a/Packets/PacketParser.test.cc +++ b/Packets/PacketParser.test.cc @@ -25,10 +25,7 @@ //#include "PacketParser.test.ih" // Custom includes -#include "PacketParser.hh" -#include "PacketInterpreter.hh" -#include "PacketType.hh" -#include "ParseInt.hh" +#include "Packets.hh" #include #include diff --git a/Packets/PacketRegistry.cc b/Packets/PacketRegistry.cc index 09a6af8..c119131 100644 --- a/Packets/PacketRegistry.cc +++ b/Packets/PacketRegistry.cc @@ -21,10 +21,9 @@ /** \file \brief PacketRegistry non-inline non-template implementation */ -#include "PacketRegistry.hh" -#include "PacketRegistry.ih" // Custom includes +#include "Packets.hh" //#include "PacketRegistry.mpp" #define prefix_ diff --git a/Packets/PacketRegistry.ct b/Packets/PacketRegistry.ct index ca5a144..2147023 100644 --- a/Packets/PacketRegistry.ct +++ b/Packets/PacketRegistry.ct @@ -20,7 +20,8 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline template funPacketRegistry.ons +/** \file + \brief PacketRegistry non-inline template implementation */ #include "PacketRegistry.ih" @@ -34,7 +35,7 @@ template prefix_ senf::PacketInterpreterBase::factory_t senf::detail::PkReg_EntryImpl::factory() const { - return PacketInterpreter::factory(); + return PacketType::factory(); } template diff --git a/Packets/PacketRegistry.cti b/Packets/PacketRegistry.cti index 41a9127..0998801 100644 --- a/Packets/PacketRegistry.cti +++ b/Packets/PacketRegistry.cti @@ -20,7 +20,8 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of inline template funPacketRegistry.ons +/** \file + \brief PacketRegistry inline template implementation */ #include "PacketRegistry.ih" @@ -65,7 +66,8 @@ prefix_ typename Tag::key_t senf::PacketRegistry::key(Packet packet) } template -prefix_ typename Tag::key_t senf::PacketRegistry::key(Packet packet, NoThrow_t) +prefix_ typename boost::optional +senf::PacketRegistry::key(Packet packet, NoThrow_t) { return registry().key(packet.typeId(),true); } diff --git a/Packets/PacketRegistry.hh b/Packets/PacketRegistry.hh index e27f106..ef1fa26 100644 --- a/Packets/PacketRegistry.hh +++ b/Packets/PacketRegistry.hh @@ -20,6 +20,8 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +/** \file + \brief PacketRegistry public header */ #ifndef HH_PacketRegistryImpl_ #define HH_PacketRegistryImpl_ 1 @@ -29,7 +31,6 @@ #include // for boost::noncopyable #include #include "Utils/Exception.hh" -#include "PacketInterpreter.hh" #include "Packet.hh" //#include "PacketRegistry.mpp" @@ -37,66 +38,77 @@ namespace senf { + /** \brief Registry entry + + Value returned by a registry lookup + */ struct PkReg_Entry : public intrusive_refcount { virtual ~PkReg_Entry(); - virtual PacketInterpreterBase::factory_t factory() const = 0; + virtual Packet::factory_t factory() const = 0; + ///< Get factory of the registered packet type }; namespace detail { template class PacketRegistryImpl; } /** \brief Packet registration facility - The PacketRegistry provides a generic facility to associate an - arbitrary key with Packets. Example keys are Ethertype or IP - protocols. + The PacketRegistry provides a generic facility to associate an arbitrary key with + Packets. Example keys are Ethertype or IP protocols. Every PacketRegistry is identified by a type tag: \code - struct SomeTag { - typedef some_key_type key_t; - }; + struct SomeTag { + typedef some_key_type key_t; + }; \endcode - The key type can be an arbitrary value type. The PacketRegistry - for this Tag can then be accessed using - PacketRegistry::. + The key type can be an arbitrary value type. The PacketRegistry for this Tag can then be + accessed using senf::PacketRegistry::. - The PacketRegistry class has only static members and provides - access to the packet registry. It allows to register Packet - classes and to create new Packets given a key. Methods are - also provided to find the key of a Packet type. + The PacketRegistry class has only static members and provides access to the packet + registry. It allows two-way lookup either by key or by packet type. \code - PacketRegistry::registerPacket(key_of_somePacket); - p = PacketRegistry::create(some_key,begin,end); - SomeTag::key_t key = PacketRegistry::key(); + senf::Packet::factory_t factory (senf::PacketRegistry::lookup(some_key).factory()); + SomeTag::key_t key = PacketRegistry::key(); \endcode - Normally, packet classes are registered statically and not - procedurally. To this end, the RegistrationProxy is provided: + Packets can be registered either dynamically or statically. Dynamic: \code - PacketRegistry::RegistrationProxy - registerSomePacket (key_of_somePacket); + // dynamic registration + senf::PacketRegistry::registerPacket(key_of_somePacket); + + // static registration. 'registerSomePacket' is an arbitrary symbol name + senf::PacketRegistry::RegistrationProxy + registerSomePacket (key_of_somePacket); \endcode - This global variable declaration will register \c SomePacket - with the \c SomeTag registry under the key \c - key_of_somePacket. The variable \c registerSomePacket is a - dummy. It's only function is to force the call of it's - constructor during global construction time. - - The PacketRegistry's purpose is mostly to assist in - implementing the v_nextInterpreter() member of packet - facades. This is further supported by the PacketRegistryMixin - class. - - \todo Add parameterless create() method + + This global variable declaration will register \a SomePacket with the \a SomeTag registry + under the key \a key_of_somePacket. The variable \a registerSomePacket is a dummy. It's only + function is to force the call of it's constructor during global construction time. This + 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. + + \ingroup packet_module */ template class PacketRegistry { public: /** \brief Statically register a packet type in a PacketRegistry + + To use this class, define a global symbol in the following way: + \code + namespace { + senf::PacketRegistry::RegistrationProxy + registerPacketType (key); + } + \endcode Here \a Tag is the type tag of the registry to register the packet in, \a + PacketType is the packet to register (this is the ConcretePacket of that packet) and \a + key is the key of type \c Tag::key_t under which the packet is to be registered. \a + registerPacketType is an arbitrary name for the global symbol. */ template struct RegistrationProxy @@ -106,49 +118,74 @@ namespace senf { /** \brief Register new packet type - Register \c PacketType in the packet registry \c Tag - under the given \c key. + Register \a PacketType in the packet registry \a Tag under the given \a key. - \par Preconditions: - The given \c key must be unique and not be assigned to - any other packet class in this registry. - The Packet must not already be registered in the registry. + \par Preconditions: The given \a key must be unique and not be assigned to any other + packet class in this registry. The Packet must not already be registered in the + registry. - \param PacketType packet to register - \param key key of the packet + \param PacketType ConcretePacket instantiation of packet to register + \param key The key of the packet */ template static void registerPacket(typename Tag::key_t key); - /** \brief Find key of a packet + /** \brief Find key of a packet type - Return the key of \c PacketType as registered in the \c - Tag registry + Return the key of \a PacketType as registered in the \a Tag registry \param PacketType packet of which the key is requested \returns key of the packet - \throws PacketTypeNotRegistered if the packet type is not - found in the registry. + \throws PacketTypeNotRegistered if the packet type is not found in the registry. */ template static typename Tag::key_t key(); + /** \brief Find key of a packet type + + Return the key of \a PacketType as registered in the \a Tag registry + + \param PacketType packet of which the key is requested + \returns key of the packet wrapped in a boost::optional or + an unbound optional, if the key is not found. + */ template static typename boost::optional key(NoThrow_t); + /** \brief Find key of a packet + + Return the key of \a packet, an arbitrary packet, as registered in the \a Tag registry. + + \param packet The packet of which the key is requested + \returns key of the packet + \throws PacketTypeNotRegistered if the packet type is not found in the registry. + */ static typename Tag::key_t key(Packet packet); - static typename Tag::key_t key(Packet packet, NoThrow_t); - /** \brief Lookup a packet by it's key + /** \brief Find key of a packet + + Return the key of \a packet, an arbitrary packet, as registered in the \a Tag registry. - Returns the packet registration registered under \a key in the \a Tag registry + \param packet The +packet of which the key is requested + \returns key of the packet wrapped in a boost::optional or + an unbound optional, if the key is not found. + */ + static typename boost::optional key(Packet packet, NoThrow_t); - \param key Key of the packet registered - \returns Registration entry of the packet - \throws PacketTypeNotRegistered if the packet type is not found in the registry + /** \brief Lookup a packet by it's key + + \throws PacketTypeNotRegistered if the \a key is not found in the registry + \return Packet entry for given \a key */ static PkReg_Entry const & lookup(typename Tag::key_t key); + /** \brief Lookup a packet by it's key + \return Pointer to packet entry for given \a key or 0, if the key is not found in the + registry. + */ static PkReg_Entry const * lookup(typename Tag::key_t key, NoThrow_t); private: @@ -162,6 +199,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketRegistryImpl_i_) +#define HH_PacketRegistryImpl_i_ //#include "PacketRegistry.cci" #include "PacketRegistry.ct" #include "PacketRegistry.cti" @@ -177,3 +217,11 @@ namespace senf { // compile-command: "scons -u test" // comment-column: 40 // End: + +// LocalWords: PacketRegistry hh dil Fraunhofer Institut fuer offene FOKUS de +// LocalWords: Kommunikationssysteme Kompetenzzentrum Satelitenkommunikation +// LocalWords: SatCom Bund stefan bund fokus fraunhofer Ethertype IP struct +// LocalWords: SomeTag endcode senf SomePacket registerPacket ingroup param +// LocalWords: registerSomePacket RegistrationProxy namespace PacketType key +// LocalWords: registerPacketType ConcretePacket PacketTypeNotRegistered href +// LocalWords: http www org html diff --git a/Packets/PacketRegistry.ih b/Packets/PacketRegistry.ih index 94b9169..4043362 100644 --- a/Packets/PacketRegistry.ih +++ b/Packets/PacketRegistry.ih @@ -20,6 +20,9 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +/** \file + \brief PacketRegistry internal header */ + #ifndef IH_PacketRegistryImpl_ #define IH_PacketRegistryImpl_ 1 @@ -31,14 +34,16 @@ namespace senf { namespace detail { - + + ///\internal template struct PkReg_EntryImpl : public PkReg_Entry { - virtual PacketInterpreterBase::factory_t factory() const; + virtual Packet::factory_t factory() const; }; + ///\internal template class PacketRegistryImpl : private boost::noncopyable diff --git a/Packets/PacketRegistry.test.cc b/Packets/PacketRegistry.test.cc index 70618f2..07523d9 100644 --- a/Packets/PacketRegistry.test.cc +++ b/Packets/PacketRegistry.test.cc @@ -27,9 +27,7 @@ // Custom includes #include -#include "PacketRegistry.hh" -#include "PacketType.hh" -#include "ParseInt.hh" +#include "Packets.hh" #include #include @@ -50,30 +48,32 @@ namespace { }; struct FooPacketType : public PacketTypeBase {}; + typedef senf::ConcretePacket FooPacket; struct BarPacketType : public PacketTypeBase {}; + typedef senf::ConcretePacket BarPacket; struct OtherPacketType : public PacketTypeBase {}; + typedef senf::ConcretePacket OtherPacket; namespace reg { - PacketRegistry::RegistrationProxy registerFoo ("foo"); - PacketRegistry::RegistrationProxy registerBar ("bar"); + PacketRegistry::RegistrationProxy registerFoo ("foo"); + PacketRegistry::RegistrationProxy registerBar ("bar"); } } BOOST_AUTO_UNIT_TEST(packetRegistry_test) { - PacketRegistry::registerPacket(1u); - PacketRegistry::registerPacket(2u); + PacketRegistry::registerPacket(1u); + PacketRegistry::registerPacket(2u); - BOOST_CHECK_EQUAL( PacketRegistry::key(), 1u ); - BOOST_CHECK_EQUAL( PacketRegistry::key(), 2u ); - BOOST_CHECK_THROW( PacketRegistry::key(), + BOOST_CHECK_EQUAL( PacketRegistry::key(), 1u ); + BOOST_CHECK_EQUAL( PacketRegistry::key(), 2u ); + BOOST_CHECK_THROW( PacketRegistry::key(), PacketTypeNotRegisteredException ); - BOOST_CHECK_EQUAL( PacketRegistry::key(), "foo" ); + BOOST_CHECK_EQUAL( PacketRegistry::key(), "foo" ); BOOST_CHECK( ! PacketRegistry::lookup("blub", senf::nothrow) ); BOOST_CHECK( PacketRegistry::lookup(1u, senf::nothrow) ); - } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/Packets/PacketType.hh b/Packets/PacketType.hh index 8e46eec..03af113 100644 --- a/Packets/PacketType.hh +++ b/Packets/PacketType.hh @@ -36,7 +36,7 @@ namespace senf { - /** \brief Helper baseclass implementing the PacketType interface + /** \brief Helper base-class implementing the PacketType interface This helper class maybe used when building a new PacketType. It provides a complete default implementations of this interface. To define a new PacketType, derive from this class and @@ -88,7 +88,7 @@ namespace senf { static void finalize(packet p) { - // optionally complete the packet by generating autogenerated information + // optionally complete the packet by generating auto-generated information // (like checksums) } @@ -101,6 +101,8 @@ namespace senf { You may leave out any one of the members (you should however always define the \c interpreter typedef member) + + \ingroup packet_module */ struct PacketTypeBase { @@ -124,7 +126,7 @@ namespace senf { ///< Parser to parser packet fields /**< This typedef has to be set to the parser of the packet - The default is a VoidPacketParser which does not parser + The default is a VoidPacketParser which does not parse any field. */ static size_type initSize(); @@ -136,7 +138,7 @@ namespace senf { static size_type initHeadSize(); ///< Get size of new (empty) packet header /**< This function gives the index within a newly created, - empty packet where a subpacket is to be placed. + empty packet where a sub-packet is to be placed. The default implementation returns initSize(). @@ -152,7 +154,7 @@ namespace senf { packet. The new packet will have a size of at least initSize() but the size may well be larger. It is also possible for the packet to already have further - subpackets. + sub-packets. The default implementation does nothing. */ @@ -203,8 +205,8 @@ namespace senf { static void dump(packet p, std::ostream & os); ///< Dump packet data in readable form /**< The dump() function writes out a complete - representation of the packet. This is used formost for - debugging purposes. + representation of the packet. This is used for most for + debugging purposes. The default implementation does nothing. */ }; @@ -213,13 +215,28 @@ namespace senf { /** \brief Mixin to provide standard implementations for nextPacketRange and nextPacketType This mixin class simplifies the definition of simple packets with fixed-size headers and/or - trailers. For this type of Packet, this mixin provides the nextPacketRange() and - nextPacketType() members: + trailers. For this type of Packet, this mixin provides the nextPacketRange() member. If you + additionally provide the optional \a Registry argument, PacketTypeMixin provides a simple + implementation of nextPacketType. When using the PacketTypeMixin, the implementation of a + packet is simplified to: \code + // Here 'SomeRegistryTag' is optional struct SimplePacketType : public senf::PacketTypeBase - pyblic senf:PacketTypeMixin + public senf:PacketTypeMixin { + typedef senf::PacketTypeMixin mixin; + typedef senf::ConcretePacket packet; + typedef SomePacketParser parser; + + using mixin::nextPacketRange; + // Only if the optional 'Registry' argument is provided + using mixin::nextPacketType; + // Only if using the default implementation + using mixin::initSize; + // Only if using the default implementation + using mixin::init; + static interpreter::size_type initSize() { // This member is optional. If it is not defined, 'senf::init_size::value' @@ -238,6 +255,12 @@ namespace senf { return header_size; } + static void init(packet p) + { + // This member is optional. The default implementation calls the parsers init() + // member. + } + static registry_key_t nextPacketKey(packet p) { // Return the key in the registry under which the next packet @@ -245,8 +268,46 @@ namespace senf { // passed to the PacketTypeMixin template. return i.fields().typeField(); } + + static void finalize(packet p) + { + // optionally complete the packet by generating auto-generated information + // (like checksums) + } + + static void dump(packet p, std::ostream & os) + { + // Write out a readable representation of the packet for debug purposes + } }; \endcode + + Most of the members are optional, which reduces the implementation of a fixed-sized header + packet with no trailer and a simple next-packet header to + + \code + struct SimplePacketType + : public senf::PacketTypeBase + public senf:PacketTypeMixin + { + typedef senf::PacketTypeMixin mixin; + typedef senf::ConcretePacket packet; + typedef SomePacketParser parser; + + using mixin::nextPacketRange; + using mixin::nextPacketType; + using mixin::initSize; + using mixin::init; + + static registry_key_t nextPacketKey(packet p) + { return i.fields().typeField(); } + }; + \endcode + + If needed, you may additionally add a \c finalize() member. You also should add a \c dump() + member to help debugging but both members are optional. + + \ingroup packet_module */ template class PacketTypeMixin @@ -272,6 +333,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketType_i_) +#define HH_PacketType_i_ #include "PacketType.cci" //#include "PacketType.ct" #include "PacketType.cti" @@ -287,3 +351,12 @@ namespace senf { // compile-command: "scons -u test" // comment-column: 40 // End: + +// LocalWords: Fraunhofer Institut fuer offene Kommunikationssysteme FOKUS de +// LocalWords: Kompetenzzentrum Satelitenkommunikation SatCom Bund berlios dil +// LocalWords: PacketType struct SomePacketType senf PacketTypeBase initSize +// LocalWords: ConcretePacket init initHeadSize nextPacketRange NextPacket os +// LocalWords: nextPacketType std ostream endcode ingroup VoidPacketParser Ok +// LocalWords: tt li OtherPacketType Mixin mixin SimplePacketType typeField +// LocalWords: PacketTypeMixin SomeRegistryTag SomePacketParser nextPacketKey +// LocalWords: hh diff --git a/Packets/PacketTypes.hh b/Packets/PacketTypes.hh index 980c183..68fa471 100644 --- a/Packets/PacketTypes.hh +++ b/Packets/PacketTypes.hh @@ -72,6 +72,9 @@ namespace test { }}}} ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketTypes_i_) +#define HH_PacketTypes_i_ //#include "PacketTypes.cci" //#include "PacketTypes.ct" //#include "PacketTypes.cti" diff --git a/Packets/Packets.hh b/Packets/Packets.hh new file mode 100644 index 0000000..9178325 --- /dev/null +++ b/Packets/Packets.hh @@ -0,0 +1,46 @@ +// Copyright (C) 2007 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Stefan Bund +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief Packets public header */ + +#ifndef HH_Packets_ +#define HH_Packets_ 1 + +#define SENF_PACKETS_DECL_ONLY + +#include "all_includes.hh" + +#undef SENF_PACKETS_DECL_ONLY + +#include "all_includes.hh" + +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/Packets/ParseArray.hh b/Packets/ParseArray.hh index 1e98a71..f0669b3 100644 --- a/Packets/ParseArray.hh +++ b/Packets/ParseArray.hh @@ -62,6 +62,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseArray_i_) +#define HH_ParseArray_i_ //#include "ParseArray.cci" //#include "ParseArray.ct" #include "ParseArray.cti" diff --git a/Packets/ParseArray.test.cc b/Packets/ParseArray.test.cc index 8dc19ae..44b406d 100644 --- a/Packets/ParseArray.test.cc +++ b/Packets/ParseArray.test.cc @@ -26,10 +26,7 @@ //#include "ParseArray.test.ih" // Custom includes -#include "PacketInterpreter.hh" -#include "ParseArray.hh" -#include "ParseInt.hh" -#include "PacketType.hh" +#include "Packets.hh" #include #include diff --git a/Packets/ParseInt.hh b/Packets/ParseInt.hh index 86a3730..865fd56 100644 --- a/Packets/ParseInt.hh +++ b/Packets/ParseInt.hh @@ -259,6 +259,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseInt_i_) +#define HH_ParseInt_i_ //#include "ParseInt.cci" //#include "ParseInt.ct" //#include "ParseInt.cti" diff --git a/Packets/ParseInt.test.cc b/Packets/ParseInt.test.cc index deee2fd..e240e37 100644 --- a/Packets/ParseInt.test.cc +++ b/Packets/ParseInt.test.cc @@ -26,9 +26,7 @@ //#include "ParseInt.test.ih" // Custom includes -#include "ParseInt.hh" -#include "PacketInterpreter.hh" -#include "PacketType.hh" +#include "Packets.hh" #include #include diff --git a/Packets/ParseList.hh b/Packets/ParseList.hh index 4927be2..945f72e 100644 --- a/Packets/ParseList.hh +++ b/Packets/ParseList.hh @@ -316,6 +316,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseList_i_) +#define HH_ParseList_i_ //#include "ParseList.cci" #include "ParseList.ct" #include "ParseList.cti" diff --git a/Packets/ParseList.test.cc b/Packets/ParseList.test.cc index 0bd0ab4..1145af6 100644 --- a/Packets/ParseList.test.cc +++ b/Packets/ParseList.test.cc @@ -25,7 +25,7 @@ //#include "ParseList.test.ih" // Custom includes -#include "ParseList.hh" +#include "Packets.hh" #include #include diff --git a/Packets/ParseListB.hh b/Packets/ParseListB.hh index 7a53c0a..72b5159 100644 --- a/Packets/ParseListB.hh +++ b/Packets/ParseListB.hh @@ -65,6 +65,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseListB_i_) +#define HH_ParseListB_i_ //#include "ParseListB.cci" //#include "ParseListB.ct" #include "ParseListB.cti" diff --git a/Packets/ParseListB.test.cc b/Packets/ParseListB.test.cc index cd433ed..764ab64 100644 --- a/Packets/ParseListB.test.cc +++ b/Packets/ParseListB.test.cc @@ -25,10 +25,7 @@ //#include "ParseListB.test.ih" // Custom includes -#include "ParseListB.hh" -#include "ParseVec.hh" -#include "PacketType.hh" -#include "ParseInt.hh" +#include "Packets.hh" #include #include diff --git a/Packets/ParseListN.hh b/Packets/ParseListN.hh index e3f816b..8dc2243 100644 --- a/Packets/ParseListN.hh +++ b/Packets/ParseListN.hh @@ -43,6 +43,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseListN_i_) +#define HH_ParseListN_i_ //#include "ParseListN.cci" #include "ParseListN.ct" #include "ParseListN.cti" diff --git a/Packets/ParseListN.test.cc b/Packets/ParseListN.test.cc index 84f2ff1..3800a0d 100644 --- a/Packets/ParseListN.test.cc +++ b/Packets/ParseListN.test.cc @@ -25,11 +25,7 @@ //#include "ParseListN.test.ih" // Custom includes -#include "ParseListN.hh" -#include "ParseVec.hh" -#include "ParseInt.hh" -#include "PacketType.hh" -#include "Packet.hh" +#include "Packets.hh" #include #include diff --git a/Packets/ParseVec.hh b/Packets/ParseVec.hh index 21239e8..157b061 100644 --- a/Packets/ParseVec.hh +++ b/Packets/ParseVec.hh @@ -198,6 +198,9 @@ namespace senf { } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseVec_i_) +#define HH_ParseVec_i_ //#include "ParseVec.cci" #include "ParseVec.ct" #include "ParseVec.cti" diff --git a/Packets/ParseVec.test.cc b/Packets/ParseVec.test.cc index 35079a7..078626c 100644 --- a/Packets/ParseVec.test.cc +++ b/Packets/ParseVec.test.cc @@ -26,9 +26,7 @@ //#include "ParseVec.test.ih" // Custom includes -#include "ParseVec.hh" -#include "ParseInt.hh" -#include "PacketType.hh" +#include "Packets.hh" #include #include diff --git a/Packets/SConscript b/Packets/SConscript index 27f0650..153a67c 100644 --- a/Packets/SConscript +++ b/Packets/SConscript @@ -5,10 +5,21 @@ import SENFSCons, glob ########################################################################### +def makeAllIncludesHH(target = None, source = None, env = None): + file(target[0].abspath,"w").write("".join([ '#include "%s"\n' % f + for f in env['SOURCE_HEADERS']])) +makeAllIncludesHH = env.Action(makeAllIncludesHH, varlist=['SOURCE_HEADERS']) + +########################################################################### + sources = SENFSCons.GlobSources() SENFSCons.StandardTargets(env) +env.Command('all_includes.hh', 'SConscript', makeAllIncludesHH, + SOURCE_HEADERS = [ f for f in glob.glob("*.hh") + if 'defined(SENF_PACKETS_DECL_ONLY)' in file(f).read() ]) + SENFSCons.Lib(env, library = 'Packets', sources = sources, diff --git a/Packets/main.test.cc b/Packets/main.test.cc index b759387..c2972fd 100644 --- a/Packets/main.test.cc +++ b/Packets/main.test.cc @@ -29,6 +29,7 @@ #define BOOST_AUTO_TEST_MAIN #include #include +#include "Packets.hh" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// diff --git a/find-sources.sh b/find-sources.sh index b28c390..9cb24ec 100755 --- a/find-sources.sh +++ b/find-sources.sh @@ -17,6 +17,8 @@ if [ "$1" = "-c" ]; then cond='( -name *.h -o -name *.hh -o -name *.ih -o -name *.c -o -name *.cc -o -name *.cci -o -name *.ct -o -name *.cti )' fi +set -f + find . \ -name .svn -prune -o \ -name doc -prune -o \