From: tho Date: Tue, 6 Jan 2009 12:29:07 +0000 (+0000) Subject: first steps to a MIHPacket X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=45f1f7608c81c1d5e417c97a3e9273e0282d6a0d;p=senf.git first steps to a MIHPacket git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1037 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/80221Bundle/MIHPacket.cc b/Packets/80221Bundle/MIHPacket.cc index 3e173a8..1a398f1 100644 --- a/Packets/80221Bundle/MIHPacket.cc +++ b/Packets/80221Bundle/MIHPacket.cc @@ -27,11 +27,33 @@ //#include "MIHPacket.ih" // Custom includes - +#include "MIHPacket.hh" +#include "../../Packets/Packets.hh" +#include #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_ diff --git a/Packets/80221Bundle/MIHPacket.hh b/Packets/80221Bundle/MIHPacket.hh index 2021102..a2c7ceb 100644 --- a/Packets/80221Bundle/MIHPacket.hh +++ b/Packets/80221Bundle/MIHPacket.hh @@ -34,6 +34,48 @@ 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 + { + typedef PacketTypeMixin mixin; + typedef ConcretePacket 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 MIHPacket; }