added MIHPacketType::finalize
[senf.git] / Packets / 80221Bundle / MIHPacket.hh
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief MIH protocol public header */
25
26 #ifndef HH_SENF_Packets_80221Bundle_MIHPacket_
27 #define HH_SENF_Packets_80221Bundle_MIHPacket_ 1
28
29 // Custom includes
30 #include "../../Packets/Packets.hh"
31 #include "TLVPacket.hh"
32
33 //#include "MIHPacket.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
35
36 namespace senf {
37
38     struct MIHF_IdParser : public senf::PacketParserBase
39     {
40     #   include SENF_FIXED_PARSER()        
41                 
42         SENF_PARSER_FINALIZE ( MIHF_IdParser );
43     };
44
45     struct MIHPacketParser : public senf::PacketParserBase
46     {
47     #   include SENF_PARSER()
48         
49         SENF_PARSER_BITFIELD_RO ( version,       4,  unsigned );
50         SENF_PARSER_BITFIELD    ( ackRequest,    1,  bool     );
51         SENF_PARSER_BITFIELD    ( ackResponse,   1,  bool     );
52         SENF_PARSER_BITFIELD    ( uir,           1,  bool     );
53         SENF_PARSER_BITFIELD    ( moreFragment,  1,  bool     );
54         SENF_PARSER_BITFIELD    ( fragmentNr,    7,  unsigned );
55         SENF_PARSER_SKIP_BITS   ( 1                           );
56         
57         // MIH message ID (MID)
58         SENF_PARSER_BITFIELD ( sid,     4,  unsigned );
59         SENF_PARSER_BITFIELD ( opcode,  2,  unsigned );
60         SENF_PARSER_BITFIELD ( aid,    10,  unsigned );
61         
62         SENF_PARSER_SKIP_BITS ( 4                           );
63         SENF_PARSER_BITFIELD  ( transactionId, 12, unsigned );
64         SENF_PARSER_FIELD_RO  ( payloadLength, UInt16Parser );
65         
66         // Source MIHF Id
67         SENF_PARSER_PRIVATE_FIELD ( source_type,    UInt8Parser            );
68         SENF_PARSER_PRIVATE_FIELD ( source_length,  DynamicTLVLengthParser );
69         SENF_PARSER_FIELD         ( source_mihf_id, MIHF_IdParser          );
70
71         // Destination MIHF Id
72         SENF_PARSER_PRIVATE_FIELD ( destination_type,    UInt8Parser            );
73         SENF_PARSER_PRIVATE_FIELD ( destination_length,  DynamicTLVLengthParser );
74         SENF_PARSER_FIELD         ( destination_mihf_id, MIHF_IdParser          );
75         
76         SENF_PARSER_FINALIZE ( MIHPacketParser );
77         
78         SENF_PARSER_INIT() {
79             version_() = 1;
80             source_type() = 1;
81             destination_type() = 2;
82         }
83         
84         friend class MIHPacketType;
85     };
86     
87     
88     struct MIHPacketType
89         : public PacketTypeBase,
90           public PacketTypeMixin<MIHPacketType>
91     {
92         typedef PacketTypeMixin<MIHPacketType> mixin;
93         typedef ConcretePacket<MIHPacketType> packet;
94         typedef MIHPacketParser parser;
95
96         using mixin::nextPacketRange;
97         using mixin::init;
98         using mixin::initSize;
99
100         static void dump(packet p, std::ostream &os);
101         static void finalize(packet p);
102     };
103
104     typedef ConcretePacket<MIHPacketType> MIHPacket;
105 }
106
107
108 ///////////////////////////////hh.e////////////////////////////////////////
109 #endif
110 #ifndef SENF_PACKETS_DECL_ONLY
111 //#include "MIHPacket.cci"
112 //#include "MIHPacket.ct"
113 //#include "MIHPacket.cti"
114 #endif
115
116 \f
117 // Local Variables:
118 // mode: c++
119 // fill-column: 100
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"
124 // comment-column: 40
125 // End: