senfscons: Fix 'Object' build helper to work with empty source list in SCons 0.96.1
[senf.git] / Packets / DefaultBundle / UDPPacket.hh
index 615c530..1e566a1 100644 (file)
 // 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////////////////////////////////////////
@@ -35,30 +38,36 @@ namespace senf {
 
         Parser implementing the UDP header. The fields implemented are:
 
-        <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 Parse_16bit;
 
-        ///////////////////////////////////////////////////////////////////////////
+#       ifndef DOXYGEN
 
-        typedef Parse_UInt16 Parse_16bit;
+        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 )) );
+            ((Field)( checksum,    Parse_16bit )) );
+
+#       else
+
+        Parse_16bit source();
+        Parse_16bit destination();
+        Parse_16bit length();
+        Parse_16bit checksum();
+
+#       endif
+
+        boost::uint16_t calcChecksum() const;
+        bool validateChecksum() const {
+            return checksum() == 0u || checksum() == calcChecksum();
+        }
     };
 
     /** \brief UDP packet
@@ -84,6 +93,8 @@ namespace senf {
         using mixin::init;
 
         static void dump(packet p, std::ostream & os);
+
+        static void finalize(packet p);
     };
 
     /** \brief UDP packet typedef */