X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FUDPPacket.hh;h=296597ca7a10956614272d5643b0c9ff39ad17b2;hb=d6abda313f70c8a849c5e3f3bbfc12ce301789f1;hp=bc3ab1d6df0f252d5edf4bc2237837c8bf5c1b26;hpb=2d6585ff852e9d282c17003ba1db0b73eb3a8500;p=senf.git
diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh
index bc3ab1d..296597c 100644
--- a/Packets/DefaultBundle/UDPPacket.hh
+++ b/Packets/DefaultBundle/UDPPacket.hh
@@ -20,36 +20,55 @@
// 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/Packets.hh"
+#include "../../Packets/Packets.hh"
//#include "UDPPacket.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
- ///\addtogroup protocolbundle_default
- ///@{
+ /** \brief Parse a UDP packet
+
+ Parser implementing the UDP header. The fields implemented are:
- // See RFC768
+ \see UDPPacketType
+ RFC 768
+ */
struct Parse_UDP : public PacketParserBase
{
- SENF_PACKET_PARSER_INIT(Parse_UDP);
+# include SENF_FIXED_PARSER()
- ///////////////////////////////////////////////////////////////////////////
+ SENF_PARSER_FIELD( source, senf::Parse_UInt16 );
+ SENF_PARSER_FIELD( destination, senf::Parse_UInt16 );
+ SENF_PARSER_FIELD( length, senf::Parse_UInt16 );
+ SENF_PARSER_FIELD( checksum, senf::Parse_UInt16 );
- typedef Parse_UInt16 Parse_16bit;
+ SENF_PARSER_FINALIZE(Parse_UDP);
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field)( source, Parse_16bit ))
- ((Field)( destination, Parse_16bit ))
- ((Field)( length, Parse_16bit ))
- ((Field)( crc, Parse_16bit )) );
+ boost::uint16_t calcChecksum() const;
+
+ bool validateChecksum() const {
+ return checksum() == 0u || checksum() == calcChecksum();
+ }
};
+ /** \brief UDP packet
+
+ \par Packet type (typedef):
+ \ref UDPPacket
+
+ \par Fields:
+ \ref Parse_UDP
+
+ \ingroup protocolbundle_default
+ */
struct UDPPacketType
: public PacketTypeBase,
public PacketTypeMixin
@@ -63,11 +82,12 @@ namespace senf {
using mixin::init;
static void dump(packet p, std::ostream & os);
+
+ static void finalize(packet p);
};
+ /** \brief UDP packet typedef */
typedef UDPPacketType::packet UDPPacket;
-
- ///@}
}