X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FUDPPacket.hh;h=560c36075c6cd18898fcb78f3d92f103aef89345;hb=81ffa1c459b96dd44472bcef37e1e373934ee138;hp=58b945587adfeb08c0366cf038ea5cc1d15020c7;hpb=31d85cd6b8e03c5ecc924ca8892906be1bab702f;p=senf.git diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh index 58b9455..560c360 100644 --- a/Packets/DefaultBundle/UDPPacket.hh +++ b/Packets/DefaultBundle/UDPPacket.hh @@ -20,73 +20,87 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +/** \file + \brief UDPPacket public header */ + #ifndef HH_UDPPacket_ #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 { - // See RFC768 - template - struct Parse_UDP : public ParserBase + /** \brief Parse a UDP packet + + Parser implementing the UDP header. The fields implemented are: + + \see UDPPacketType + RFC 768 + */ + struct Parse_UDP : public PacketParserBase { - template - struct rebind { typedef Parse_UDP parser; }; - typedef Iterator byte_iterator; + typedef Parse_UInt16 Parse_16bit; - Parse_UDP() {} - Parse_UDP(Iterator const & i) : ParserBase(i) {} +# ifndef DOXYGEN - static unsigned bytes() { return 8; } + SENF_PACKET_PARSER_INIT(Parse_UDP); - /////////////////////////////////////////////////////////////////////////// + SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS( + ((Field)( source, Parse_16bit )) + ((Field)( destination, Parse_16bit )) + ((Field)( length, Parse_16bit )) + ((Field)( crc, Parse_16bit )) ); - typedef Parse_UInt16 < Iterator > Parse_16bit; +# else - 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 ); } + Parse_16bit source(); + Parse_16bit destination(); + Parse_16bit length(); + Parse_16bit crc(); +# endif }; - class UDPPacket - : public Packet, - public Parse_UDP - { - public: - /////////////////////////////////////////////////////////////////////////// - // Types - - typedef ptr_t::ptr ptr; + /** \brief UDP packet + + \par Packet type (typedef): + \ref UDPPacket - /////////////////////////////////////////////////////////////////////////// + \par Fields: + \ref Parse_UDP - private: - template - UDPPacket(Arg const & arg); + \ingroup protocolbundle_default + */ + struct UDPPacketType + : public PacketTypeBase, + public PacketTypeMixin + { + typedef PacketTypeMixin mixin; + typedef ConcretePacket packet; + typedef Parse_UDP parser; - virtual void v_nextInterpreter() const; - virtual void v_finalize(); - virtual void v_dump(std::ostream & os) const; + using mixin::nextPacketRange; + using mixin::initSize; + using mixin::init; - friend class Packet; + static void dump(packet p, std::ostream & os); }; + + /** \brief UDP packet typedef */ + typedef UDPPacketType::packet UDPPacket; } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#ifndef SENF_PACKETS_DECL_ONLY //#include UDPPacket.cci" //#include "UDPPacket.ct" -#include "UDPPacket.cti" +//#include "UDPPacket.cti" #endif @@ -97,4 +111,5 @@ namespace senf { // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" +// comment-column: 40 // End: