first steps to a MIHPacket
tho [Tue, 6 Jan 2009 12:29:07 +0000 (12:29 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1037 270642c3-0616-0410-b53a-bc976706d245

Packets/80221Bundle/MIHPacket.cc
Packets/80221Bundle/MIHPacket.hh

index 3e173a8..1a398f1 100644 (file)
 //#include "MIHPacket.ih"
 
 // Custom includes
-
+#include "MIHPacket.hh"
+#include "../../Packets/Packets.hh"
+#include <boost/io/ios_state.hpp>
 
 #define prefix_
 
 
+prefix_ void senf::MIHPacketType::dump(packet p, std::ostream &os)
+{
+    boost::io::ios_all_saver ias(os);
+    os << "MIH Packet:\n"
+       << "  protocol header:\n" << "\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";
+}
+
+
 
 #undef prefix_
 
index 2021102..a2c7ceb 100644 (file)
 
 namespace senf {
 
+    struct MIHPacketParser : public senf::PacketParserBase
+    {
+    #   include SENF_PARSER()
+        
+        SENF_PARSER_BITFIELD  ( version,       4,  unsigned );
+        SENF_PARSER_BITFIELD  ( ackRequest,    1,  bool     );
+        SENF_PARSER_BITFIELD  ( ackResponse,   1,  bool     );
+        SENF_PARSER_BITFIELD  ( uir,           1,  bool     );
+        SENF_PARSER_BITFIELD  ( moreFragment,  1,  bool     );
+        SENF_PARSER_BITFIELD  ( fragmentNr,    7,  unsigned );
+        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_SKIP_BITS ( 4                           );
+        SENF_PARSER_BITFIELD  ( transactionId, 12, unsigned );
+        SENF_PARSER_FIELD_RO  ( payloadLength, UInt16Parser );
+        
+        SENF_PARSER_FINALIZE ( MIHPacketParser );
+    };
+    
+    
+    struct MIHPacketType
+        : public PacketTypeBase,
+          public PacketTypeMixin<MIHPacketType>
+    {
+        typedef PacketTypeMixin<MIHPacketType> mixin;
+        typedef ConcretePacket<MIHPacketType> packet;
+        typedef MIHPacketParser parser;
+
+        using mixin::nextPacketRange;
+        using mixin::init;
+        using mixin::initSize;
+
+        static void dump(packet p, std::ostream &os);
+//        static void finalize(packet p);
+    };
+
+    typedef ConcretePacket<MIHPacketType> MIHPacket;
 }