From: g0dil Date: Tue, 16 Oct 2007 14:33:04 +0000 (+0000) Subject: Packets: Add parse helper SENF_PARSER_SKIP_BITS X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=ab243554f940af9f873e1a920d0a6b7886c6f5cf;p=senf.git Packets: Add parse helper SENF_PARSER_SKIP_BITS Packets: Add parse helpers for private fields Packets: Rename all SENF_PARSE_ parse helpers to SENF_PARSER_ Packets/MPEGDVBBundle: Fix parsers to make use of the new parse helper features Add additional Doxygen predefined macros to correctly parse the packet parse helper macros git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@465 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/DefaultBundle/EthernetPacket.hh b/Packets/DefaultBundle/EthernetPacket.hh index 04516db..78fd671 100644 --- a/Packets/DefaultBundle/EthernetPacket.hh +++ b/Packets/DefaultBundle/EthernetPacket.hh @@ -70,9 +70,9 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSE_FIELD( destination, Parse_MAC ); - SENF_PARSE_FIELD( source, Parse_MAC ); - SENF_PARSE_FIELD( type, Parse_UInt16 ); + SENF_PARSER_FIELD( destination, Parse_MAC ); + SENF_PARSER_FIELD( source, Parse_MAC ); + SENF_PARSER_FIELD( type, Parse_UInt16 ); SENF_PARSER_FINALIZE(Parse_Ethernet); }; @@ -137,11 +137,11 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSE_BITFIELD( priority, 3, unsigned ); - SENF_PARSE_BITFIELD( cfi, 1, bool ); - SENF_PARSE_BITFIELD( vlanId, 12, unsigned ); + SENF_PARSER_BITFIELD( priority, 3, unsigned ); + SENF_PARSER_BITFIELD( cfi, 1, bool ); + SENF_PARSER_BITFIELD( vlanId, 12, unsigned ); - SENF_PARSE_FIELD( type, Parse_UInt16 ); + SENF_PARSER_FIELD( type, Parse_UInt16 ); SENF_PARSER_FINALIZE(Parse_EthVLan); }; diff --git a/Packets/DefaultBundle/IpV4Packet.hh b/Packets/DefaultBundle/IpV4Packet.hh index f293909..bbc884c 100644 --- a/Packets/DefaultBundle/IpV4Packet.hh +++ b/Packets/DefaultBundle/IpV4Packet.hh @@ -69,23 +69,23 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSE_BITFIELD( version, 4, unsigned ); - SENF_PARSE_BITFIELD( ihl, 4, unsigned ); - - SENF_PARSE_FIELD( tos, Parse_UInt8 ); - SENF_PARSE_FIELD( length, Parse_UInt16 ); - SENF_PARSE_FIELD( identifier, Parse_UInt16 ); - - SENF_PARSE_BITFIELD( reserved, 1, bool ); - SENF_PARSE_BITFIELD( df, 1, bool ); - SENF_PARSE_BITFIELD( mf, 1, bool ); - SENF_PARSE_BITFIELD( frag, 13, unsigned ); - - SENF_PARSE_FIELD( ttl, Parse_UInt8 ); - SENF_PARSE_FIELD( protocol, Parse_UInt8 ); - SENF_PARSE_FIELD( checksum, Parse_UInt16 ); - SENF_PARSE_FIELD( source, Parse_INet4Address ); - SENF_PARSE_FIELD( destination, Parse_INet4Address ); + SENF_PARSER_BITFIELD( version, 4, unsigned ); + SENF_PARSER_BITFIELD( ihl, 4, unsigned ); + + SENF_PARSER_FIELD( tos, Parse_UInt8 ); + SENF_PARSER_FIELD( length, Parse_UInt16 ); + SENF_PARSER_FIELD( identifier, Parse_UInt16 ); + + SENF_PARSER_BITFIELD( reserved, 1, bool ); + SENF_PARSER_BITFIELD( df, 1, bool ); + SENF_PARSER_BITFIELD( mf, 1, bool ); + SENF_PARSER_BITFIELD( frag, 13, unsigned ); + + SENF_PARSER_FIELD( ttl, Parse_UInt8 ); + SENF_PARSER_FIELD( protocol, Parse_UInt8 ); + SENF_PARSER_FIELD( checksum, Parse_UInt16 ); + SENF_PARSER_FIELD( source, Parse_INet4Address ); + SENF_PARSER_FIELD( destination, Parse_INet4Address ); SENF_PARSER_INIT() { version() = 4; diff --git a/Packets/DefaultBundle/IpV6Extensions.hh b/Packets/DefaultBundle/IpV6Extensions.hh index e04c6bb..bc4ba89 100644 --- a/Packets/DefaultBundle/IpV6Extensions.hh +++ b/Packets/DefaultBundle/IpV6Extensions.hh @@ -43,14 +43,14 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSE_FIELD( nextHeader , Parse_UInt8 ); - SENF_PARSE_FIELD( reserved1 , Parse_UInt8 ); + SENF_PARSER_FIELD( nextHeader , Parse_UInt8 ); + SENF_PARSER_FIELD( reserved1 , Parse_UInt8 ); - SENF_PARSE_BITFIELD( fragmentOffset, 13, unsigned ); - SENF_PARSE_BITFIELD( reserved2, 2, unsigned ); - SENF_PARSE_BITFIELD( moreFragments, 1, bool ); + SENF_PARSER_BITFIELD( fragmentOffset, 13, unsigned ); + SENF_PARSER_BITFIELD( reserved2, 2, unsigned ); + SENF_PARSER_BITFIELD( moreFragments, 1, bool ); - SENF_PARSE_FIELD( id , Parse_UInt32 ); + SENF_PARSER_FIELD( id , Parse_UInt32 ); SENF_PARSER_FINALIZE(Parse_IpV6Extension_Fragment); }; diff --git a/Packets/DefaultBundle/IpV6Packet.hh b/Packets/DefaultBundle/IpV6Packet.hh index 646dd1c..cb073e8 100644 --- a/Packets/DefaultBundle/IpV6Packet.hh +++ b/Packets/DefaultBundle/IpV6Packet.hh @@ -64,15 +64,15 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSE_BITFIELD( version, 4, unsigned ); - SENF_PARSE_BITFIELD( trafficClass, 8, unsigned ); - SENF_PARSE_BITFIELD( flowLabel, 20, unsigned ); - - SENF_PARSE_FIELD( length, Parse_UInt16 ); - SENF_PARSE_FIELD( nextHeader, Parse_UInt8 ); - SENF_PARSE_FIELD( hopLimit, Parse_UInt8 ); - SENF_PARSE_FIELD( source, Parse_INet6Address ); - SENF_PARSE_FIELD( destination, Parse_INet6Address ); + SENF_PARSER_BITFIELD( version, 4, unsigned ); + SENF_PARSER_BITFIELD( trafficClass, 8, unsigned ); + SENF_PARSER_BITFIELD( flowLabel, 20, unsigned ); + + SENF_PARSER_FIELD( length, Parse_UInt16 ); + SENF_PARSER_FIELD( nextHeader, Parse_UInt8 ); + SENF_PARSER_FIELD( hopLimit, Parse_UInt8 ); + SENF_PARSER_FIELD( source, Parse_INet6Address ); + SENF_PARSER_FIELD( destination, Parse_INet6Address ); SENF_PARSER_INIT() { version() = 6; diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh index f881497..296597c 100644 --- a/Packets/DefaultBundle/UDPPacket.hh +++ b/Packets/DefaultBundle/UDPPacket.hh @@ -45,10 +45,10 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSE_FIELD( source, senf::Parse_UInt16 ); - SENF_PARSE_FIELD( destination, senf::Parse_UInt16 ); - SENF_PARSE_FIELD( length, senf::Parse_UInt16 ); - SENF_PARSE_FIELD( checksum, senf::Parse_UInt16 ); + 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); diff --git a/Packets/MPEGDVBBundle/DSMCCSection.cc b/Packets/MPEGDVBBundle/DSMCCSection.cc index 689d4d1..d0c8b34 100644 --- a/Packets/MPEGDVBBundle/DSMCCSection.cc +++ b/Packets/MPEGDVBBundle/DSMCCSection.cc @@ -45,12 +45,10 @@ prefix_ void senf::DSMCCSectionType::dump(packet p, std::ostream & os) << " table_id: 0x" << unsigned(p->table_id()) << "\n" << " section_syntax_indicator: " << p->ssi() << "\n" << " private_indicator: " << p->private_indicator() << "\n" - << " reserved_1: " << p->reserved_1() << "\n" << std::dec << " section_length: " << p->sec_length() << "\n" << std::hex << " table_id_extension: " << p->table_id_extension() << "\n" - << " reserved_2: " << p->reserved_2() << "\n" << " version_number: " << p->version_num() << "\n" << " current_next_indicator: " << p->curr_next_indicator() << "\n" << " section_number: " << unsigned(p->sec_num()) << "\n" diff --git a/Packets/MPEGDVBBundle/DSMCCSection.hh b/Packets/MPEGDVBBundle/DSMCCSection.hh index e0881f9..922c871 100644 --- a/Packets/MPEGDVBBundle/DSMCCSection.hh +++ b/Packets/MPEGDVBBundle/DSMCCSection.hh @@ -45,23 +45,23 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSE_FIELD( table_id, Parse_UInt8 ); + SENF_PARSER_FIELD ( table_id , Parse_UInt8 ); - SENF_PARSE_BITFIELD( ssi, 1, bool ); - SENF_PARSE_BITFIELD( private_indicator, 1, bool ); - SENF_PARSE_BITFIELD( reserved_1, 2, unsigned ); - SENF_PARSE_BITFIELD( sec_length, 12, unsigned ); - - SENF_PARSE_FIELD( table_id_extension, Parse_UInt16 ); - - SENF_PARSE_BITFIELD( reserved_2, 2, unsigned ); - SENF_PARSE_BITFIELD( version_num, 5, unsigned ); - SENF_PARSE_BITFIELD( curr_next_indicator, 1, bool ); + SENF_PARSER_BITFIELD ( ssi , 1 , bool ); + SENF_PARSER_BITFIELD ( private_indicator , 1 , bool ); + SENF_PARSER_SKIP_BITS( 2 ); + SENF_PARSER_BITFIELD ( sec_length , 12 , unsigned ); + + SENF_PARSER_FIELD ( table_id_extension , Parse_UInt16 ); + + SENF_PARSER_SKIP_BITS( 2 ); + SENF_PARSER_BITFIELD ( version_num , 5 , unsigned ); + SENF_PARSER_BITFIELD ( curr_next_indicator , 1 , bool ); - SENF_PARSE_FIELD( sec_num, Parse_UInt8 ); - SENF_PARSE_FIELD( last_sec_num, Parse_UInt8 ); + SENF_PARSER_FIELD ( sec_num , Parse_UInt8 ); + SENF_PARSER_FIELD ( last_sec_num , Parse_UInt8 ); - SENF_PARSER_FINALIZE(Parse_DSMCCSection); + SENF_PARSER_FINALIZE( Parse_DSMCCSection ); Parse_UInt32 crc() const { return parse( data().size()-4 ); } }; diff --git a/Packets/MPEGDVBBundle/DatagramSection.cc b/Packets/MPEGDVBBundle/DatagramSection.cc index a03c96a..e34c3c3 100644 --- a/Packets/MPEGDVBBundle/DatagramSection.cc +++ b/Packets/MPEGDVBBundle/DatagramSection.cc @@ -45,13 +45,11 @@ prefix_ void senf::DatagramSectionType::dump(packet p, std::ostream & os) << " table_id: 0x" << unsigned(p->table_id()) << "\n" << " section_syntax_indicator: " << p->ssi() << "\n" << " private_indicator: " << p->private_indicator() << "\n" - << " reserved_1: " << p->reserved_1() << "\n" << std::dec << " section_length: " << p->sec_length() << "\n" << std::hex << " MAC_address_6: " << unsigned(p->mac_addr_6()) << "\n" << " MAC_address_5: " << unsigned(p->mac_addr_5()) << "\n" - << " reserved_2: " << p->reserved_2() << "\n" << " payload_scrambling_control: " << p->payload_scrmbl_ctrl() << "\n" << " address_scrambling_control: " << p-> addr_scrmbl_ctrl() << "\n" << " LLC_SNAP_flag: " << p->llc_snap_flag() << "\n" diff --git a/Packets/MPEGDVBBundle/DatagramSection.hh b/Packets/MPEGDVBBundle/DatagramSection.hh index 9873b03..bf5d87a 100644 --- a/Packets/MPEGDVBBundle/DatagramSection.hh +++ b/Packets/MPEGDVBBundle/DatagramSection.hh @@ -47,33 +47,25 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSER_INHERIT(Parse_DSMCCSection); + SENF_PARSER_INHERIT( Parse_DSMCCSection ); - SENF_PARSE_FIELD( mac_addr_4, Parse_UInt8 ); - SENF_PARSE_FIELD( mac_addr_3, Parse_UInt8 ); - SENF_PARSE_FIELD( mac_addr_2, Parse_UInt8 ); - SENF_PARSE_FIELD( mac_addr_1, Parse_UInt8 ); + SENF_PARSER_FIELD ( mac_addr_4 , Parse_UInt8 ); + SENF_PARSER_FIELD ( mac_addr_3 , Parse_UInt8 ); + SENF_PARSER_FIELD ( mac_addr_2 , Parse_UInt8 ); + SENF_PARSER_FIELD ( mac_addr_1 , Parse_UInt8 ); - SENF_PARSER_FINALIZE(Parse_DatagramSection); + SENF_PARSER_FINALIZE( Parse_DatagramSection ); - typedef Parse_UIntField < 2, 4 > Parse_payload_scrmbl_ctrl; - typedef Parse_UIntField < 4, 6 > Parse_addr_scrmbl_ctrl; - typedef Parse_Flag < 6 > Parse_llc_snap_flag; + // Parse table_id_extension as two bytes + SENF_PARSER_GOTO( table_id_extension ); + SENF_PARSER_FIELD ( mac_addr_6 , Parse_UInt8 ); + SENF_PARSER_FIELD ( mac_addr_5 , Parse_UInt8 ); - Parse_UInt8 mac_addr_6() const { return parse( 3 ); } - Parse_UInt8 mac_addr_5() const { return parse( 4 ); } - - Parse_payload_scrmbl_ctrl payload_scrmbl_ctrl() const { - return parse( 5 ); - } - - Parse_addr_scrmbl_ctrl addr_scrmbl_ctrl() const { - return parse( 5 ); - } - - Parse_llc_snap_flag llc_snap_flag() const { - return parse( 5 ); - } + // Divide 5 bit version_num field into several subfields. + SENF_PARSER_SKIP_BITS( 2 ); + SENF_PARSER_BITFIELD ( payload_scrmbl_ctrl , 2, unsigned ); + SENF_PARSER_BITFIELD ( addr_scrmbl_ctrl , 2, unsigned ); + SENF_PARSER_BITFIELD ( llc_snap_flag , 1, bool ); }; /** \brief Datagram Section diff --git a/Packets/MPEGDVBBundle/TLVPacket.hh b/Packets/MPEGDVBBundle/TLVPacket.hh index 5f43f8b..f81eafd 100644 --- a/Packets/MPEGDVBBundle/TLVPacket.hh +++ b/Packets/MPEGDVBBundle/TLVPacket.hh @@ -88,8 +88,8 @@ namespace senf { { # include SENF_PARSER() - SENF_PARSE_FIELD( type, Parse_UInt32 ); - SENF_PARSE_FIELD( length, Parse_TLVPacketLength ); + SENF_PARSER_FIELD( type, Parse_UInt32 ); + SENF_PARSER_FIELD( length, Parse_TLVPacketLength ); SENF_PARSER_FINALIZE(Parse_TLVPacket); }; diff --git a/Packets/MPEGDVBBundle/TransportPacket.hh b/Packets/MPEGDVBBundle/TransportPacket.hh index 6aac38c..7f21415 100644 --- a/Packets/MPEGDVBBundle/TransportPacket.hh +++ b/Packets/MPEGDVBBundle/TransportPacket.hh @@ -45,15 +45,15 @@ namespace senf { { # include SENF_FIXED_PARSER() - SENF_PARSE_FIELD( sync_byte, Parse_UInt8 ); + SENF_PARSER_FIELD( sync_byte, Parse_UInt8 ); - SENF_PARSE_BITFIELD( transport_error_indicator, 1, bool ); - SENF_PARSE_BITFIELD( pusi, 1, bool ); - SENF_PARSE_BITFIELD( transport_priority, 1, bool ); - SENF_PARSE_BITFIELD( pid, 13, unsigned ); - SENF_PARSE_BITFIELD( transport_scrmbl_ctrl, 2, unsigned ); - SENF_PARSE_BITFIELD( adaptation_field_ctrl, 2, unsigned ); - SENF_PARSE_BITFIELD( continuity_counter, 4, unsigned ); + SENF_PARSER_BITFIELD( transport_error_indicator, 1, bool ); + SENF_PARSER_BITFIELD( pusi, 1, bool ); + SENF_PARSER_BITFIELD( transport_priority, 1, bool ); + SENF_PARSER_BITFIELD( pid, 13, unsigned ); + SENF_PARSER_BITFIELD( transport_scrmbl_ctrl, 2, unsigned ); + SENF_PARSER_BITFIELD( adaptation_field_ctrl, 2, unsigned ); + SENF_PARSER_BITFIELD( continuity_counter, 4, unsigned ); SENF_PARSER_FINALIZE( Parse_TransportPacket ); diff --git a/Packets/Packet.test.cc b/Packets/Packet.test.cc index 88208f4..baa89f0 100644 --- a/Packets/Packet.test.cc +++ b/Packets/Packet.test.cc @@ -57,9 +57,9 @@ namespace { { # include SENF_FIXED_PARSER() - SENF_PARSE_FIELD( type, senf::Parse_UInt16 ); - SENF_PARSE_FIELD( length, senf::Parse_Int32 ); - SENF_PARSE_FIELD( reserved, senf::Parse_UInt16 ); + SENF_PARSER_FIELD( type, senf::Parse_UInt16 ); + SENF_PARSER_FIELD( length, senf::Parse_Int32 ); + SENF_PARSER_FIELD( reserved, senf::Parse_UInt16 ); SENF_PARSER_FINALIZE(BarPacketParser); }; diff --git a/Packets/PacketParser.test.cc b/Packets/PacketParser.test.cc index bde87e1..8be0524 100644 --- a/Packets/PacketParser.test.cc +++ b/Packets/PacketParser.test.cc @@ -49,8 +49,8 @@ namespace { { # include SENF_FIXED_PARSER() - SENF_PARSE_FIELD( name, senf::Parse_UInt16 ); - SENF_PARSE_FIELD( id, senf::Parse_Int32 ); + SENF_PARSER_FIELD( name, senf::Parse_UInt16 ); + SENF_PARSER_FIELD( id, senf::Parse_Int32 ); SENF_PARSER_FINALIZE(FooParser); }; @@ -59,8 +59,8 @@ namespace { { # include SENF_PARSER() - SENF_PARSE_FIELD( name, senf::Parse_UInt16 ); - SENF_PARSE_FIELD( id, senf::Parse_Int32 ); + SENF_PARSER_FIELD( name, senf::Parse_UInt16 ); + SENF_PARSER_FIELD( id, senf::Parse_Int32 ); SENF_PARSER_FINALIZE(BarParser); }; diff --git a/Packets/ParseArray.test.cc b/Packets/ParseArray.test.cc index 0ced2cf..350d7d5 100644 --- a/Packets/ParseArray.test.cc +++ b/Packets/ParseArray.test.cc @@ -44,8 +44,8 @@ namespace { typedef senf::Parse_Array<2,senf::Parse_UInt24> Parse_Array2; - SENF_PARSE_FIELD( array, Parse_Array2 ); - SENF_PARSE_FIELD( index, senf::Parse_UInt16 ); + SENF_PARSER_FIELD( array, Parse_Array2 ); + SENF_PARSER_FIELD( index, senf::Parse_UInt16 ); SENF_PARSER_FINALIZE(SomePacketParser); }; @@ -56,7 +56,7 @@ namespace { typedef senf::Parse_Array<1,SomePacketParser> Parse_Array1; - SENF_PARSE_FIELD( fields, Parse_Array1 ); + SENF_PARSER_FIELD( fields, Parse_Array1 ); SENF_PARSER_FINALIZE(SomeOtherParser); }; diff --git a/Packets/ParseHelpers.hh b/Packets/ParseHelpers.hh index 46bb7b5..b4eb6c4 100644 --- a/Packets/ParseHelpers.hh +++ b/Packets/ParseHelpers.hh @@ -151,13 +151,19 @@ #define SENF_PARSER_INHERIT BOOST_PP_CAT( SENF_PARSER_INHERIT_ , SENF_PARSER_TYPE ) -#define SENF_PARSE_FIELD BOOST_PP_CAT( SENF_PARSE_FIELD_ , SENF_PARSER_TYPE ) -#define SENF_PARSE_FIELD_RO BOOST_PP_CAT( SENF_PARSE_FIELD_RO_ , SENF_PARSER_TYPE ) -#define SENF_PARSE_CUSTOM_FIELD BOOST_PP_CAT( SENF_PARSE_CUSTOM_FIELD_ , SENF_PARSER_TYPE ) -#define SENF_PARSE_BITFIELD BOOST_PP_CAT( SENF_PARSE_BITFIELD_ , SENF_PARSER_TYPE ) -#define SENF_PARSE_BITFIELD_RO BOOST_PP_CAT( SENF_PARSE_BITFIELD_RO_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_FIELD BOOST_PP_CAT( SENF_PARSER_FIELD_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_FIELD_RO BOOST_PP_CAT( SENF_PARSER_FIELD_RO_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_BITFIELD BOOST_PP_CAT( SENF_PARSER_BITFIELD_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_BITFIELD_RO BOOST_PP_CAT( SENF_PARSER_BITFIELD_RO_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_CUSTOM_FIELD BOOST_PP_CAT( SENF_PARSER_CUSTOM_FIELD_ , SENF_PARSER_TYPE ) + +#define SENF_PARSER_PRIVATE_FIELD BOOST_PP_CAT( SENF_PARSER_P_FIELD_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_PRIVATE_FIELD_RO BOOST_PP_CAT( SENF_PARSER_P_FIELD_RO_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_PRIVATE_BITFIELD BOOST_PP_CAT( SENF_PARSER_P_BITFIELD_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_PRIVATE_BITFIELD_RO BOOST_PP_CAT( SENF_PARSER_P_BITFIELD_RO_ , SENF_PARSER_TYPE ) #define SENF_PARSER_SKIP BOOST_PP_CAT( SENF_PARSER_SKIP_ , SENF_PARSER_TYPE ) +#define SENF_PARSER_SKIP_BITS BOOST_PP_CAT( SENF_PARSER_SKIP_BITS_ , SENF_PARSER_TYPE ) #define SENF_PARSER_GOTO BOOST_PP_CAT( SENF_PARSER_GOTO_ , SENF_PARSER_TYPE ) #define SENF_PARSER_GOTO_OFFSET BOOST_PP_CAT( SENF_PARSER_GOTO_OFFSET_ , SENF_PARSER_TYPE ) #define SENF_PARSER_LABEL BOOST_PP_CAT( SENF_PARSER_LABEL_ , SENF_PARSER_TYPE ) diff --git a/Packets/ParseHelpers.ih b/Packets/ParseHelpers.ih index 4b381e1..dc1191c 100644 --- a/Packets/ParseHelpers.ih +++ b/Packets/ParseHelpers.ih @@ -81,13 +81,18 @@ public: # # /////////////////////////////////////////////////////////////////////////// -# // SENF_PARSE_FIELD_* +# // SENF_PARSER_FIELD_* +# // SENF_PARSER_P_FIELD_* # -# define SENF_PARSE_FIELD_var(name, type) SENF_PARSER_FIELD_I(name, type, var, rw, public) -# define SENF_PARSE_FIELD_RO_var(name, type) SENF_PARSER_FIELD_I(name, type, var, ro, public) +# define SENF_PARSER_FIELD_var(name, type) SENF_PARSER_FIELD_I(name, type, var, rw, public) +# define SENF_PARSER_FIELD_RO_var(name, type) SENF_PARSER_FIELD_I(name, type, var, ro, public) +# define SENF_PARSER_FIELD_fix(name, type) SENF_PARSER_FIELD_I(name, type, fix, rw, public) +# define SENF_PARSER_FIELD_RO_fix(name, type) SENF_PARSER_FIELD_I(name, type, fix, ro, public) # -# define SENF_PARSE_FIELD_fix(name, type) SENF_PARSER_FIELD_I(name, type, fix, rw, public) -# define SENF_PARSE_FIELD_RO_fix(name, type) SENF_PARSER_FIELD_I(name, type, fix, ro, public) +# define SENF_PARSER_P_FIELD_var(name, type) SENF_PARSER_FIELD_I(name, type, var, rw, private) +# define SENF_PARSER_P_FIELD_RO_var(name, type) SENF_PARSER_FIELD_I(name, type, var, ro, private) +# define SENF_PARSER_P_FIELD_fix(name, type) SENF_PARSER_FIELD_I(name, type, fix, rw, private) +# define SENF_PARSER_P_FIELD_RO_fix(name, type) SENF_PARSER_FIELD_I(name, type, fix, ro, private) # # define SENF_PARSER_FIELD_I(name, type, ofstype, rwtype, access) \ access: \ @@ -193,11 +198,11 @@ } # # /////////////////////////////////////////////////////////////////////////// -# // SENF_PARSE_CUSTOM_FIELD_* +# // SENF_PARSER_CUSTOM_FIELD_* # -# define SENF_PARSE_CUSTOM_FIELD_var(name, type, size, isize) \ +# define SENF_PARSER_CUSTOM_FIELD_var(name, type, size, isize) \ SENF_PARSER_CUSTOM_FIELD_I(name, type, size, isize, var) -# define SENF_PARSE_CUSTOM_FIELD_fix(name, type, size) \ +# define SENF_PARSER_CUSTOM_FIELD_fix(name, type, size) \ SENF_PARSER_CUSTOM_FIELD_I(name, type, size, size, fix) # # define SENF_PARSER_CUSTOM_FIELD_I(name, type, size, isize, ofstype) \ @@ -209,18 +214,27 @@ BOOST_PP_CAT(name, _t) name() const # # /////////////////////////////////////////////////////////////////////////// -# // SENF_PARSE_BITFIELD_* +# // SENF_PARSER_BITFIELD_* +# // SENF_PARSER_P_BITFIELD_* # -# define SENF_PARSE_BITFIELD_var(name, bits, type) \ +# define SENF_PARSER_BITFIELD_var(name, bits, type) \ SENF_PARSER_BITFIELD_I(name, bits, type, var, rw, public) -# define SENF_PARSE_BITFIELD_RO_var(name, bits, type) \ +# define SENF_PARSER_BITFIELD_RO_var(name, bits, type) \ SENF_PARSER_BITFIELD_I(name, bits, type, var, ro, public) -# -# define SENF_PARSE_BITFIELD_fix(name, bits, type) \ +# define SENF_PARSER_BITFIELD_fix(name, bits, type) \ SENF_PARSER_BITFIELD_I(name, bits, type, fix, rw, public) -# define SENF_PARSE_BITFIELD_RO_fix(name, bits, type) \ +# define SENF_PARSER_BITFIELD_RO_fix(name, bits, type) \ SENF_PARSER_BITFIELD_I(name, bits, type, fix, ro, public) # +# define SENF_PARSER_P_BITFIELD_var(name, bits, type) \ + SENF_PARSER_BITFIELD_I(name, bits, type, var, rw, private) +# define SENF_PARSER_P_BITFIELD_RO_var(name, bits, type) \ + SENF_PARSER_BITFIELD_I(name, bits, type, var, ro, private) +# define SENF_PARSER_P_BITFIELD_fix(name, bits, type) \ + SENF_PARSER_BITFIELD_I(name, bits, type, fix, rw, private) +# define SENF_PARSER_P_BITFIELD_RO_fix(name, bits, type) \ + SENF_PARSER_BITFIELD_I(name, bits, type, fix, ro, private) +# # //////////////////////////////////////// # // SENF_PARSER_BITFIELD_I # @@ -316,6 +330,15 @@ public: # # /////////////////////////////////////////////////////////////////////////// +# // SENF_PARSER_SKIP_BITS_* +# +# define SENF_PARSER_SKIP_BITS_var(bits) SENF_PARSER_I_SKIP_BITS(bits, var) +# define SENF_PARSER_SKIP_BITS_fix(bits) SENF_PARSER_I_SKIP_BITS(bits, fix) +# +# define SENF_PARSER_I_SKIP_BITS(bits, ofstype) \ + SENF_MPL_SLOT_SET(bit, SENF_MPL_SLOT_GET(bit) + bits) +# +# /////////////////////////////////////////////////////////////////////////// # // SENF_PARSER_GOTO_* # # define SENF_PARSER_GOTO_var(name) \ @@ -341,16 +364,16 @@ SENF_PARSER_I_BITFIELD_RESET() \ SENF_PARSER_I_FIELD_INTRO(name, void, private) \ SENF_PARSER_I_FIELD_INIT_ro(name, void, private) \ - BOOST_PP_CAT( SENF_PARSE_I_GOTO_SET_OFS_, ofstype ) (name, offset, initsize) \ + BOOST_PP_CAT( SENF_PARSER_I_GOTO_SET_OFS_, ofstype ) (name, offset, initsize) \ public: # -# define SENF_PARSE_I_GOTO_SET_OFS_var(name, offs, initsize) \ +# define SENF_PARSER_I_GOTO_SET_OFS_var(name, offs, initsize) \ size_type field_offset_(senf::mpl::rv*) const { \ return offs; \ } \ SENF_MPL_SLOT_SET(init_bytes, initsize); # -# define SENF_PARSE_I_GOTO_SET_OFS_fix(name, offs, initsize) \ +# define SENF_PARSER_I_GOTO_SET_OFS_fix(name, offs, initsize) \ SENF_MPL_SLOT_SET(offset, offs); # # /////////////////////////////////////////////////////////////////////////// diff --git a/Packets/ParseHelpers.test.cc b/Packets/ParseHelpers.test.cc index 6d69414..3d42cff 100644 --- a/Packets/ParseHelpers.test.cc +++ b/Packets/ParseHelpers.test.cc @@ -41,31 +41,35 @@ namespace { { # include SENF_FIXED_PARSER() - SENF_PARSE_FIELD ( normalField , senf::Parse_UInt16 ); - SENF_PARSE_FIELD_RO ( roField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( normalField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD_RO ( roField , senf::Parse_UInt16 ); - SENF_PARSE_CUSTOM_FIELD ( customField , int, 2 ) { + SENF_PARSER_CUSTOM_FIELD ( customField , int, 2 ) { return parse(customField_offset); } - SENF_PARSE_BITFIELD ( signedBitfield , 4, signed ); - SENF_PARSE_BITFIELD ( unsignedBitfield , 3, unsigned ); - SENF_PARSE_BITFIELD ( boolBitfield , 1, bool ); + SENF_PARSER_BITFIELD ( signedBitfield , 4, signed ); + SENF_PARSER_BITFIELD ( unsignedBitfield , 3, unsigned ); + SENF_PARSER_BITFIELD ( boolBitfield , 1, bool ); - SENF_PARSE_BITFIELD_RO ( roSignedBitfield , 4, signed ); - SENF_PARSE_BITFIELD_RO ( roUnsignedBitfield , 3, unsigned ); - SENF_PARSE_BITFIELD_RO ( roBoolBitfield , 1, bool ); + SENF_PARSER_BITFIELD_RO ( roSignedBitfield , 4, signed ); + SENF_PARSER_BITFIELD_RO ( roUnsignedBitfield , 3, unsigned ); + SENF_PARSER_BITFIELD_RO ( roBoolBitfield , 1, bool ); SENF_PARSER_LABEL( end ); SENF_PARSER_GOTO( roField ); - SENF_PARSE_FIELD ( overlayOfRoField , senf::Parse_Int16 ); + SENF_PARSER_FIELD ( overlayOfRoField , senf::Parse_Int16 ); SENF_PARSER_SKIP( 2 ); - SENF_PARSE_FIELD ( overlayOfBitfield , senf::Parse_UInt8 ); + SENF_PARSER_FIELD ( overlayOfBitfield , senf::Parse_UInt8 ); SENF_PARSER_GOTO_OFFSET( 1 ); - SENF_PARSE_FIELD ( lowbyteOfNormalField , senf::Parse_UInt8 ); + SENF_PARSER_PRIVATE_FIELD ( privLowbyteOfNormalField , senf::Parse_UInt8 ); + + unsigned lowbyteOfNormalField() { + return privLowbyteOfNormalField(); + } SENF_PARSER_GOTO( end ); @@ -78,12 +82,12 @@ namespace { SENF_PARSER_INHERIT( FixedBaseParser ); - SENF_PARSE_FIELD ( derivedField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( derivedField , senf::Parse_UInt16 ); SENF_PARSER_LABEL( end ); SENF_PARSER_GOTO( signedBitfield ); - SENF_PARSE_FIELD ( anotherOverlay , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( anotherOverlay , senf::Parse_UInt16 ); SENF_PARSER_GOTO( end ); @@ -147,31 +151,35 @@ namespace { { # include SENF_PARSER() - SENF_PARSE_FIELD ( normalField , senf::Parse_UInt16 ); - SENF_PARSE_FIELD_RO ( roField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( normalField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD_RO ( roField , senf::Parse_UInt16 ); - SENF_PARSE_CUSTOM_FIELD ( customField , int, 2, 2 ) { + SENF_PARSER_CUSTOM_FIELD ( customField , int, 2, 2 ) { return parse(customField_offset()); } - SENF_PARSE_BITFIELD ( signedBitfield , 4, signed ); - SENF_PARSE_BITFIELD ( unsignedBitfield , 3, unsigned ); - SENF_PARSE_BITFIELD ( boolBitfield , 1, bool ); + SENF_PARSER_BITFIELD ( signedBitfield , 4, signed ); + SENF_PARSER_BITFIELD ( unsignedBitfield , 3, unsigned ); + SENF_PARSER_BITFIELD ( boolBitfield , 1, bool ); - SENF_PARSE_BITFIELD_RO ( roSignedBitfield , 4, signed ); - SENF_PARSE_BITFIELD_RO ( roUnsignedBitfield , 3, unsigned ); - SENF_PARSE_BITFIELD_RO ( roBoolBitfield , 1, bool ); + SENF_PARSER_BITFIELD_RO ( roSignedBitfield , 4, signed ); + SENF_PARSER_BITFIELD_RO ( roUnsignedBitfield , 3, unsigned ); + SENF_PARSER_BITFIELD_RO ( roBoolBitfield , 1, bool ); SENF_PARSER_LABEL( end ); SENF_PARSER_GOTO( roField ); - SENF_PARSE_FIELD ( overlayOfRoField , senf::Parse_Int16 ); + SENF_PARSER_FIELD ( overlayOfRoField , senf::Parse_Int16 ); SENF_PARSER_SKIP( 2, 2 ); - SENF_PARSE_FIELD ( overlayOfBitfield , senf::Parse_UInt8 ); + SENF_PARSER_FIELD ( overlayOfBitfield , senf::Parse_UInt8 ); SENF_PARSER_GOTO_OFFSET( 1, 1 ); - SENF_PARSE_FIELD ( lowbyteOfNormalField , senf::Parse_UInt8 ); + SENF_PARSER_PRIVATE_FIELD ( privLowbyteOfNormalField , senf::Parse_UInt8 ); + + unsigned lowbyteOfNormalField() { + return privLowbyteOfNormalField(); + } SENF_PARSER_GOTO( end ); @@ -184,12 +192,12 @@ namespace { SENF_PARSER_INHERIT( VariableBaseParser ); - SENF_PARSE_FIELD ( derivedField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( derivedField , senf::Parse_UInt16 ); SENF_PARSER_LABEL( end ); SENF_PARSER_GOTO( signedBitfield ); - SENF_PARSE_FIELD ( anotherOverlay , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( anotherOverlay , senf::Parse_UInt16 ); SENF_PARSER_GOTO( end ); diff --git a/doclib/Doxyfile.global b/doclib/Doxyfile.global index 87f3c31..c91d4a1 100644 --- a/doclib/Doxyfile.global +++ b/doclib/Doxyfile.global @@ -29,14 +29,23 @@ MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES PREDEFINED = DOXYGEN \ "SENF_PPI_MODULE(x)=" \ - "SENF_PARSE_FIELD(name,type)=type name()" \ - "SENF_PARSE_FIELD_RO(name,type)=type::value_type name()" \ - "SENF_PARSE_FIELD_AFTER(name,type,prev)=type name()" \ - "SENF_PARSE_FIELD_AFTER_RO(name,type,prev)=type::value_type name()" \ - "SENF_PARSE_BITFIELD(name, bits, type)=type ## _ ## bits name()" \ - "SENF_PARSE_BITFIELD_RO(name, bits, type)=type ## _ ## bits name()" \ + "SENF_PARSER_FIELD(name,type)=type name() const" \ + "SENF_PARSER_FIELD_RO(name,type)=type::value_type name() const" \ + "SENF_PARSER_FIELD_AFTER(name,type,prev)=type name() const" \ + "SENF_PARSER_FIELD_AFTER_RO(name,type,prev)=type::value_type name() const" \ + "SENF_PARSER_BITFIELD(name, bits, type)=senf::ParseField_ ## type name() const" \ + "SENF_PARSER_BITFIELD_RO(name, bits, type)=type ## _ ## bits name() const" \ + "SENF_PARSER_INHERIT(name)=" \ "SENF_PARSER_FINALIZE(name)=" \ - "SENF_PARSER_INIT()=void init()" + "SENF_PARSER_INIT()=void init()" \ + "SENF_PARSER_SKIP(x)=" \ + "SENF_PARSER_SKIP_BITS(x)=" \ + "SENF_PARSER_GOTO(x)=" \ + "SENF_PARSER_GOTO_OFFSET(x)=" \ + "SENF_PARSER_LABEL(x)=" \ + "ParseField_unsigned=Parse_UIntField" \ + "ParseField_signed=Parse_IntField" \ + "ParseField_bool=Parse_Flag" EXPAND_AS_DEFINED = prefix_ HTML_HEADER = "$(TOPDIR)/doclib/doxy-header.html"