4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief MIH protocol public header */
26 #ifndef HH_SENF_Packets_80221Bundle_MIHPacket_
27 #define HH_SENF_Packets_80221Bundle_MIHPacket_ 1
30 #include <senf/Packets/Packets.hh>
31 #include "TLVParser.hh"
32 #include "MIHMessageRegistry.hh"
34 //#include "MIHPacket.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
39 /** \brief Parse a MIH packet
41 Parser implementing the MIH header. The fields implemented are:
42 \image html MIHPacket.png
46 struct MIHPacketParser : public PacketParserBase
48 # include SENF_PARSER()
50 SENF_PARSER_BITFIELD_RO ( version, 4, unsigned );
51 SENF_PARSER_BITFIELD ( ackRequest, 1, bool );
52 SENF_PARSER_BITFIELD ( ackResponse, 1, bool );
53 SENF_PARSER_BITFIELD ( uir, 1, bool );
54 SENF_PARSER_BITFIELD ( moreFragment, 1, bool );
55 SENF_PARSER_BITFIELD ( fragmentNr, 7, unsigned );
56 SENF_PARSER_SKIP_BITS ( 1 );
58 // MIH message ID (MID)
59 SENF_PARSER_FIELD ( messageId, UInt16Parser ); //<pkgdraw:hide
60 SENF_PARSER_GOTO ( messageId );
61 SENF_PARSER_BITFIELD ( sid, 4, unsigned );
62 SENF_PARSER_BITFIELD ( opcode, 2, unsigned );
63 SENF_PARSER_BITFIELD ( aid, 10, unsigned );
65 SENF_PARSER_SKIP_BITS ( 4 );
66 SENF_PARSER_BITFIELD ( transactionId, 12, unsigned );
67 SENF_PARSER_FIELD_RO ( payloadLength, UInt16Parser );
69 SENF_PARSER_GOTO_OFFSET( 8, 8); // just to limit the offset calculation
72 SENF_PARSER_FIELD ( src_mihfId, MIHFSrcIdTLVParser );
73 // Destination MIHF Id
74 SENF_PARSER_FIELD ( dst_mihfId, MIHFDstIdTLVParser );
76 SENF_PARSER_FINALIZE ( MIHPacketParser );
83 friend class MIHPacketType;
88 \par Packet type (typedef):
94 \ingroup protocolbundle_80221
97 : public PacketTypeBase,
98 public PacketTypeMixin<MIHPacketType, MIHMessageRegistry>
101 typedef PacketTypeMixin<MIHPacketType, MIHMessageRegistry> mixin;
103 typedef ConcretePacket<MIHPacketType> packet; ///< MIH packet typedef
104 typedef MIHPacketParser parser; ///< typedef to the parser of MIH packet
106 using mixin::nextPacketRange;
108 using mixin::initSize;
110 /** \brief Dump given MIH packet in readable form to given output stream */
111 static void dump(packet p, std::ostream &os);
112 static void finalize(packet p);
113 static factory_t nextPacketType(packet p);
116 /** \brief MIH packet typedef
117 \ingroup protocolbundle_80221
119 typedef ConcretePacket<MIHPacketType> MIHPacket;
122 struct MIHGenericPayloadPacketParser : public PacketParserBase
124 # include SENF_PARSER()
125 SENF_PARSER_LIST ( tlvList, packetSize(), MIHGenericTLVParser );
126 SENF_PARSER_FINALIZE ( MIHGenericPayloadPacketParser );
129 struct MIHGenericPayloadPacketType
130 : public PacketTypeBase,
131 public PacketTypeMixin<MIHGenericPayloadPacketType>
134 typedef PacketTypeMixin<MIHGenericPayloadPacketType> mixin;
136 typedef ConcretePacket<MIHGenericPayloadPacketType> packet; ///< MIH Payload packet typedef
137 typedef MIHGenericPayloadPacketParser parser; ///< typedef to the parser of MIH Payload packet
139 using mixin::nextPacketRange;
141 using mixin::initSize;
143 /** \brief Dump given MIHGenericPayload in readable form to given output stream */
144 static void dump(packet p, std::ostream &os);
145 static void finalize(packet p);
148 /** \brief MIH Payload packet typedef
149 \ingroup protocolbundle_80221
151 typedef ConcretePacket<MIHGenericPayloadPacketType> MIHGenericPayloadPacket;
155 ///////////////////////////////hh.e////////////////////////////////////////
156 //#include "MIHPacket.cci"
157 //#include "MIHPacket.ct"
158 //#include "MIHPacket.cti"
166 // c-file-style: "senf"
167 // indent-tabs-mode: nil
168 // ispell-local-dictionary: "american"
169 // compile-command: "scons -u test"
170 // comment-column: 40