4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
29 \brief MIH protocol public header */
31 #ifndef HH_SENF_Packets_80221Bundle_MIHPacket_
32 #define HH_SENF_Packets_80221Bundle_MIHPacket_ 1
35 #include <senf/Packets/Packets.hh>
36 #include "TLVParser.hh"
37 #include "MIHMessageRegistry.hh"
39 //#include "MIHPacket.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 /** \brief Parse a MIH packet
46 Parser implementing the MIH header. The fields implemented are:
47 \image html MIHPacket.png
51 struct MIHPacketParser : public PacketParserBase
53 # include SENF_PARSER()
55 SENF_PARSER_BITFIELD_RO ( version, 4, unsigned );
56 SENF_PARSER_BITFIELD ( ackRequest, 1, bool );
57 SENF_PARSER_BITFIELD ( ackResponse, 1, bool );
58 SENF_PARSER_BITFIELD ( uir, 1, bool );
59 SENF_PARSER_BITFIELD ( moreFragment, 1, bool );
60 SENF_PARSER_BITFIELD ( fragmentNr, 7, unsigned );
61 SENF_PARSER_SKIP_BITS ( 1 );
63 // MIH message ID (MID)
64 SENF_PARSER_FIELD ( messageId, UInt16Parser ); //<pkgdraw:hide
65 SENF_PARSER_GOTO ( messageId );
66 SENF_PARSER_BITFIELD ( sid, 4, unsigned );
67 SENF_PARSER_BITFIELD ( opcode, 2, unsigned );
68 SENF_PARSER_BITFIELD ( aid, 10, unsigned );
70 SENF_PARSER_SKIP_BITS ( 4 );
71 SENF_PARSER_BITFIELD ( transactionId, 12, unsigned );
72 SENF_PARSER_FIELD_RO ( payloadLength, UInt16Parser );
74 SENF_PARSER_GOTO_OFFSET( 8, 8); // just to limit the offset calculation
77 SENF_PARSER_FIELD ( src_mihfId, MIHFSrcIdTLVParser );
78 // Destination MIHF Id
79 SENF_PARSER_FIELD ( dst_mihfId, MIHFDstIdTLVParser );
81 SENF_PARSER_FINALIZE ( MIHPacketParser );
88 friend class MIHPacketType;
93 \par Packet type (typedef):
99 \ingroup protocolbundle_80221
102 : public PacketTypeBase,
103 public PacketTypeMixin<MIHPacketType, MIHMessageRegistry>
105 typedef PacketTypeMixin<MIHPacketType, MIHMessageRegistry> mixin;
106 typedef ConcretePacket<MIHPacketType> packet; ///< MIH packet typedef
107 typedef MIHPacketParser parser; ///< typedef to the parser of MIH packet
109 using mixin::nextPacketRange;
111 using mixin::initSize;
113 /** \brief Dump given MIH packet in readable form to given output stream */
114 static void dump(packet p, std::ostream & os);
115 static void finalize(packet p);
116 static factory_t nextPacketType(packet p);
117 static void validate(packet p);
119 static const boost::uint16_t etherType = 0x8917;
122 /** \brief MIH packet typedef
123 \ingroup protocolbundle_80221
125 typedef ConcretePacket<MIHPacketType> MIHPacket;
128 struct MIHGenericPayloadPacketParser : public PacketParserBase
130 # include SENF_PARSER()
131 SENF_PARSER_LIST ( tlvList, packetSize(), MIHGenericTLVParser );
132 SENF_PARSER_FINALIZE ( MIHGenericPayloadPacketParser );
135 struct MIHGenericPayloadPacketType
136 : public PacketTypeBase,
137 public PacketTypeMixin<MIHGenericPayloadPacketType>
139 typedef PacketTypeMixin<MIHGenericPayloadPacketType> mixin;
140 typedef ConcretePacket<MIHGenericPayloadPacketType> packet; ///< MIH Payload packet typedef
141 typedef MIHGenericPayloadPacketParser parser; ///< typedef to the parser of MIH Payload packet
143 using mixin::nextPacketRange;
145 using mixin::initSize;
147 /** \brief Dump given MIHGenericPayload in readable form to given output stream */
148 static void dump(packet p, std::ostream & os);
149 static void finalize(packet p);
152 /** \brief MIH Payload packet typedef
153 \ingroup protocolbundle_80221
155 typedef ConcretePacket<MIHGenericPayloadPacketType> MIHGenericPayloadPacket;
159 //-/////////////////////////////////////////////////////////////////////////////////////////////////
160 //#include "MIHPacket.cci"
161 //#include "MIHPacket.ct"
162 //#include "MIHPacket.cti"
170 // c-file-style: "senf"
171 // indent-tabs-mode: nil
172 // ispell-local-dictionary: "american"
173 // compile-command: "scons -u test"
174 // comment-column: 40