Packets/80221Bundle: added messageId field to MIHPacket
[senf.git] / Packets / 80221Bundle / MIHPacket.cc
index 7cb720c..f2e6124 100644 (file)
@@ -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";
 }