Skip to content
Snippets Groups Projects
Commit 55f89905 authored by tho's avatar tho
Browse files

Packets/80221Bundle: added messageId field to MIHPacket

parent 7160dc15
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ all_docs all_tests all:
#----------------------------------------------------------------------
JOBS := 1
all@% all_docs@% all_test@% build@%:
all@% all_docs@% all_tests@% build@%:
ssh $* "cd `pwd` && $(MAKE) -j $(JOBS) $(firstword $(subst @, ,$@))"
......
......@@ -97,27 +97,27 @@ prefix_ void senf::MIHPacketType::dump(packet p, std::ostream &os)
boost::io::ios_all_saver ias(os);
os << "MIH Packet:\n"
<< " protocol header:\n"
<< " Version: " << unsigned( p->version()) << "\n"
<< " Ack-Request: " << p->ackRequest() << "\n"
<< " Ack-Response: " << p->ackResponse() << "\n"
<< " UIR: " << p->uir() << "\n"
<< " more fragment: " << p->moreFragment() << "\n"
<< " fragment number: " << p->fragmentNr() << "\n"
<< " message ID (MID):\n"
<< " SID: " << unsigned( p->sid()) << "\n"
<< " Opcode: " << unsigned( p->opcode()) << "\n"
<< " AID: " << unsigned( p->aid()) << "\n"
<< " Transaction ID: " << unsigned( p->transactionId()) << "\n"
<< " payload length: " << unsigned( p->payloadLength()) << "\n"
<< " Version: " << unsigned( p->version()) << "\n"
<< " Ack-Request: " << p->ackRequest() << "\n"
<< " Ack-Response: " << p->ackResponse() << "\n"
<< " UIR: " << p->uir() << "\n"
<< " more fragment: " << p->moreFragment() << "\n"
<< " fragment number: " << p->fragmentNr() << "\n"
<< " message ID (MID): " << unsigned( p->messageId()) << "\n"
<< " SID: " << unsigned( p->sid()) << "\n"
<< " Opcode: " << unsigned( p->opcode()) << "\n"
<< " AID: " << unsigned( p->aid()) << "\n"
<< " Transaction ID: " << unsigned( p->transactionId()) << "\n"
<< " payload length: " << unsigned( p->payloadLength()) << "\n"
<< " source MIHF_Id TLV:\n"
<< " type: " << unsigned (p->src_mihfId().type()) << "\n"
<< " length: " << unsigned (p->src_mihfId().length()) << "\n"
<< " type: " << unsigned (p->src_mihfId().type()) << "\n"
<< " length: " << unsigned (p->src_mihfId().length()) << "\n"
<< " value:\n";
std::string src_mihfId (p->src_mihfId().asString());
hexdump(src_mihfId.begin(), src_mihfId.end(), os);
os << " destination MIHF_Id TLV:\n"
<< " type: " << unsigned (p->dst_mihfId().type()) << "\n"
<< " length: " << unsigned (p->dst_mihfId().length()) << "\n"
<< " type: " << unsigned (p->dst_mihfId().type()) << "\n"
<< " length: " << unsigned (p->dst_mihfId().length()) << "\n"
<< " value:\n";
std::string dst_mihfId (p->dst_mihfId().asString());
hexdump(dst_mihfId.begin(), dst_mihfId.end(), os);
......@@ -134,14 +134,18 @@ prefix_ void senf::MIHPacketType::finalize(packet p)
prefix_ senf::PacketInterpreterBase::factory_t senf::MIHPacketType::nextPacketType(packet p)
{
return MIHPayloadPacket::factory();
if (p.data().size() < initSize())
return no_factory();
PkReg_Entry const * e (PacketRegistry<MIHMessageRegistry>::lookup( p->messageId(), nothrow ));
return e ? e->factory() : MIHPayloadPacket::factory();
}
prefix_ void senf::MIHPayloadPacketType::dump(packet p, std::ostream &os)
{
boost::io::ios_all_saver ias(os);
os << "MIH Payload (service specific TLVs):\n";
os << "MIH Payload (service specific TLVs):\n"
<< " ToDo!\n";
}
......
......@@ -97,6 +97,11 @@ namespace senf {
return boost::make_filter_iterator<binaryNAIDecoder>(begin, end);
}
};
struct MIHMessageRegistry {
// MIH messages registry
typedef boost::uint16_t key_t;
};
/** \brief Parse a MIH packet
......@@ -118,14 +123,18 @@ namespace senf {
SENF_PARSER_SKIP_BITS ( 1 );
// MIH message ID (MID)
SENF_PARSER_BITFIELD ( sid, 4, unsigned );
SENF_PARSER_BITFIELD ( opcode, 2, unsigned );
SENF_PARSER_BITFIELD ( aid, 10, unsigned );
SENF_PARSER_LABEL ( msgId_begin)
SENF_PARSER_BITFIELD ( sid, 4, unsigned );
SENF_PARSER_BITFIELD ( opcode, 2, unsigned );
SENF_PARSER_BITFIELD ( aid, 10, unsigned );
SENF_PARSER_GOTO ( msgId_begin );
SENF_PARSER_FIELD ( messageId, UInt16Parser );
SENF_PARSER_SKIP_BITS ( 4 );
SENF_PARSER_BITFIELD ( transactionId, 12, unsigned );
SENF_PARSER_FIELD_RO ( payloadLength, UInt16Parser );
// Source MIHF Id
SENF_PARSER_FIELD ( src_mihfId, MIHFId_TLVParser );
// Destination MIHF Id
......@@ -154,10 +163,10 @@ namespace senf {
*/
struct MIHPacketType
: public PacketTypeBase,
public PacketTypeMixin<MIHPacketType>
public PacketTypeMixin<MIHPacketType, MIHMessageRegistry>
{
#ifndef DOXYGEN
typedef PacketTypeMixin<MIHPacketType> mixin;
typedef PacketTypeMixin<MIHPacketType, MIHMessageRegistry> mixin;
#endif
typedef ConcretePacket<MIHPacketType> packet; ///< MIH packet typedef
typedef MIHPacketParser parser; ///< typedef to the parser of MIH packet
......@@ -216,6 +225,7 @@ namespace senf {
#endif
// Local Variables:
// mode: c++
// fill-column: 100
......
......@@ -36,6 +36,15 @@
///////////////////////////////cc.p////////////////////////////////////////
using namespace senf;
BOOST_AUTO_UNIT_TEST(MIHPacket_msgId)
{
MIHPacket mihPacket (MIHPacket::create());
mihPacket->sid() = 4;
mihPacket->opcode() = 3;
mihPacket->aid() = 42;
BOOST_CHECK_EQUAL( mihPacket->messageId(), 0x4c2a );
}
BOOST_AUTO_UNIT_TEST(MIHPacket_create_string)
{
MIHPacket mihPacket (MIHPacket::create());
......@@ -237,7 +246,7 @@ BOOST_AUTO_UNIT_TEST(MIHPayload_create)
tlv2->type() = 0x43;
tlv2->value( tlv1_value);
tlv2.finalizeThis();
mihPayload->tlv_list().push_front( tlv2.parser());
mihPayload->tlv_list().push_front( tlv2);
unsigned char tlv2_value[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
......@@ -245,7 +254,7 @@ BOOST_AUTO_UNIT_TEST(MIHPayload_create)
tlv1->type() = 0x42;
tlv1->value( tlv2_value);
tlv1.finalizeThis();
mihPayload->tlv_list().push_front( tlv1.parser());
mihPayload->tlv_list().push_front( tlv1);
mihPacket.finalizeAll();
......@@ -278,7 +287,7 @@ BOOST_AUTO_UNIT_TEST(MIHPayload_create)
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
// Local Variables:
// mode: c++
// fill-column: 100
......
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