From: tho Date: Thu, 25 Jun 2009 08:13:38 +0000 (+0000) Subject: Packets/80221Bundle: added messageId field to MIHPacket X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=474bf4ca752caa4edad3eb007f8dca7a19a47335 Packets/80221Bundle: added messageId field to MIHPacket git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1238 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Makefile b/Makefile index f423bb5..eeb0d80 100644 --- a/Makefile +++ b/Makefile @@ -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 @, ,$@))" diff --git a/Packets/80221Bundle/MIHPacket.cc b/Packets/80221Bundle/MIHPacket.cc index 7cb720c..f2e6124 100644 --- a/Packets/80221Bundle/MIHPacket.cc +++ b/Packets/80221Bundle/MIHPacket.cc @@ -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::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"; } diff --git a/Packets/80221Bundle/MIHPacket.hh b/Packets/80221Bundle/MIHPacket.hh index 5f4f997..99b89e8 100644 --- a/Packets/80221Bundle/MIHPacket.hh +++ b/Packets/80221Bundle/MIHPacket.hh @@ -97,6 +97,11 @@ namespace senf { return boost::make_filter_iterator(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 + public PacketTypeMixin { #ifndef DOXYGEN - typedef PacketTypeMixin mixin; + typedef PacketTypeMixin mixin; #endif typedef ConcretePacket 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 diff --git a/Packets/80221Bundle/MIHPacket.test.cc b/Packets/80221Bundle/MIHPacket.test.cc index 3b021ee..91c6dc5 100644 --- a/Packets/80221Bundle/MIHPacket.test.cc +++ b/Packets/80221Bundle/MIHPacket.test.cc @@ -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