X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FUDPPacket.hh;h=296597ca7a10956614272d5643b0c9ff39ad17b2;hb=d6abda313f70c8a849c5e3f3bbfc12ce301789f1;hp=1e566a13f3c75e1cdfd064bc5cc205ffc6c405d0;hpb=a2bece00465e874b1a52e98918f64aa24919a009;p=senf.git diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh index 1e566a1..296597c 100644 --- a/Packets/DefaultBundle/UDPPacket.hh +++ b/Packets/DefaultBundle/UDPPacket.hh @@ -43,28 +43,17 @@ namespace senf { */ struct Parse_UDP : public PacketParserBase { - typedef Parse_UInt16 Parse_16bit; +# include SENF_FIXED_PARSER() -# ifndef DOXYGEN + 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_PACKET_PARSER_INIT(Parse_UDP); - - SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS( - ((Field)( source, Parse_16bit )) - ((Field)( destination, Parse_16bit )) - ((Field)( length, Parse_16bit )) - ((Field)( checksum, Parse_16bit )) ); - -# else - - Parse_16bit source(); - Parse_16bit destination(); - Parse_16bit length(); - Parse_16bit checksum(); - -# endif + SENF_PARSER_FINALIZE(Parse_UDP); boost::uint16_t calcChecksum() const; + bool validateChecksum() const { return checksum() == 0u || checksum() == calcChecksum(); }