X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketParser.hh;h=2b73860b2c32f9385fe8ffcc0dd1685b23f1638c;hb=21bad90912447cd2d390112cf2d2a7d383ad8058;hp=9a3305b698b174dfa336dc39b1f7bee3f5853931;hpb=32573fc81844083b2aa02d3d224e4cb327de0d9d;p=senf.git diff --git a/Packets/PacketParser.hh b/Packets/PacketParser.hh index 9a3305b..2b73860 100644 --- a/Packets/PacketParser.hh +++ b/Packets/PacketParser.hh @@ -161,7 +161,7 @@ namespace senf { /** \brief Parser Base class - Parsers come in two favors: fixed and dynamically sized parsers. A fixed size + Parsers come in two flavors: fixed and dynamically sized parsers. A fixed size parser has a constant size, it will always parse a fixed number of bytes. The low-level 'final' parsers (like the integer parsers) are fixed size parsers as are composite parsers built up only of fixed-size fields. @@ -413,10 +413,24 @@ namespace senf { using these macros has the following form (This is a concrete example from the definition of the ethernet packet in DefaultBundle/EthernetPacket.hh) - \dontinclude EthernetPacket.hh - \skipline struct Parse_EthVLan : public PacketParserBase - \until }; - + \code + struct Parse_EthVLan : public PacketParserBase + { + typedef Parse_UIntField < 0, 3 > Parse_Priority; + typedef Parse_Flag < 3 > Parse_CFI; + typedef Parse_UIntField < 4, 16 > Parse_VLanId; + typedef Parse_UInt16 Parse_Type; + + SENF_PACKET_PARSER_INIT(Parse_EthVLan); + + SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS( + ((OverlayField)( priority, Parse_Priority )) + ((OverlayField)( cfi, Parse_CFI )) + ((Field )( vlanId, Parse_VLanId )) + ((Field )( type, Parse_Type )) ); + }; + \endcode + The macros take care of the following: \li They define the accessor functions returning parsers of the given type. \li They automatically calculate the offset of the fields from the preceding fields.