X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FUDPPacket.hh;h=bc3ab1d6df0f252d5edf4bc2237837c8bf5c1b26;hb=d084c02e4914da4fa1a4098a33d704f69e8bdedd;hp=2935f409fa6505137b0004d4ec7e92b8b5547ed8;hpb=145f6a7d0f3a6aaa77b3625351c952d24cb0b8a1;p=senf.git diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh index 2935f40..bc3ab1d 100644 --- a/Packets/DefaultBundle/UDPPacket.hh +++ b/Packets/DefaultBundle/UDPPacket.hh @@ -24,69 +24,59 @@ #define HH_UDPPacket_ 1 // Custom includes -#include "Packets/Packet.hh" -#include "Packets/ParseInt.hh" -#include "Packets/ParseArray.hh" -#include "Packets/PacketRegistry.hh" +#include "Packets/Packets.hh" //#include "UDPPacket.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { + ///\addtogroup protocolbundle_default + ///@{ + // See RFC768 - template - struct Parse_UDP : public ParserBase + struct Parse_UDP : public PacketParserBase { - template - struct rebind { typedef Parse_UDP parser; }; - typedef Iterator byte_iterator; - - Parse_UDP() {} - Parse_UDP(Iterator const & i) : ParserBase(i) {} - - static unsigned bytes() { return 8; } + SENF_PACKET_PARSER_INIT(Parse_UDP); /////////////////////////////////////////////////////////////////////////// - typedef Parse_UInt16 < Iterator > Parse_16bit; - - Parse_16bit source() const { return Parse_16bit (this->i() ); } - Parse_16bit destination() const { return Parse_16bit (this->i() + 2 ); } - Parse_16bit length() const { return Parse_16bit (this->i() + 4 ); } - Parse_16bit crc() const { return Parse_16bit (this->i() + 6 ); } + typedef Parse_UInt16 Parse_16bit; + SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS( + ((Field)( source, Parse_16bit )) + ((Field)( destination, Parse_16bit )) + ((Field)( length, Parse_16bit )) + ((Field)( crc, Parse_16bit )) ); }; - class UDPPacket - : public Packet, - public Parse_UDP + struct UDPPacketType + : public PacketTypeBase, + public PacketTypeMixin { - public: - /////////////////////////////////////////////////////////////////////////// - // Types + typedef PacketTypeMixin mixin; + typedef ConcretePacket packet; + typedef Parse_UDP parser; - typedef ptr_t::ptr ptr; + using mixin::nextPacketRange; + using mixin::initSize; + using mixin::init; - /////////////////////////////////////////////////////////////////////////// - - private: - template - UDPPacket(Arg const & arg); + static void dump(packet p, std::ostream & os); + }; - virtual void v_nextInterpreter() const; - virtual void v_finalize(); - virtual void v_dump(std::ostream & os) const; + typedef UDPPacketType::packet UDPPacket; - friend class Packet; - }; + ///@} } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#ifndef SENF_PACKETS_DECL_ONLY //#include UDPPacket.cci" //#include "UDPPacket.ct" -#include "UDPPacket.cti" +//#include "UDPPacket.cti" #endif