Skip to content
Snippets Groups Projects
Commit a8684be9 authored by g0dil's avatar g0dil
Browse files

Packets: Remove direct Socket dependency

Packets: BUGFIX: Fix init_bytes caculation on dynamic parser bitfields
parent 1c336fcc
No related branches found
No related tags found
No related merge requests found
......@@ -6,5 +6,4 @@ INPUT = .
EXAMPLE_PATH = . DefaultBundle
TAGFILES = \
"$(TOPDIR)/Socket/doc/Socket.tag" \
"$(TOPDIR)/Utils/doc/Utils.tag"
......@@ -22,11 +22,11 @@
// Unit tests
//#include "TransportPacket.test.hh"
//#include "TransportPacket.test.ih"
//#include "GREPacket.test.hh"
//#include "GREPacket.test.ih"
// Custom includes
#include "TransportPacket.hh"
#include "GREPacket.hh"
#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
......@@ -38,45 +38,10 @@ using namespace senf;
BOOST_AUTO_UNIT_TEST(GREPacket_packet)
{
// TransportStream-Packet containing a ULE encoded IPv6 ping packet,
// captured with dvbsnoop
unsigned char data[] = {
0x47, 0x41, 0x0f, 0x1e, 0x00, 0x80, 0x4c, 0x86,
0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11,
0x40, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68,
0xaf, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x04 ,0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58,
0xe1, 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01,
0x00, 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
0x00, 0x1d, 0xc4, 0xe8, 0xc1, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff
};
senf::TransportPacket p (senf::TransportPacket::create(data));
senf::GREPacket p (senf::GREPacket::create());
BOOST_CHECK_EQUAL( p->sync_byte(), TRANSPORT_PACKET_SYNC_BYTE );
BOOST_CHECK( ! p->transport_error_indicator() );
BOOST_CHECK( p->pusi() );
BOOST_CHECK( ! p->transport_priority() );
BOOST_CHECK_EQUAL( p->pid(), 0x010fu );
BOOST_CHECK_EQUAL( p->transport_scrmbl_ctrl(), 0x0u );
BOOST_CHECK_EQUAL( p->adaptation_field_ctrl(), 0x1u );
BOOST_CHECK_EQUAL( p->continuity_counter(), 0x0eu );
BOOST_CHECK_EQUAL( senf::Parse_GREPacket::init_bytes+0u, 4u );
//BOOST_CHECK_EQUAL( p->bytes(), 4u );
}
///////////////////////////////cc.e////////////////////////////////////////
......
......@@ -142,7 +142,8 @@
# define SENF_PARSER_I_FIELD_OFS_var(name, type, access) \
size_type BOOST_PP_CAT(name,_offset)() const { \
return field_offset_(static_cast<senf::mpl::rv<BOOST_PP_CAT(name,_index)-1>*>(0)); \
}
} \
static size_type const BOOST_PP_CAT(name, _init_bytes) = SENF_MPL_SLOT_GET(init_bytes);
#
# define SENF_PARSER_I_FIELD_OFS_fix(name, type, access) \
static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset);
......@@ -161,7 +162,6 @@
size_type BOOST_PP_CAT(name, _next_offset)() const { \
return BOOST_PP_CAT(name,_offset)() + size; \
} \
static size_type const BOOST_PP_CAT(name, _init_bytes) = SENF_MPL_SLOT_GET(init_bytes); \
static size_type const BOOST_PP_CAT(name, _next_init_bytes) = \
BOOST_PP_CAT(name, _init_bytes) + isize; \
private: \
......@@ -211,22 +211,22 @@
# // SENF_PARSER_BITFIELD_*
# // SENF_PARSER_P_BITFIELD_*
#
# define SENF_PARSER_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_PARSER_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_PARSER_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_PARSER_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) \
# 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) \
# 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) \
# 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) \
# define SENF_PARSER_P_BITFIELD_RO_fix(name, bits, type) \
SENF_PARSER_BITFIELD_I(name, bits, type, fix, ro, private)
#
# ////////////////////////////////////////
......@@ -268,7 +268,9 @@
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); \
}
} \
static size_type const BOOST_PP_CAT(name, _init_bytes) = SENF_MPL_SLOT_GET(init_bytes) \
- SENF_MPL_SLOT_GET(bitfield_size);
#
# define SENF_PARSER_I_BITFIELD_OFS_fix(name, type, access) \
static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset) \
......@@ -334,16 +336,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_PARSER_I_GOTO_SET_OFS_, ofstype ) (name, offset, initsize) \
BOOST_PP_CAT( SENF_PARSER_I_GOTO_SET_OFS_, ofstype ) (name, offset, initsize) \
public:
#
# define SENF_PARSER_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<BOOST_PP_CAT(name,_index)>*) const { \
return offs; \
} \
SENF_MPL_SLOT_SET(init_bytes, initsize);
#
# define SENF_PARSER_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);
#
# ///////////////////////////////////////////////////////////////////////////
......@@ -399,7 +401,7 @@
} \
name(data_iterator i, state_type s) : parser_base_type(i,s) {} \
private: \
template <class T> void init(T) const { defaultInit(); } \
template <class T> void init(T) const { defaultInit(); } \
public: \
void init() const { init(0); }
#
......
......@@ -12,7 +12,7 @@ SENFSCons.StandardTargets(env)
SENFSCons.Lib(env,
library = 'Packets',
sources = SENFSCons.GlobSources(),
LIBS = [ 'Socket', 'Utils' ])
LIBS = [ 'Utils' ])
SENFSCons.Doxygen(env, extra_sources = [
env.Dia2Png("structure.dia")
])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment