X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FUDPPacket.hh;h=2c662d336373d34d91f106b4eabf3cd2e48eb162;hb=6a3a31fb7b2d2a5e8ae6d67d50797700274fb34e;hp=26485486fa8fc987c2aa1b9c38030c9043ebca46;hpb=64e170521a221effc1ba11a0544f753544d03bac;p=senf.git
diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh
index 2648548..2c662d3 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)
@@ -20,61 +20,85 @@
// 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/PacketType.hh"
-#include "Packets/ParseInt.hh"
-#include "Packets/PacketRegistry.hh"
-#include "Packets/PacketParser.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 );
- ///////////////////////////////////////////////////////////////////////////
+ SENF_PARSER_FINALIZE(Parse_UDP);
- typedef Parse_UInt16 Parse_16bit;
+ boost::uint16_t calcChecksum() const;
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field)( source, Parse_16bit ))
- ((Field)( destination, Parse_16bit ))
- ((Field)( length, Parse_16bit ))
- ((Field)( crc, Parse_16bit )) );
+ bool validateChecksum() const {
+ return checksum() == 0u || checksum() == calcChecksum();
+ }
};
+ /** \brief UDP packet
+
+ \par Packet type (typedef):
+ \ref UDPPacket
+
+ \par Fields:
+ \ref Parse_UDP
+
+ \par Finalize action:
+ Set \a length from payload size\n
+ Calculate \a checksum
+
+ \ingroup protocolbundle_default
+ */
struct UDPPacketType
: public PacketTypeBase,
public PacketTypeMixin
{
+#ifndef DOXYGEN
typedef PacketTypeMixin mixin;
typedef ConcretePacket packet;
typedef Parse_UDP parser;
-
+#endif
using mixin::nextPacketRange;
using mixin::initSize;
using mixin::init;
static void dump(packet p, std::ostream & os);
- };
- typedef UDPPacketType::packet UDPPacket;
+ static void finalize(packet p);
+ };
- ///@}
+ /** \brief UDP packet typedef */
+ typedef ConcretePacket UDPPacket;
}
///////////////////////////////hh.e////////////////////////////////////////
+#endif
+#ifndef SENF_PACKETS_DECL_ONLY
//#include UDPPacket.cci"
//#include "UDPPacket.ct"
//#include "UDPPacket.cti"