#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 <class Iterator=nil, class IPacket=nil>
- struct Parse_UDP : public ParserBase<Iterator,IPacket>
- {
- template <class I, class P=nil>
- struct rebind { typedef Parse_UDP<I,P> parser; };
- typedef Iterator byte_iterator;
+ /** \brief Parse a UDP packet
- Parse_UDP() {}
- Parse_UDP(Iterator const & i) : ParserBase<Iterator,IPacket>(i) {}
+ Parser implementing the UDP header. The fields implemented are:
- static unsigned bytes() { return 8; }
+ <table class="senf">
+ <tr><th>Field name</th><th>Parser type</th></tr>
+ <tr><td>source</td><td>\ref Parse_16bit</td></tr>
+ <tr><td>destination</td><td>\ref Parse_16bit</td></tr>
+ <tr><td>length</td><td>\ref Parse_16bit</td></tr>
+ <tr><td>crc</td><td>\ref Parse_16bit</td></tr>
+ </table>
- ///////////////////////////////////////////////////////////////////////////
+ \see UDPPacketType
+ <a href="http://tools.ietf.org/html/rfc768">RFC 768</a>
+ */
+ struct Parse_UDP : public PacketParserBase
+ {
+ 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<Packet::iterator, UDPPacket>
- {
- public:
- ///////////////////////////////////////////////////////////////////////////
- // Types
+ /** \brief UDP packet
+
+ \par Packet type (typedef):
+ \ref UDPPacket
- typedef ptr_t<UDPPacket>::ptr ptr;
+ \par Fields:
+ \ref Parse_UDP
- ///////////////////////////////////////////////////////////////////////////
-
- private:
- template <class Arg>
- UDPPacket(Arg const & arg);
+ \ingroup protocolbundle_default
+ */
+ struct UDPPacketType
+ : public PacketTypeBase,
+ public PacketTypeMixin<UDPPacketType>
+ {
+ typedef PacketTypeMixin<UDPPacketType> mixin;
+ typedef ConcretePacket<UDPPacketType> 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
\f
// indent-tabs-mode: nil
// ispell-local-dictionary: "american"
// compile-command: "scons -u test"
+// comment-column: 40
// End: