#----------------------------------------------------------------------
JOBS := 1
-all@% all_docs@% all_test@% build@%:
+all@% all_docs@% all_tests@% build@%:
ssh $* "cd `pwd` && $(MAKE) -j $(JOBS) $(firstword $(subst @, ,$@))"
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);
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";
}
return boost::make_filter_iterator<binaryNAIDecoder>(begin, end);
}
};
+
+ struct MIHMessageRegistry {
+ // MIH messages registry
+ typedef boost::uint16_t key_t;
+ };
/** \brief Parse a MIH packet
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
*/
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
#endif
+\f
// Local Variables:
// mode: c++
// fill-column: 100
///////////////////////////////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());
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 };
tlv1->type() = 0x42;
tlv1->value( tlv2_value);
tlv1.finalizeThis();
- mihPayload->tlv_list().push_front( tlv1.parser());
+ mihPayload->tlv_list().push_front( tlv1);
mihPacket.finalizeAll();
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
-
+\f
// Local Variables:
// mode: c++
// fill-column: 100