///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_DataPacket_impl_)
+#if !defined(HH_Packets__decls_) && !defined(HH_DataPacket_impl_)
#define HH_DataPacket_impl_
//#include "DataPacket.cci"
//#include "DataPacket.ct"
*/
struct Parse_Ethernet : public PacketParserBase
{
- typedef Parse_UInt16 Parse_Type;
+# include SENF_FIXED_PARSER()
-# ifndef DOXYGEN
+ SENF_PARSE_FIELD( destination, Parse_MAC );
+ SENF_PARSE_FIELD( source, Parse_MAC );
+ SENF_PARSE_FIELD( type, Parse_UInt16 );
- SENF_PACKET_PARSER_INIT(Parse_Ethernet);
-
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field)( destination, Parse_MAC ))
- ((Field)( source, Parse_MAC ))
- ((Field)( type, Parse_Type )) );
-
-# else
-
- Parse_MAC destination();
- Parse_MAC source();
- Parse_Type type();
-
-# endif
+ SENF_PARSER_FINALIZE(Parse_Ethernet);
};
/** \brief EtherType registry
*/
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;
-
-# ifndef DOXYGEN
-
- 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 )) );
+# include SENF_FIXED_PARSER()
-# else
+ SENF_PARSE_BITFIELD( priority, 3, unsigned );
+ SENF_PARSE_BITFIELD( cfi, 1, bool );
+ SENF_PARSE_BITFIELD( vlanId, 12, unsigned );
- Parse_Priority priority();
- Parse_CFI cfi();
- Parse_VLanId vlanId();
- Parse_Type type();
+ SENF_PARSE_FIELD( type, Parse_UInt16 );
-# endif
+ SENF_PARSER_FINALIZE(Parse_EthVLan);
};
/** \brief Ethernet VLAN tag
*/
struct Parse_IpV4 : public PacketParserBase
{
- typedef Parse_UIntField < 0, 4 > Parse_Version;
- typedef Parse_UIntField < 4, 8 > Parse_IHL;
- typedef Parse_UInt8 Parse_8bit;
- typedef Parse_UInt16 Parse_16bit;
- typedef Parse_Flag < 0 > Parse_R;
- typedef Parse_Flag < 1 > Parse_DF;
- typedef Parse_Flag < 2 > Parse_MF;
- typedef Parse_UIntField < 3, 16 > Parse_Frag;
- typedef Parse_UInt32 Parse_32bit;
- typedef Parse_INet4Address Parse_Addr;
-
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_NO_INIT(Parse_IpV4);
-
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((OverlayField)( version, Parse_Version ))
- ((Field )( ihl, Parse_IHL ))
- ((Field )( tos, Parse_8bit ))
- ((Field )( length, Parse_16bit ))
- ((Field )( identifier, Parse_16bit ))
- ((OverlayField)( reserved, Parse_R ))
- ((OverlayField)( df, Parse_DF ))
- ((OverlayField)( mf, Parse_MF ))
- ((Field )( frag, Parse_Frag ))
- ((Field )( ttl, Parse_8bit ))
- ((Field )( protocol, Parse_8bit ))
- ((Field )( checksum, Parse_16bit ))
- ((Field )( source, Parse_Addr ))
- ((Field )( destination, Parse_Addr )) );
-
-# else
-
- Parse_Version version() const;
- Parse_IHL ihl() const;
- Parse_8bit tos() const;
- Parse_16bit length() const;
- Parse_16bit identifier() const;
- Parse_R reserved() const;
- Parse_DF df() const;
- Parse_MF mf() const;
- Parse_Frag frag() const;
- Parse_8bit ttl() const;
- Parse_8bit protocol() const;
- Parse_16bit checksum() const;
- Parse_Addr source() const;
- Parse_Addr destination() const;
-
-# endif
-
- void init() {
+# 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_INIT() {
version() = 4;
// We don't support option headers at the moment ...
ihl() = 5;
}
+
+ SENF_PARSER_FINALIZE(Parse_IpV4);
boost::uint16_t calcChecksum() const;
+
bool validateChecksum() const {
return checksum() == calcChecksum();
}
*/
struct Parse_IpV6Extension_Fragment : public PacketParserBase
{
- typedef Parse_UInt8 Parse_8bit;
- typedef Parse_UIntField < 0, 13 > Parse_Offset;
- typedef Parse_UIntField < 13, 15 > Parse_Reserved;
- typedef Parse_Flag < 15 > Parse_More;
- typedef Parse_UInt32 Parse_32bit;
-
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_INIT(Parse_IpV6Extension_Fragment);
-
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field )( nextHeader , Parse_8bit ))
- ((Field )( reserved1 , Parse_8bit ))
- ((OverlayField)( fragmentOffset , Parse_Offset ))
- ((OverlayField)( reserved2 , Parse_Reserved ))
- ((Field )( moreFragments , Parse_More ))
- ((Field )( id , Parse_32bit )) );
-
-# else
-
- Parse_8bit nextHeader();
- Parse_8bit reserved1();
- Parse_Offset fragmentOffset();
- Parse_Reserved reserved2();
- Parse_More moreFragments();
- Parse_32bit id();
-
-# endif
+# include SENF_FIXED_PARSER()
+
+ SENF_PARSE_FIELD( nextHeader , Parse_UInt8 );
+ SENF_PARSE_FIELD( reserved1 , Parse_UInt8 );
+
+ SENF_PARSE_BITFIELD( fragmentOffset, 13, unsigned );
+ SENF_PARSE_BITFIELD( reserved2, 2, unsigned );
+ SENF_PARSE_BITFIELD( moreFragments, 1, bool );
+
+ SENF_PARSE_FIELD( id , Parse_UInt32 );
+
+ SENF_PARSER_FINALIZE(Parse_IpV6Extension_Fragment);
};
/** \brief IpV6 fragment extension
*/
struct Parse_IpV6 : public PacketParserBase
{
- typedef Parse_UIntField < 0, 4 > Parse_Version;
- typedef Parse_UIntField < 4, 12 > Parse_Class;
- typedef Parse_UIntField < 12, 32 > Parse_FlowLabel;
- typedef Parse_UInt8 Parse_8bit;
- typedef Parse_UInt16 Parse_16bit;
- typedef Parse_INet6Address Parse_Addr;
-
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_NO_INIT(Parse_IpV6);
-
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((OverlayField)( version, Parse_Version ))
- ((OverlayField)( trafficClass, Parse_Class ))
- ((Field )( flowLabel, Parse_FlowLabel ))
- ((Field )( length, Parse_16bit ))
- ((Field )( nextHeader, Parse_8bit ))
- ((Field )( hopLimit, Parse_8bit ))
- ((Field )( source, Parse_Addr ))
- ((Field )( destination, Parse_Addr )) );
-
-# else
-
- Parse_Version version() const;
- Parse_Class trafficClass() const;
- Parse_FlowLabel flowLabel() const;
- Parse_16bit length() const;
- Parse_8bit nextHeader() const;
- Parse_8bit hopLimit() const;
- Parse_Addr source() const;
- Parse_Addr destination() const;
-
-# endif
-
- void init() {
+# 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_INIT() {
version() = 6;
}
+
+ SENF_PARSER_FINALIZE(Parse_IpV6);
};
/** \brief IpV6 packet
*/
struct Parse_UDP : public PacketParserBase
{
- typedef Parse_UInt16 Parse_16bit;
+# include SENF_FIXED_PARSER()
-# ifndef DOXYGEN
+ 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_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();
}
<< std::dec
<< " section_length: " << p->sec_length() << "\n"
<< std::hex
- << " table_id_extension: " << p->tabel_id_extension() << "\n"
+ << " 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"
// Custom includes
#include <algorithm>
-#include "../../Packets/PacketType.hh"
-#include "../../Packets/ParseInt.hh"
-#include "../../Packets/PacketParser.hh"
+#include "../../Packets/Packets.hh"
//#include "DSMCCSection.mpp"
///////////////////////////////hh.p////////////////////////////////////////
*/
struct Parse_DSMCCSection : public PacketParserBase
{
- typedef Parse_UInt8 Parse_table_id;
- typedef Parse_Flag < 0 > Parse_ssi; // section_syntax_indicator
- typedef Parse_Flag < 1 > Parse_pi; // private_indicator
- typedef Parse_UIntField < 2, 4 > Parse_reserved_1;
- typedef Parse_UIntField < 4, 16 > Parse_sec_length;
- typedef Parse_UIntField < 0, 2 > Parse_reserved_2;
- typedef Parse_UIntField < 2, 7 > Parse_version_num;
- typedef Parse_Flag < 7 > Parse_curr_next_indicator;
-
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_INIT(Parse_DSMCCSection);
-
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field ) ( table_id, Parse_table_id ))
- ((OverlayField) ( ssi, Parse_ssi ))
- ((OverlayField) ( private_indicator, Parse_pi ))
- ((OverlayField) ( reserved_1, Parse_reserved_1 ))
- ((Field ) ( sec_length, Parse_sec_length ))
- ((Field ) ( tabel_id_extension, Parse_UInt16 ))
- ((OverlayField) ( reserved_2, Parse_reserved_2 ))
- ((OverlayField) ( version_num, Parse_version_num ))
- ((Field ) ( curr_next_indicator, Parse_curr_next_indicator ))
- ((Field ) ( sec_num, Parse_UInt8 ))
- ((Field ) ( last_sec_num, Parse_UInt8 ))
- );
-
-# else
-
- Parse_table_id table_id() const;
- Parse_ssi ssi() const;
- Parse_pi pi() const;
- Parse_reserved_1 reserved_1() const;
- Parse_sec_length sec_length const;
- Parse_UInt16 tabel_id_extension() const;
- Parse_reserved_2 reserved_2() const;
- Parse_version_num version_num() const;
- Parse_curr_next_indicator curr_next_indicator() const;
- Parse_UInt8 sec_num() const;
- Parse_UInt8 last_sec_num() const;
+# include SENF_FIXED_PARSER()
+
+ SENF_PARSE_FIELD( table_id, Parse_UInt8 );
-# endif
+ 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_PARSE_FIELD( sec_num, Parse_UInt8 );
+ SENF_PARSE_FIELD( last_sec_num, Parse_UInt8 );
+ SENF_PARSER_FINALIZE(Parse_DSMCCSection);
+
Parse_UInt32 crc() const { return parse<Parse_UInt32>( data().size()-4 ); }
};
// Custom includes
#include <algorithm>
-#include "../../Packets/PacketType.hh"
-#include "../../Packets/ParseInt.hh"
-#include "../../Packets/PacketRegistry.hh"
-#include "../../Packets/PacketParser.hh"
-#include "../../Packets/MPEGDVBBundle/DSMCCSection.hh"
+#include "../../Packets/Packets.hh"
+#include "DSMCCSection.hh"
//#include "DatagramSection.mpp"
*/
struct Parse_DatagramSection : public Parse_DSMCCSection
{
- Parse_DatagramSection(data_iterator i, state_type s) : senf::Parse_DSMCCSection(i,s) {}
+# include SENF_FIXED_PARSER()
+
+ 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_FINALIZE_INHERITED(Parse_DatagramSection, Parse_DSMCCSection);
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;
-
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS_OFFSET(Parse_DSMCCSection::fixed_bytes,
- ((Field ) ( mac_addr_4, Parse_UInt8 ))
- ((Field ) ( mac_addr_3, Parse_UInt8 ))
- ((Field ) ( mac_addr_2, Parse_UInt8 ))
- ((Field ) ( mac_addr_1, Parse_UInt8 ))
- );
-
-# else
-
- Parse_UInt8 mac_addr_4() const;
- Parse_UInt8 mac_addr_3() const;
- Parse_UInt8 mac_addr_2() const;
- Parse_UInt8 mac_addr_1() const;
-
-# endif
-
+
Parse_UInt8 mac_addr_6() const { return parse<Parse_UInt8>( 3 ); }
Parse_UInt8 mac_addr_5() const { return parse<Parse_UInt8>( 4 ); }
+
Parse_payload_scrmbl_ctrl payload_scrmbl_ctrl() const {
return parse<Parse_payload_scrmbl_ctrl>( 5 );
}
+
Parse_addr_scrmbl_ctrl addr_scrmbl_ctrl() const {
return parse<Parse_addr_scrmbl_ctrl>( 5 );
}
+
Parse_llc_snap_flag llc_snap_flag() const {
return parse<Parse_llc_snap_flag>( 5 );
}
-
- void init()
- {
- Parse_DSMCCSection::init();
- defaultInit();
- }
};
/** \brief Datagram Section
// Custom includes
#include <algorithm>
#include <boost/crc.hpp>
-#include "../../Packets/PacketType.hh"
-#include "../../Packets/ParseInt.hh"
-#include "../../Packets/PacketRegistry.hh"
-#include "../../Packets/PacketParser.hh"
-#include "../../Packets/DefaultBundle/EthernetPacket.hh"
+#include "../../Packets/Packets.hh"
+#include "../DefaultBundle/EthernetPacket.hh"
//#include "SNDUPacket.mpp"
///////////////////////////////hh.p////////////////////////////////////////
*/
struct Parse_SNDUPacket : public PacketParserBase
{
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_NO_INIT(Parse_SNDUPacket);
-
-# endif
+ Parse_SNDUPacket(data_iterator i, state_type s) : PacketParserBase(i,s) {}
typedef Parse_Flag < 0 > Parse_daaf; // Destination Address Absent Field
typedef Parse_UIntField < 1, 16 > Parse_length;
// Custom includes
#include <algorithm>
-#include "../../Packets/PacketType.hh"
-#include "../../Packets/ParseInt.hh"
-#include "../../Packets/PacketParser.hh"
+#include "../../Packets/Packets.hh"
//#include "TLVPacket.mpp"
///////////////////////////////hh.p////////////////////////////////////////
public PacketParserBase
{
public:
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_NO_INIT(Parse_TLVPacketLength);
-
-# endif
+ Parse_TLVPacketLength(data_iterator i, state_type s) : PacketParserBase(i,s) {}
typedef boost::uint32_t value_type;
*/
struct Parse_TLVPacket : public PacketParserBase
{
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_INIT(Parse_TLVPacket);
+# include SENF_PARSER()
- SENF_PACKET_PARSER_DEFINE_FIELDS(
- ((Field)( type, Parse_UInt32 ))
- ((Field)( length, Parse_TLVPacketLength ))
- );
+ SENF_PARSE_FIELD( type, Parse_UInt32 );
+ SENF_PARSE_FIELD( length, Parse_TLVPacketLength );
-# endif
+ SENF_PARSER_FINALIZE(Parse_TLVPacket);
};
/** \brief TLV Packet
// Custom includes
#include <algorithm>
-#include "../../Packets/PacketType.hh"
-#include "../../Packets/ParseInt.hh"
-#include "../../Packets/PacketParser.hh"
+#include "../../Packets/Packets.hh"
//#include "TransportPacket.mpp"
///////////////////////////////hh.p////////////////////////////////////////
*/
struct Parse_TransportPacket : public PacketParserBase
{
- typedef Parse_Flag < 0 > Parse_tei; // transport_error_indicator
- typedef Parse_Flag < 1 > Parse_pusi; // payload_unit_start_indicator
- typedef Parse_Flag < 2 > Parse_transportPrio; // transport_priority
- typedef Parse_UIntField < 2, 16 > Parse_pid;
- typedef Parse_UIntField < 0, 2 > Parse_tsc; // transport_scrambling_control
- typedef Parse_UIntField < 2, 4 > Parse_adaptCtrl; // adaptation_field_control
- typedef Parse_UIntField < 4, 8 > Parse_contCounter; // continuity_counter
-
-# ifndef DOXYGEN
-
- SENF_PACKET_PARSER_INIT(Parse_TransportPacket);
-
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field ) ( sync_byte, Parse_UInt8 ))
- ((OverlayField) ( transport_error_indicator, Parse_tei ))
- ((OverlayField) ( pusi, Parse_pusi ))
- ((OverlayField) ( transport_priority, Parse_transportPrio ))
- ((Field ) ( pid, Parse_pid ))
- ((OverlayField) ( transport_scrmbl_ctrl, Parse_tsc ))
- ((OverlayField) ( adaptation_field_ctrl, Parse_adaptCtrl ))
- ((Field ) ( continuity_counter, Parse_contCounter ))
- );
-
-# else
-
- Parse_UInt8 sync_byte() const;
- Parse_tei transport_error_indicator() const;
- Parse_pusi pusi() const;
- Parse_transportPrio transport_priority() const;
- Parse_pid pid() const;
- Parse_tsc transport_scrmbl_ctrl() const;
- Parse_adaptCtrl adaptation_field_ctrl() const;
- Parse_contCounter continuity_counter() const;
+# include SENF_FIXED_PARSER()
-# endif
+ SENF_PARSE_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_FINALIZE( Parse_TransportPacket );
+
// Parse_UInt8 payload_pointer() const {
// return parse<Parse_UInt8>( Parse_TransportPacket::fixed_bytes );
// }
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_Packet_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_Packet_i_)
#define HH_Packet_i_
#include "Packet.cci"
#include "Packet.ct"
struct BarPacketParser : public senf::PacketParserBase
{
- SENF_PACKET_PARSER_INIT(BarPacketParser);
+# include SENF_FIXED_PARSER()
- typedef senf::Parse_UInt16 Parse_Type;
- typedef senf::Parse_Int32 Parse_Length;
- typedef senf::Parse_UInt16 Parse_Reserved;
+ SENF_PARSE_FIELD( type, senf::Parse_UInt16 );
+ SENF_PARSE_FIELD( length, senf::Parse_Int32 );
+ SENF_PARSE_FIELD( reserved, senf::Parse_UInt16 );
- Parse_Type type() const { return parse<Parse_Type> (i()); }
- Parse_Length length() const { return parse<Parse_Length> (i()+2); }
- Parse_Reserved reserved() const { return parse<Parse_Reserved> (i()+6); }
+ SENF_PARSER_FINALIZE(BarPacketParser);
};
struct BarPacketType
packet.finalize();
BOOST_CHECK_EQUAL( packet.last().as<BarPacket>()->type(),
- BarPacket::type::parser::Parse_Type::value_type(-1) );
+ BarPacket::type::parser::type_t::value_type(-1) );
packet.last().append(FooPacket::create());
packet.finalize();
BOOST_CHECK_EQUAL( packet.next<BarPacket>()->type(), 1u );
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketData_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_PacketData_i_)
#define HH_PacketData_i_
#include "PacketData.cci"
//#include "PacketData.ct"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketImpl_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_PacketImpl_i_)
#define HH_PacketImpl_i_
#include "PacketImpl.cci"
//#include "PacketImpl.ct"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketInterpreter_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_PacketInterpreter_i_)
#define HH_PacketInterpreter_i_
#include "PacketInterpreter.cci"
#include "PacketInterpreter.ct"
#include "../Utils/SafeBool.hh"
#include "PacketTypes.hh"
#include "PacketData.hh"
+#include "ParseHelpers.hh"
-#include "PacketParser.mpp"
+//#include "PacketParser.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
Parser operator<<(Parser target, boost::optional<Value> const & value);
# endif
- /** \defgroup packetparsermacros Helper macros for defining new packet parsers
-
- To simplify the definition of simple packet parsers, several macros are provided. Before
- using these macros you should familiarize yourself with the packet parser interface as
- described in senf::PacketParserBase.
-
- These macros simplify providing the above defined interface. A typical packet declaration
- using these macros has the following form (This is a concrete example from the definition of
- the ethernet packet in <tt>DefaultBundle/EthernetPacket.hh</tt>)
-
- \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.
- \li The macros provide a definition for \c init()
- \li The macros define the \c bytes(), \c fixed_bytes and \c init_bytes members as needed.
-
- You may define either a fixed or a dynamically sized parser. Fixed size parsers are defined
- using \ref SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS, dynamically sized parsers are defined
- using \ref SENF_PACKET_PARSER_DEFINE_FIELDS. The different members are implemented such
- that:
-
- \li The needed parser constructor is defined
- \li \c init() calls \c defaultInit(). \c defaultInit() is defined to call \c init() on each
- of the fields.
- \li \c bytes() (on dynamically sized parser) respectively \c fixed_bytes (on fixed size
- parsers) is defined to return the sum of the sizes of all fields.
- \li On dynamically sized parsers, \c init_bytes is defined to return the sum of the
- \c init_size's of all fields
-
- The central definition macros are \ref SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS and \ref
- SENF_PACKET_PARSER_DEFINE_FIELDS. The argument to both has the same structure. It is a
- (boost preprocessor style) sequence of field definitions where each field definition
- provides the builder macro to use and the name and type of the field to define:
- \code
- SENF_PACKET_PARSER_DEFINE[_FIXED]_FIELDS(
- (( <builder> )( <name>, <type> ))
- ...
- )
- \endcode
-
- For each field, this command will define
- \li A method \a name() returning an instance of the \a type parser
- \li \a name<tt>_t</tt> as a typedef for \a type, the fields value
- \li \a name<tt>_offset</tt> to give the offset of the field from the beginning of the
- parser. If the parser is a fixed size parser, this will be a static constant, otherwise
- it will be a method.
-
- The \a builder argument selects, how the field is defined
- \li <tt>Field</tt> defines a field and increments the current position by the size of the
- field
- \li <tt>OverlayField</tt> defines a field like <tt>Field</tt> but does \e not increment the
- position. In the above example, this is used to overlay the different bitfield parsers:
- All overlaying bitfield parser except the last one (the one with the highest bit
- numbers) is marked as OverlayField.
-
- The \a name argument defines the name of the accessor method.
-
- The \a type argument is the parser to return for that field. Since none of the arguments may
- contain a comma, <em>This argument cannot be a multi-parameter template</em>. Always use
- typedefs to access templated parsers as shown above.
-
- The \ref SENF_PACKET_PARSER_INIT macro defines the constructor and the \c init() member. If
- you want to provide your own \c init() implementation, use \ref
- SENF_PACKET_PARSER_NO_INIT. The first statement in your init method should probably to call
- \c defaultInit(). This will call the \c init() member of all the fields. Afterwards you can
- set up the field values as needed:
- \code
- struct SomePacket : public senf::PacketParserBase
- {
- SENF_PACKET_PARSER_NO_INIT(SomePacket);
-
- typedef senf::Parse_UInt8 Parse_Type;
- typedef senf::Parse_Vector< senf::Parse_UInt32,
- senf::SimpleVectorSizer<senf::Parse_UInt16>
- > Parse_Elements;
-
- SENF_PACKET_PARSER_DEFINE_FIELDS(
- ((Field)( type, Parse_Type ))
- ((Field)( elements, Parse_Elements ))
- );
-
- void init() const {
- defaultInit();
- type() = 0x01;
- elements().push_back(0x01020304u);
- }
- }
- \endcode
-
- \ingroup packetparser
- */
-
- /** \brief Define initialization members of a parser
-
- This macro defines the packet parser constructor and the \c init() member. \c init() is
- defined to just call \c defaultInit() which is defined by the other macros to call \c init()
- on each of the parsers fields.
-
- \ingroup packetparsermacros
- \hideinitializer
- */
-# define SENF_PACKET_PARSER_INIT(name) \
- name(data_iterator i, state_type s) : senf::PacketParserBase(i,s) {} \
- void init() const { defaultInit(); }
-
- /** \brief Define initialization members of a parser except init()
-
- This macro is like SENF_PACKET_PARSER_INIT but does \e not define \c init(). This allows you
- to provide your own implementation. You should call \c defaultInit() first before
- initializing your data fields.
-
- \ingroup packetparsermacros
- \hideinitializer
- */
-# define SENF_PACKET_PARSER_NO_INIT(name) \
- name(data_iterator i, state_type s) : senf::PacketParserBase(i,s) {}
-
- /** \brief Define fields for a dynamically sized parser
-
- Define the fields as specified in \a fields. This macro supports dynamically sized
- subfields, the resulting parser will be dynamically sized.
-
- \ingroup packetparsermacros
- \hideinitializer
- */
-# define SENF_PACKET_PARSER_DEFINE_FIELDS(fields) \
- SENF_PACKET_PARSER_I_DEFINE_FIELDS(0,fields)
-
- /** \brief Define fields for a dynamically sized parser (with offset)
-
- Define the fields as specified in \a fields. This macro supports dynamically sized
- subfields, the resulting parser will be dynamically sized.
-
- The \a offset argument gives the byte offset at which to start parsing the fields. This
- helps defining extended parser deriving from a base parser:
- \code
- struct ExtendedParser : public BaseParser
- {
- ExtendedParser(data_iterator i, state_type s) : BaseParser(i,s) {}
-
- SENF_PACKET_PARSER_DEFINE_FIELDS_OFFSET(senf::bytes(BaseParser(*this)),
- ( ... fields ... ) );
-
- void init() {
- BaseParser::init();
- defaultInit();
- // other init code
- }
- }
- \endcode
-
- \ingroup packetparsermacros
- \hideinitializer
- */
-# define SENF_PACKET_PARSER_DEFINE_FIELDS_OFFSET(offset,fields) \
- SENF_PACKET_PARSER_I_DEFINE_FIELDS(offset,fields)
-
- /** \brief Define fields for a fixed size parser
-
- Define the fields as specified in \a fields. This macro only supports fixed size
- subfields, the resulting parser will also be a fixed size parser.
-
- \ingroup packetparsermacros
- \hideinitializer
- */
-# define SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(fields) \
- SENF_PACKET_PARSER_I_DEFINE_FIXED_FIELDS(0,fields)
-
- /** \brief Define fields for a fixed size parser
-
- Define the fields as specified in \a fields. This macro only supports fixed size
- subfields, the resulting parser will also be a fixed size parser.
-
- The \a offset argument gives the byte offset at which to start parsing the fields. This
- helps defining extended parser deriving from a base parser:
- \code
- struct ExtendedParser : public BaseParser
- {
- ExtendedParser(data_iterator i, state_type s) : BaseParser(i,s) {}
-
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS_OFFSET(BaseParser::fixed_bytes,
- ( ... fields ... ) );
-
- void init() {
- BaseParser::init();
- defaultInit();
- // other init code
- }
- }
- \endcode
-
- \ingroup packetparsermacros
- \hideinitializer
- */
-# define SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS_OFFSET(offset,fields) \
- SENF_PACKET_PARSER_I_DEFINE_FIXED_FIELDS(offset,fields)
-
/** \brief Default parser parsing nothing
*/
struct VoidPacketParser
: public PacketParserBase
{
- SENF_PACKET_PARSER_INIT(VoidPacketParser);
+# include SENF_FIXED_PARSER()
+ SENF_PARSER_FINALIZE(VoidPacketParser);
};
/** \brief Iterator re-validating Parser wrapper
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketParser_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_PacketParser_i_)
#define HH_PacketParser_i_
#include "PacketParser.cci"
#include "PacketParser.ct"
+++ /dev/null
-# // Copyright (C) 2007
-# // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-# // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-# // Stefan Bund <g0dil@berlios.de>
-# //
-# // This program is free software; you can redistribute it and/or modify
-# // it under the terms of the GNU General Public License as published by
-# // the Free Software Foundation; either version 2 of the License, or
-# // (at your option) any later version.
-# //
-# // This program is distributed in the hope that it will be useful,
-# // but WITHOUT ANY WARRANTY; without even the implied warranty of
-# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# // GNU General Public License for more details.
-# //
-# // You should have received a copy of the GNU General Public License
-# // along with this program; if not, write to the
-# // Free Software Foundation, Inc.,
-# // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# /** \file
-# \brief PacketParser Boost.Preprocesser definitions */
-#
-# if !defined(MPP_PacketParser_)
-# define MPP_PacketParser_ 1
-#
-# // Custom includes
-# include <boost/preprocessor/seq/for_each_i.hpp>
-# include <boost/preprocessor/seq/for_each.hpp>
-# include <boost/preprocessor/seq/size.hpp>
-# include <boost/preprocessor/cat.hpp>
-# include <boost/preprocessor/inc.hpp>
-# include <boost/preprocessor/tuple/elem.hpp>
-# include <boost/preprocessor/facilities/expand.hpp>
-#
-# ///////////////////////////////mpp.p///////////////////////////////////////
-#
-# define SENF_PACKET_PARSER_I_UNWRAP(n,elt) (n,SENF_PACKET_PARSER_I_UNWRAP_1 elt)
-# define SENF_PACKET_PARSER_I_UNWRAP_1(x) x,SENF_PACKET_PARSER_I_UNWRAP_2
-# define SENF_PACKET_PARSER_I_UNWRAP_2(x,y) x,y
-#
-# define SENF_PACKET_PARSER_I_GET_NAME(elt) SENF_PACKET_PARSER_I_GET_NAME_1 elt
-# define SENF_PACKET_PARSER_I_GET_NAME_1(x) SENF_PACKET_PARSER_I_GET_NAME_2
-# define SENF_PACKET_PARSER_I_GET_NAME_2(name,type) name
-#
-# define SENF_PACKET_PARSER_I_GET_TYPE(elt) SENF_PACKET_PARSER_I_GET_TYPE_1 elt
-# define SENF_PACKET_PARSER_I_GET_TYPE_1(x) SENF_PACKET_PARSER_I_GET_TYPE_2
-# define SENF_PACKET_PARSER_I_GET_TYPE_2(name,type) type
-#
-# define SENF_PACKET_PARSER_I_DEFINE_INIT_C(_0,_1,elt) \
- SENF_PACKET_PARSER_I_GET_NAME(elt) ().init();
-#
-# define SENF_PACKET_PARSER_I_DEFINE_INIT(fields) \
- void defaultInit() const { \
- BOOST_PP_SEQ_FOR_EACH( SENF_PACKET_PARSER_I_DEFINE_INIT_C, _, fields) \
- }
-#
-# define SENF_PACKET_PARSER_I_FIELD_DISPATCH(n,t,name,type) \
- SENF_PACKET_PARSER_I_ ## t(n,name,type)
-#
-# define SENF_PACKET_PARSER_I_FIELD_C(_0,_1,n,elt) \
- BOOST_PP_EXPAND( \
- SENF_PACKET_PARSER_I_FIELD_DISPATCH SENF_PACKET_PARSER_I_UNWRAP(n,elt))
-#
-# define SENF_PACKET_PARSER_I_INITSIZE_C(_0,_1,n,elt) \
- BOOST_PP_IF(n,+,) senf::init_bytes< SENF_PACKET_PARSER_I_GET_TYPE(elt) >::value
-#
-# define SENF_PACKET_PARSER_I_DEFINE_FIELDS(offset,fields) \
- size_type offset_0_() const { return offset; } \
- BOOST_PP_SEQ_FOR_EACH_I(SENF_PACKET_PARSER_I_FIELD_C, _, fields) \
- size_type bytes() const { \
- return BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_SEQ_SIZE(fields),_)) (); \
- } \
- SENF_PACKET_PARSER_I_DEFINE_INIT(fields) \
- static const size_type init_bytes = \
- BOOST_PP_SEQ_FOR_EACH_I(SENF_PACKET_PARSER_I_INITSIZE_C, _, fields) ;
-#
-# define SENF_PACKET_PARSER_I_FIXED_FIELD_DISPATCH(n,t,name,type) \
- SENF_PACKET_PARSER_I_FIXED_ ## t(n,name,type)
-#
-# define SENF_PACKET_PARSER_I_FIXED_FIELD_C(_0,_1,n,elt) \
- BOOST_PP_EXPAND( \
- SENF_PACKET_PARSER_I_FIXED_FIELD_DISPATCH SENF_PACKET_PARSER_I_UNWRAP(n,elt))
-#
-# define SENF_PACKET_PARSER_I_DEFINE_FIXED_FIELDS(offset,fields) \
- static const size_type offset_0_ = offset; \
- BOOST_PP_SEQ_FOR_EACH_I(SENF_PACKET_PARSER_I_FIXED_FIELD_C, _, fields) \
- static const size_type fixed_bytes = \
- BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_SEQ_SIZE(fields),_)); \
- SENF_PACKET_PARSER_I_DEFINE_INIT(fields)
-#
-# ///////////////////////////////////////////////////////////////////////////
-# // Definition of the field types
-#
-# define SENF_PACKET_PARSER_I_Field(n,name,type) \
- typedef type BOOST_PP_CAT(name,_t) ; \
- type name () const { \
- return parse< type >( BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) () ); \
- } \
- size_type BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_INC(n),_)) () const { \
- return BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) () + senf::bytes( name () ); \
- } \
- size_type BOOST_PP_CAT(name, _offset) () const { \
- return BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) () ; \
- }
-#
-# define SENF_PACKET_PARSER_I_FIXED_Field(n,name,type) \
- typedef type BOOST_PP_CAT(name,_t) ; \
- type name () const { \
- return parse< type >( BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) ); \
- } \
- static const size_type BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_INC(n),_)) = \
- BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) + type::fixed_bytes; \
- static const size_type BOOST_PP_CAT(name,_offset) = \
- BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_));
-#
-# define SENF_PACKET_PARSER_I_OverlayField(n,name,type) \
- typedef type BOOST_PP_CAT(name,_t) ; \
- type name () const { \
- return parse< type >( BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) () ); \
- } \
- size_type BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_INC(n),_)) () const { \
- return BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) (); \
- } \
- size_type BOOST_PP_CAT(name, _offset) () const { \
- return BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) () ; \
- }
-#
-# define SENF_PACKET_PARSER_I_FIXED_OverlayField(n,name,type) \
- typedef type BOOST_PP_CAT(name,_t) ; \
- type name () const { \
- return parse< type >( BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)) ); \
- } \
- static const size_type BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_INC(n),_)) = \
- BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_)); \
- static const size_type BOOST_PP_CAT(name,_offset) = \
- BOOST_PP_CAT(offset_,BOOST_PP_CAT(n,_));
-#
-# ///////////////////////////////mpp.e///////////////////////////////////////
-# endif
-#
-# \f
-# // Local Variables:
-# // mode: c++
-# // fill-column: 100
-# // c-file-style: "senf"
-# // indent-tabs-mode: nil
-# // ispell-local-dictionary: "american"
-# // compile-command: "scons -u test"
-# // End:
struct SimpleParser : public senf::PacketParserBase
{
- SENF_PACKET_PARSER_INIT(SimpleParser);
+# include SENF_FIXED_PARSER()
+ SENF_PARSER_FINALIZE(SimpleParser);
using senf::PacketParserBase::check;
using senf::PacketParserBase::validate;
struct FooParser : public senf::PacketParserBase
{
- SENF_PACKET_PARSER_INIT(FooParser);
+# include SENF_FIXED_PARSER()
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field)( name, senf::Parse_UInt16 ))
- ((Field)( id, senf::Parse_Int32 )) );
+ SENF_PARSE_FIELD( name, senf::Parse_UInt16 );
+ SENF_PARSE_FIELD( id, senf::Parse_Int32 );
+
+ SENF_PARSER_FINALIZE(FooParser);
};
struct BarParser : public senf::PacketParserBase
{
- SENF_PACKET_PARSER_INIT(BarParser);
+# include SENF_PARSER()
+
+ SENF_PARSE_FIELD( name, senf::Parse_UInt16 );
+ SENF_PARSE_FIELD( id, senf::Parse_Int32 );
- SENF_PACKET_PARSER_DEFINE_FIELDS(
- ((Field)( name, senf::Parse_UInt16 ))
- ((Field)( id, senf::Parse_Int32 )) );
+ SENF_PARSER_FINALIZE(BarParser);
};
}
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketRegistryImpl_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_PacketRegistryImpl_i_)
#define HH_PacketRegistryImpl_i_
//#include "PacketRegistry.cci"
#include "PacketRegistry.ct"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketType_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_PacketType_i_)
#define HH_PacketType_i_
#include "PacketType.cci"
//#include "PacketType.ct"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_PacketTypes_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_PacketTypes_i_)
#define HH_PacketTypes_i_
//#include "PacketTypes.cci"
//#include "PacketTypes.ct"
#ifndef HH_Packets_
#define HH_Packets_ 1
-#define SENF_PACKETS_DECL_ONLY
+#define HH_Packets__decls_
#include "all_includes.hh"
-#undef SENF_PACKETS_DECL_ONLY
+#undef HH_Packets__decls_
#include "all_includes.hh"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseArray_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_ParseArray_i_)
#define HH_ParseArray_i_
//#include "ParseArray.cci"
#include "ParseArray.ct"
struct SomePacketParser : public senf::PacketParserBase
{
- SENF_PACKET_PARSER_INIT(SomePacketParser);
+# include SENF_FIXED_PARSER()
typedef senf::Parse_Array<2,senf::Parse_UInt24> Parse_Array2;
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field)( array, Parse_Array2 ))
- ((Field)( index, senf::Parse_UInt16 )) );
+ SENF_PARSE_FIELD( array, Parse_Array2 );
+ SENF_PARSE_FIELD( index, senf::Parse_UInt16 );
+
+ SENF_PARSER_FINALIZE(SomePacketParser);
};
struct SomeOtherParser : public senf::PacketParserBase
{
- SENF_PACKET_PARSER_INIT(SomeOtherParser);
+# include SENF_FIXED_PARSER()
typedef senf::Parse_Array<1,SomePacketParser> Parse_Array1;
- SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
- ((Field)( fields, Parse_Array1 )) );
+ SENF_PARSE_FIELD( fields, Parse_Array1 );
+
+ SENF_PARSER_FINALIZE(SomeOtherParser);
};
}
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParseHelpers public header */
+
+#ifndef HH_ParseHelpers_
+#define HH_ParseHelpers_ 1
+
+#ifndef HH_Packets_
+#error "Don't include 'ParseHelpers.hh' directly, include 'Packets.hh'"
+#endif
+
+// Custom includes
+
+//#include "ParseHelpers.mpp"
+#include "ParseHelpers.ih"
+///////////////////////////////hh.p////////////////////////////////////////
+
+/** \defgroup packetparsermacros Helper macros for defining new packet parsers
+
+ To simplify the definition of simple packet parsers, several macros are provided. Before
+ using these macros you should familiarize yourself with the packet parser interface as
+ described in senf::PacketParserBase.
+
+ These macros simplify providing the above defined interface. A typical packet declaration
+ using these macros has the following form (This is a concrete example from the definition of
+ the ethernet packet in <tt>DefaultBundle/EthernetPacket.hh</tt>)
+
+ \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.
+ \li The macros provide a definition for \c init()
+ \li The macros define the \c bytes(), \c fixed_bytes and \c init_bytes members as needed.
+
+ You may define either a fixed or a dynamically sized parser. Fixed size parsers are defined
+ using \ref SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS, dynamically sized parsers are defined
+ using \ref SENF_PACKET_PARSER_DEFINE_FIELDS. The different members are implemented such
+ that:
+
+ \li The needed parser constructor is defined
+ \li \c init() calls \c defaultInit(). \c defaultInit() is defined to call \c init() on each
+ of the fields.
+ \li \c bytes() (on dynamically sized parser) respectively \c fixed_bytes (on fixed size
+ parsers) is defined to return the sum of the sizes of all fields.
+ \li On dynamically sized parsers, \c init_bytes is defined to return the sum of the
+ \c init_size's of all fields
+
+ The central definition macros are \ref SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS and \ref
+ SENF_PACKET_PARSER_DEFINE_FIELDS. The argument to both has the same structure. It is a
+ (boost preprocessor style) sequence of field definitions where each field definition
+ provides the builder macro to use and the name and type of the field to define:
+ \code
+ SENF_PACKET_PARSER_DEFINE[_FIXED]_FIELDS(
+ (( <builder> )( <name>, <type> ))
+ ...
+ )
+ \endcode
+
+ For each field, this command will define
+ \li A method \a name() returning an instance of the \a type parser
+ \li \a name<tt>_t</tt> as a typedef for \a type, the fields value
+ \li \a name<tt>_offset</tt> to give the offset of the field from the beginning of the
+ parser. If the parser is a fixed size parser, this will be a static constant, otherwise
+ it will be a method.
+
+ The \a builder argument selects, how the field is defined
+ \li <tt>Field</tt> defines a field and increments the current position by the size of the
+ field
+ \li <tt>OverlayField</tt> defines a field like <tt>Field</tt> but does \e not increment the
+ position. In the above example, this is used to overlay the different bitfield parsers:
+ All overlaying bitfield parser except the last one (the one with the highest bit
+ numbers) is marked as OverlayField.
+
+ The \a name argument defines the name of the accessor method.
+
+ The \a type argument is the parser to return for that field. Since none of the arguments may
+ contain a comma, <em>This argument cannot be a multi-parameter template</em>. Always use
+ typedefs to access templated parsers as shown above.
+
+ The \ref SENF_PACKET_PARSER_INIT macro defines the constructor and the \c init() member. If
+ you want to provide your own \c init() implementation, use \ref
+ SENF_PACKET_PARSER_NO_INIT. The first statement in your init method should probably to call
+ \c defaultInit(). This will call the \c init() member of all the fields. Afterwards you can
+ set up the field values as needed:
+ \code
+ struct SomePacket : public senf::PacketParserBase
+ {
+ SENF_PACKET_PARSER_NO_INIT(SomePacket);
+
+ typedef senf::Parse_UInt8 Parse_Type;
+ typedef senf::Parse_Vector< senf::Parse_UInt32,
+ senf::SimpleVectorSizer<senf::Parse_UInt16>
+ > Parse_Elements;
+
+ SENF_PACKET_PARSER_DEFINE_FIELDS(
+ ((Field)( type, Parse_Type ))
+ ((Field)( elements, Parse_Elements ))
+ );
+
+ void init() const {
+ defaultInit();
+ type() = 0x01;
+ elements().push_back(0x01020304u);
+ }
+ }
+ \endcode
+
+ \ingroup packetparser
+ */
+
+#define SENF_FIXED_PARSER() SENF_ABSOLUTE_INCLUDE_PATH(Packets/parse_fixed_setup.hh)
+#define SENF_PARSER() SENF_ABSOLUTE_INCLUDE_PATH(Packets/parse_setup.hh)
+
+#define SENF_FIXED_PARSER_INITIALIZE() \
+ private: \
+ SENF_MPL_SLOT_DEF_ZERO(index); \
+ SENF_MPL_SLOT_DEF_ZERO(offset); \
+ SENF_MPL_SLOT_DEF_ZERO(bit); \
+ SENF_MPL_SLOT_DEF_ZERO(bitfield_size); \
+ void init_chain(senf::mpl::rv<0>*) {} \
+ public:
+
+#define SENF_PARSER_INITIALIZE() \
+ private: \
+ SENF_MPL_SLOT_DEF_ZERO(index); \
+ SENF_MPL_SLOT_DEF_ZERO(init_bytes); \
+ SENF_MPL_SLOT_DEF_ZERO(bit); \
+ SENF_MPL_SLOT_DEF_ZERO(bitfield_size); \
+ void init_chain(senf::mpl::rv<0>*) {} \
+ size_type field_offset_(senf::mpl::rv<0>*) const { return 0; } \
+ public:
+
+#define SENF_PARSER_FIELD(name, type) SENF_PARSER_FIELD_I(name, type, var, rw)
+#define SENF_PARSER_FIELD_RO(name, type) SENF_PARSER_FIELD_I(name, type, var, ro)
+#define SENF_PARSER_CUSTOM_FIELD(name, type, size) SENF_PARSER_CUSTOM_FIELD_I(name, type, size, var)
+
+#define SENF_PARSER_FIXED_FIELD(name, type) SENF_PARSER_FIELD_I(name, type, fix, rw)
+#define SENF_PARSER_FIXED_FIELD_RO(name, type) SENF_PARSER_FIELD_I(name, type, fix, ro)
+#define SENF_PARSER_FIXED_CUSTOM_FIELD(name, type, size) SENF_PARSER_CUSTOM_FIELD_I(name, type, size, fix)
+
+#define SENF_PARSER_FIELD_AFTER(name, type, prev) SENF_PARSER_FIELD_I_AFTER(name, type, prev, var, rw)
+#define SENF_PARSER_FIELD_RO_AFTER(name, type, prev) SENF_PARSER_FIELD_I_AFTER(name, type, prev, var, ro)
+#define SENF_PARSER_CUSTOM_FIELD_AFTER(name, type, size, prev) SENF_PARSER_CUSTOM_FIELD_I_AFTER(name, type, size, prev, var)
+
+#define SENF_PARSER_FIXED_FIELD_AFTER(name, type, prev) SENF_PARSER_FIELD_I_AFTER(name, type, prev, fix, rw)
+#define SENF_PARSER_FIXED_FIELD_RO_AFTER(name, type, prev) SENF_PARSER_FIELD_I_AFTER(name, type, prev, fix, ro)
+#define SENF_PARSER_FIXED_CUSTOM_FIELD_AFTER(name, type, size, prev) SENF_PARSER_CUSTOM_FIELD_I_AFTER(name, type, size, prev, fix)
+
+#define SENF_PARSER_BITFIELD(name, bits, type) SENF_PARSER_BITFIELD_I(name, bits, type, var, rw)
+#define SENF_PARSER_BITFIELD_RO(name, bits, type) SENF_PARSER_BITFIELD_I(name, bits, type, var, ro)
+
+#define SENF_PARSER_FIXED_BITFIELD(name, bits, type) SENF_PARSER_BITFIELD_I(name, bits, type, fix, rw)
+#define SENF_PARSER_FIXED_BITFIELD_RO(name, bits, type) SENF_PARSER_BITFIELD_I(name, bits, type, fix, ro)
+
+#define SENF_PARSER_INIT() \
+ void init(int)
+
+#define SENF_PARSER_FINALIZE_GENERIC(name, base) \
+ void defaultInit() { \
+ init_chain(static_cast<senf::mpl::rv<SENF_MPL_SLOT_GET(index)>*>(0)); \
+ } \
+ name(data_iterator i, state_type s) : base(i,s) {} \
+ private: \
+ template <class T> void init(T) { defaultInit(); } \
+ public: \
+ void init() { init(0); }
+
+#define SENF_PARSER_FINALIZE_INHERITED_DYNAMIC(name, base) \
+ SENF_PARSER_FINALIZE_GENERIC(name, base) \
+ size_type bytes() const { \
+ return field_offset_(static_cast<senf::mpl::rv<SENF_MPL_SLOT_GET(index)>*>(0)); \
+ } \
+ static size_type const init_bytes = SENF_MPL_SLOT_GET(init_bytes)
+
+#define SENF_PARSER_FINALIZE_INHERITED_FIXED(name, base) \
+ SENF_PARSER_FINALIZE_GENERIC(name, base) \
+ static size_type const fixed_bytes = SENF_MPL_SLOT_GET(offset);
+
+#define SENF_PARSER_FINALIZE_FIXED(name) \
+ SENF_PARSER_FINALIZE_INHERITED_FIXED(name, senf::PacketParserBase)
+
+#define SENF_PARSER_FINALIZE_DYNAMIC(name) \
+ SENF_PARSER_FINALIZE_INHERITED_DYNAMIC(name, senf::PacketParserBase)
+
+///////////////////////////////hh.e////////////////////////////////////////
+#endif
+#if !defined(HH_Packets__decls_) && !defined(HH_ParseHelpers_i_)
+#define HH_ParseHelpers_i_
+//#include "ParseHelpers.cci"
+//#include "ParseHelpers.ct"
+//#include "ParseHelpers.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+# // Copyright (C) 2007
+# // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+# // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+# // Stefan Bund <g0dil@berlios.de>
+# //
+# // This program is free software; you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation; either version 2 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# //
+# // You should have received a copy of the GNU General Public License
+# // along with this program; if not, write to the
+# // Free Software Foundation, Inc.,
+# // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# /** \file
+# \brief ParseHelpers internal header */
+#
+# if !defined(IH_ParseHelpers_)
+# define IH_ParseHelpers_ 1
+#
+# // Custom includes
+# include <boost/preprocessor/cat.hpp>
+# include <boost/preprocessor/facilities/expand.hpp>
+# include "../Utils/mpl.hh"
+#
+# ////////////////////////////////ih.p///////////////////////////////////////
+#
+# define SENF_PARSER_I_FIELD_INTRO(name, type) \
+ typedef type BOOST_PP_CAT(name, _t); \
+ static size_type const BOOST_PP_CAT(name,_index) = SENF_MPL_SLOT_GET(index)+1; \
+ private: \
+ SENF_MPL_SLOT_SET(index, BOOST_PP_CAT(name,_index)); \
+ public:
+#
+# define SENF_PARSER_I_FIELD_INIT_rw(name, type) \
+ private: \
+ void init_chain(senf::mpl::rv<BOOST_PP_CAT(name,_index)>*) { \
+ init_chain(static_cast<senf::mpl::rv<BOOST_PP_CAT(name,_index)-1>*>(0)); \
+ name().init(); \
+ } \
+ public:
+#
+# define SENF_PARSER_I_FIELD_INIT_ro(name, type) \
+ private: \
+ void init_chain(senf::mpl::rv<BOOST_PP_CAT(name,_index)>*) { \
+ init_chain(static_cast<senf::mpl::rv<BOOST_PP_CAT(name,_index)-1>*>(0)); \
+ } \
+ public:
+#
+# define SENF_PARSER_I_SIZE_var(name, type) senf::bytes(name())
+# define SENF_PARSER_I_INITBYTES_var(name, type) senf::init_bytes<type>::value
+#
+# define SENF_PARSER_I_ADVANCE_OFS_var(name, type, size, isize) \
+ private: \
+ size_type BOOST_PP_CAT(name, _next_offset)() const { \
+ return BOOST_PP_CAT(name,_offset)() + size; \
+ } \
+ size_type field_offset_(senf::mpl::rv<BOOST_PP_CAT(name,_index)>*) const { \
+ return BOOST_PP_CAT(name, _next_offset)(); \
+ } \
+ SENF_MPL_SLOT_SET(init_bytes, SENF_MPL_SLOT_GET(init_bytes) + isize); \
+ public:
+#
+# define SENF_PARSER_I_FIELD_OFS_var(name, type) \
+ size_type BOOST_PP_CAT(name,_offset)() const { \
+ return field_offset_(static_cast<senf::mpl::rv<BOOST_PP_CAT(name,_index)-1>*>(0)); \
+ }
+#
+# define SENF_PARSER_I_FIELD_OFS_AFTER_var(name, type, prev) \
+ size_type BOOST_PP_CAT(name,_offset)() const { \
+ return BOOST_PP_CAT(prev,_next_offset)(); \
+ }
+#
+# define SENF_PARSER_I_SIZE_fix(name, type) type::fixed_bytes
+# define SENF_PARSER_I_INITBYTES_fix(name, type) void
+#
+# define SENF_PARSER_I_ADVANCE_OFS_fix(name, type, size, isize) \
+ private: \
+ static size_type const BOOST_PP_CAT(name, _next_offset) = \
+ BOOST_PP_CAT(name, _offset) + size; \
+ SENF_MPL_SLOT_SET(offset, BOOST_PP_CAT(name, _next_offset)); \
+ public:
+#
+# define SENF_PARSER_I_FIELD_OFS_fix(name, type) \
+ static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset);
+#
+# define SENF_PARSER_I_FIELD_OFS_AFTER_fix(name, type, prev) \
+ static size_type const BOOST_PP_CAT(name, _offset) = BOOST_PP_CAT(prev, _next_offset);
+#
+# define SENF_PARSER_I_MAYBECALL_var() ()
+# define SENF_PARSER_I_MAYBECALL_fix()
+#
+# define SENF_PARSER_I_FIELD_VAL_rw(name,type,ofstype) \
+ BOOST_PP_CAT(name, _t) name() const { \
+ return parse<type>( \
+ BOOST_PP_CAT(name,_offset) BOOST_PP_CAT(SENF_PARSER_I_MAYBECALL_, ofstype)()); \
+ }
+#
+# define SENF_PARSER_I_FIELD_VAL_ro(name,type,ofstype) \
+ BOOST_PP_CAT(name, _t)::value_type name() const { \
+ return parse<type>( \
+ BOOST_PP_CAT(name,_offset) BOOST_PP_CAT(SENF_PARSER_I_MAYBECALL_, ofstype)() \
+ .value() \
+ }
+#
+# define SENF_PARSER_FIELD_I(name, type, ofstype, rwtype) \
+ SENF_PARSER_I_BITFIELD_RESET() \
+ SENF_PARSER_I_FIELD_INTRO(name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_INIT_, rwtype) (name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_OFS_, ofstype) (name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) ( \
+ name, type, \
+ BOOST_PP_CAT(SENF_PARSER_I_SIZE_, ofstype) (name, type), \
+ BOOST_PP_CAT(SENF_PARSER_I_INITBYTES_, ofstype) (name, type) ) \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_VAL_, rwtype) (name, type, ofstype)
+#
+# define SENF_PARSER_FIELD_I_AFTER(name, type, prev, ofstype, rwtype) \
+ SENF_PARSER_I_BITFIELD_RESET() \
+ SENF_PARSER_I_FIELD_INTRO(name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_INIT_, rwtype) (name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_OFS_AFTER_, ofstype) (name, type, prev); \
+ BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) ( \
+ name, type, \
+ BOOST_PP_CAT(SENF_PARSER_I_SIZE_, ofstype) (name, type), \
+ BOOST_PP_CAT(SENF_PARSER_I_INITBYTES_, ofstype) (name, type) ) \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_VAL_, rwtype) (name, type, ofstype)
+#
+# define SENF_PARSER_CUSTOM_FIELD_I(name, type, size, isize, ofstype) \
+ SENF_PARSER_I_BITFIELD_RESET() \
+ SENF_PARSER_I_FIELD_INTRO(name, type) \
+ SENF_PARSER_I_FIELD_INIT_ro(name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_OFS_, ofstype) (name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) (name, type, size, isize) \
+ BOOST_PP_CAT(name, _t) name() const
+#
+# define SENF_PARSER_CUSTOM_FIELD_I_AFTER(name, type, size, isize, prev, ofstype) \
+ SENF_PARSER_I_BITFIELD_RESET() \
+ SENF_PARSER_I_FIELD_INTRO(name, type) \
+ SENF_PARSER_I_FIELD_INIT_ro(name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_OFS_AFTER, ofstype) (name, type, prev) \
+ BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) (name, type, size) \
+ BOOST_PP_CAT(name, _t) name() const
+#
+# define SENF_PARSER_I_BITFIELD_RESET() \
+ SENF_MPL_SLOT_SET(bit, 0); \
+ SENF_MPL_SLOT_SET(bitfield_size, 0);
+#
+# define SENF_PARSER_BITFIELD_I(name, bits, type, ofstype, rwtype) \
+ static size_type const BOOST_PP_CAT(name, _bit) = SENF_MPL_SLOT_GET(bit); \
+ private: \
+ SENF_MPL_SLOT_SET(bit, BOOST_PP_CAT(name, _bit) + bits); \
+ typedef BOOST_PP_CAT(SENF_PARSER_BITFIELD_TYPE_, type)( BOOST_PP_CAT(name, _bit), bits ) \
+ BOOST_PP_CAT(name,_bit_t ); \
+ public: \
+ SENF_PARSER_BITFIELD_II( name, bits, BOOST_PP_CAT(name, _bit_t), ofstype, rwtype)
+#
+# define SENF_PARSER_BITFIELD_TYPE_signed(start, bits) senf::Parse_IntField<start, start+bits>
+# define SENF_PARSER_BITFIELD_TYPE_unsigned(start, bits) senf::Parse_UIntField<start, start+bits>
+# define SENF_PARSER_BITFIELD_TYPE_bool(start, bits) senf::Parse_Flag<start>
+#
+# define SENF_PARSER_BITFIELD_II(name, bits, type, ofstype, rwtype) \
+ SENF_PARSER_I_FIELD_INTRO(name, type) \
+ SENF_PARSER_I_FIELD_INIT_ro(name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_BITFIELD_OFS_, ofstype) (name, type) \
+ BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) ( \
+ name, type, \
+ BOOST_PP_CAT(name, _t)::fixed_bytes, BOOST_PP_CAT(name, _t)::fixed_bytes ) \
+ private: \
+ SENF_MPL_SLOT_SET(bitfield_size, BOOST_PP_CAT(name, _t)::fixed_bytes); \
+ public: \
+ BOOST_PP_CAT(SENF_PARSER_I_FIELD_VAL_, rwtype) (name, type, ofstype)
+#
+# define SENF_PARSER_I_BITFIELD_OFS_var(name, type) \
+ size_type BOOST_PP_CAT(name,_offset)() const { \
+ return field_offset_(static_cast<senf::mpl::rv<BOOST_PP_CAT(name,_index)-1>*>(0)) \
+ - SENF_MPL_SLOT_GET(bitfield_size); \
+ }
+#
+# define SENF_PARSER_I_BITFIELD_OFS_fix(name, type) \
+ static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset) \
+ - SENF_MPL_SLOT_GET(bitfield_size);
+#
+# define SENF_PARSER_INHERIT_I(name) \
+ private: \
+ SENF_MPL_SLOT_SET(index, 1); \
+ SENF_MPL_SLOT_SET(init_bytes, senf::init_bytes<name>::value); \
+ size_type field_offset_(senf::mpl::rv<1>*) const { \
+ return senf::bytes( *static_cast<name*>(this) ); \
+ } \
+ void init_chain(senf::mpl::rv<inherit_index_>*) { \
+ name::init(); \
+ } \
+ public:
+#
+# define SENF_PARSER_FIXED_INHERIT_I(name) \
+ private: \
+ SENF_MPL_SLOT_SET(offset, name::fixed_bytes); \
+ SENF_MPL_SLOT_SET(index, 1); \
+ void init_chain(senf::mpl::rv<1>*) { \
+ name::init(); \
+ } \
+ public:
+#
+#
+# ////////////////////////////////ih.e///////////////////////////////////////
+# endif
+#
+#
+# // Local Variables:
+# // mode: c++
+# // fill-column: 100
+# // c-file-style: "senf"
+# // indent-tabs-mode: nil
+# // ispell-local-dictionary: "american"
+# // compile-command: "scons -u test"
+# // End:
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseInt_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_ParseInt_i_)
#define HH_ParseInt_i_
//#include "ParseInt.cci"
//#include "ParseInt.ct"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseList_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_ParseList_i_)
#define HH_ParseList_i_
//#include "ParseList.cci"
#include "ParseList.ct"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseListB_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_ParseListB_i_)
#define HH_ParseListB_i_
//#include "ParseListB.cci"
//#include "ParseListB.ct"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseListN_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_ParseListN_i_)
#define HH_ParseListN_i_
//#include "ParseListN.cci"
#include "ParseListN.ct"
///////////////////////////////hh.e////////////////////////////////////////
#endif
-#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseVec_i_)
+#if !defined(HH_Packets__decls_) && !defined(HH_ParseVec_i_)
#define HH_ParseVec_i_
//#include "ParseVec.cci"
#include "ParseVec.ct"
###########################################################################
SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh")
- if 'defined(SENF_PACKETS_DECL_ONLY)' in file(f).read() ])
+ if 'defined(HH_Packets__decls_)' in file(f).read() ])
SENFSCons.StandardTargets(env)
SENFSCons.Lib(env,
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief parse_fixed_setup public header */
+
+#ifdef SENF_PARSER_SETUP_INCLUDED
+# undef SENF_PARSE_FIELD
+# undef SENF_PARSE_FIELD_RO
+# undef SENF_PARSE_FIELD_AFTER
+# undef SENF_PARSE_FIELD_AFTER_RO
+# undef SENF_PARSE_CUSTOM_FIELD
+# undef SENF_PARSE_CUSTOM_FIELD_AFTER
+# undef SENF_PARSE_BITFIELD
+# undef SENF_PARSE_BITFIELD_RO
+# undef SENF_PARSER_INHERIT
+# undef SENF_PARSER_FINALIZE
+# undef SENF_PARSER_FINALIZE_INHERITED
+# undef SENF_PARSER_SETUP_INCLUDED
+#endif
+
+#define SENF_PARSE_FIELD SENF_PARSER_FIXED_FIELD
+#define SENF_PARSE_FIELD_RO SENF_PARSER_FIXED_FIELD_RO
+#define SENF_PARSE_FIELD_AFTER SENF_PARSER_FIXED_FIELD_AFTER
+#define SENF_PARSE_FIELD_AFTER_RO SENF_PARSER_FIXED_FIELD_AFTER_RO
+#define SENF_PARSE_CUSTOM_FIELD SENF_PARSER_FIXED_CUSTOM_FIELD
+#define SENF_PARSE_CUSTOM_FIELD_AFTER SENF_PARSER_FIXED_CUSTOM_FIELD_AFTER
+#define SENF_PARSE_BITFIELD SENF_PARSER_FIXED_BITFIELD
+#define SENF_PARSE_BITFIELD_RO SENF_PARSER_FIXED_BITFIELD_RO
+
+#define SENF_PARSER_INHERIT SENF_PARSER_FIXED_INHERIT_I
+#define SENF_PARSER_FINALIZE SENF_PARSER_FINALIZE_FIXED
+#define SENF_PARSER_FINALIZE_INHERITED SENF_PARSER_FINALIZE_INHERITED_FIXED
+
+#define SENF_PARSER_SETUP_INCLUDED 1
+
+SENF_FIXED_PARSER_INITIALIZE()
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief parse_setup public header */
+
+#ifdef SENF_PARSER_SETUP_INCLUDED
+# undef SENF_PARSE_FIELD
+# undef SENF_PARSE_FIELD_RO
+# undef SENF_PARSE_FIELD_AFTER
+# undef SENF_PARSE_FIELD_AFTER_RO
+# undef SENF_PARSE_CUSTOM_FIELD
+# undef SENF_PARSE_CUSTOM_FIELD_AFTER
+# undef SENF_PARSE_BITFIELD
+# undef SENF_PARSE_BITFIELD_RO
+# undef SENF_PARSER_INHERIT
+# undef SENF_PARSER_FINALIZE
+# undef SENF_PARSER_FINALIZE_INHERITED
+# undef SENF_PARSER_SETUP_INCLUDED
+#endif
+
+#define SENF_PARSE_FIELD SENF_PARSER_FIELD
+#define SENF_PARSE_FIELD_RO SENF_PARSER_FIELD_RO
+#define SENF_PARSE_FIELD_AFTER SENF_PARSER_FIELD_AFTER
+#define SENF_PARSE_FIELD_AFTER_RO SENF_PARSER_FIELD_AFTER_RO
+#define SENF_PARSE_CUSTOM_FIELD SENF_PARSER_CUSTOM_FIELD
+#define SENF_PARSE_CUSTOM_FIELD_AFTER SENF_PARSER_CUSTOM_FIELD_AFTER
+#define SENF_PARSE_BITFIELD SENF_PARSER_BITFIELD
+#define SENF_PARSE_BITFIELD_RO SENF_PARSER_BITFIELD_RO
+
+#define SENF_PARSER_INHERIT SENF_PARSER_INHERIT_I
+#define SENF_PARSER_FINALIZE SENF_PARSER_FINALIZE_DYNAMIC
+#define SENF_PARSER_FINALIZE_INHERITED SENF_PARSER_FINALIZE_INHERITED_DYNAMIC
+
+#define SENF_PARSER_SETUP_INCLUDED 1
+
+SENF_PARSER_INITIALIZE()
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
SENFSCons.StandardTargets(env)
SENFSCons.AllIncludesHH(env, [ f for f in glob.glob("*.hh")
- if f not in ('all_includes.hh','INet.hh') and not f.endswith('.test.hh') ])
+ if ( f not in ('all_includes.hh','Logger.hh')
+ and not f.endswith('.test.hh') ) ])
sources = SENFSCons.GlobSources()
objects = SENFSCons.Objects( env, sources = sources, LIBS = [ 'Utils' ] )
static senf::mpl::rv<0> _SENF_MPL_SLOT_ ## name (_); \
SENF_MPL_SLOT_SET(name,value)
+ /** \brief Define MPL slot initialized to 0
+
+ This is like \ref SENF_MPL_SLOT_DEF() but initializes the slot to the fixed value 0. The
+ advantage over \ref SENF_MPL_SLOT_DEF() is, that this macro may be called from an include
+ file whereas all the other \\c SENF_MPL_SLOT_ macros must always be called from the relevant
+ file.
+ */
+# define SENF_MPL_SLOT_DEF_ZERO(name) \
+ template <class _> \
+ static senf::mpl::rv<0> _SENF_MPL_SLOT_ ## name (_);
+
/** \brief Set MPL slot
\see \ref SENF_MPL_SLOT_DEF()
\ingroup senfmpl
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
-PREDEFINED = DOXYGEN SENF_PPI_MODULE(x)=
+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_FINALIZE(name)=" \
+ "SENF_PARSER_INIT()=void init()"
EXPAND_AS_DEFINED = prefix_
HTML_HEADER = "$(TOPDIR)/doclib/doxy-header.html"
-name .test.bin -o \
-name "*.stamp" -o \
-name ".sconsign*" -o \
+ -name "semantic.cache" -o \
+ -name "all_includes.hh" -o \
-type f $cond \( "$@" \)