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"
33 //#include "MIHPacket.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
38 struct MIHMessageRegistry {
39 // MIH messages registry
40 typedef boost::uint16_t key_t;
43 # define SENF_MIH_PACKET_REGISTRY_REGISTER( packet ) \
44 SENF_PACKET_REGISTRY_REGISTER( \
45 senf::MIHMessageRegistry, packet::type::MESSAGE_ID, packet )
48 /** \brief Parse a MIH packet
50 Parser implementing the MIH header. The fields implemented are:
51 \image html MIHPacket.png
55 struct MIHPacketParser : public PacketParserBase
57 # include SENF_PARSER()
59 SENF_PARSER_BITFIELD_RO ( version, 4, unsigned );
60 SENF_PARSER_BITFIELD ( ackRequest, 1, bool );
61 SENF_PARSER_BITFIELD ( ackResponse, 1, bool );
62 SENF_PARSER_BITFIELD ( uir, 1, bool );
63 SENF_PARSER_BITFIELD ( moreFragment, 1, bool );
64 SENF_PARSER_BITFIELD ( fragmentNr, 7, unsigned );
65 SENF_PARSER_SKIP_BITS ( 1 );
67 // MIH message ID (MID)
68 SENF_PARSER_FIELD ( messageId, UInt16Parser ); //<pkgdraw:hide
69 SENF_PARSER_GOTO ( messageId );
70 SENF_PARSER_BITFIELD ( sid, 4, unsigned );
71 SENF_PARSER_BITFIELD ( opcode, 2, unsigned );
72 SENF_PARSER_BITFIELD ( aid, 10, unsigned );
74 SENF_PARSER_SKIP_BITS ( 4 );
75 SENF_PARSER_BITFIELD ( transactionId, 12, unsigned );
76 SENF_PARSER_FIELD_RO ( payloadLength, UInt16Parser );
78 SENF_PARSER_GOTO_OFFSET( 8, 8); // just to limit the offset calculation
81 SENF_PARSER_FIELD ( src_mihfId, MIHFSrcIdTLVParser );
82 // Destination MIHF Id
83 SENF_PARSER_FIELD ( dst_mihfId, MIHFDstIdTLVParser );
85 SENF_PARSER_FINALIZE ( MIHPacketParser );
92 friend class MIHPacketType;
97 \par Packet type (typedef):
103 \ingroup protocolbundle_80221
106 : public PacketTypeBase,
107 public PacketTypeMixin<MIHPacketType, MIHMessageRegistry>
110 typedef PacketTypeMixin<MIHPacketType, MIHMessageRegistry> mixin;
112 typedef ConcretePacket<MIHPacketType> packet; ///< MIH packet typedef
113 typedef MIHPacketParser parser; ///< typedef to the parser of MIH packet
115 using mixin::nextPacketRange;
117 using mixin::initSize;
119 /** \brief Dump given MIH packet in readable form to given output stream */
120 static void dump(packet p, std::ostream &os);
121 static void finalize(packet p);
122 static factory_t nextPacketType(packet p);
125 /** \brief MIH packet typedef
126 \ingroup protocolbundle_80221
128 typedef ConcretePacket<MIHPacketType> MIHPacket;
131 struct MIHGenericPayloadPacketParser : public PacketParserBase
133 # include SENF_PARSER()
134 SENF_PARSER_LIST ( tlvList, packetSize(), MIHGenericTLVParser );
135 SENF_PARSER_FINALIZE ( MIHGenericPayloadPacketParser );
138 struct MIHGenericPayloadPacketType
139 : public PacketTypeBase,
140 public PacketTypeMixin<MIHGenericPayloadPacketType>
143 typedef PacketTypeMixin<MIHGenericPayloadPacketType> mixin;
145 typedef ConcretePacket<MIHGenericPayloadPacketType> packet; ///< MIH Payload packet typedef
146 typedef MIHGenericPayloadPacketParser parser; ///< typedef to the parser of MIH Payload packet
148 using mixin::nextPacketRange;
150 using mixin::initSize;
152 /** \brief Dump given MIHGenericPayload in readable form to given output stream */
153 static void dump(packet p, std::ostream &os);
154 static void finalize(packet p);
157 /** \brief MIH Payload packet typedef
158 \ingroup protocolbundle_80221
160 typedef ConcretePacket<MIHGenericPayloadPacketType> MIHGenericPayloadPacket;
164 ///////////////////////////////hh.e////////////////////////////////////////
165 //#include "MIHPacket.cci"
166 //#include "MIHPacket.ct"
167 //#include "MIHPacket.cti"
175 // c-file-style: "senf"
176 // indent-tabs-mode: nil
177 // ispell-local-dictionary: "american"
178 // compile-command: "scons -u test"
179 // comment-column: 40