4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Christian Niephaus <cni@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 Radiotap header \n
25 <b>Radiotap uses least significant bit byte order</b>
28 #ifndef HH_SENF_Packets_80211Bundle_RadiotapPacket_
29 #define HH_SENF_Packets_80211Bundle_RadiotapPacket_ 1
31 #include "../../Packets/Packets.hh"
36 /** \brief Parse Flag field in Radiotap header
37 * <b>Re-ordering of bits due to LSB byte order</b>
40 struct RadiotapPacketParser_Flags : public senf::PacketParserBase
42 # include SENF_FIXED_PARSER()
44 SENF_PARSER_BITFIELD ( shortGI, 1, bool );
45 SENF_PARSER_BITFIELD ( badFCS, 1, bool );
46 SENF_PARSER_BITFIELD ( padding, 1, bool );
47 SENF_PARSER_BITFIELD ( fcsPresent, 1, bool );
48 SENF_PARSER_BITFIELD ( fragmentation, 1, bool );
49 SENF_PARSER_BITFIELD ( wep, 1, bool );
50 SENF_PARSER_BITFIELD ( shortPreamble, 1, bool );
51 SENF_PARSER_BITFIELD ( cfp, 1, bool );
53 SENF_PARSER_FINALIZE ( RadiotapPacketParser_Flags );
56 /** \brief Parse in Radiotap Header channel frequency and flag field
58 <b>Re-ordering of bits due to LSB byte order</b>
60 struct RadiotapPacketParser_ChannelOptions : public senf::PacketParserBase
62 # include SENF_FIXED_PARSER()
64 SENF_PARSER_FIELD ( freq, UInt16LSBParser );
66 SENF_PARSER_BITFIELD ( flag2ghz, 1, bool );
67 SENF_PARSER_BITFIELD ( ofdm, 1, bool );
68 SENF_PARSER_BITFIELD ( cck, 1, bool );
69 SENF_PARSER_BITFIELD ( turbo, 1, bool );
70 SENF_PARSER_SKIP_BITS ( 4 ); //currently unused in radiotap
71 SENF_PARSER_BITFIELD ( quarterRateChannel, 1, bool );
72 SENF_PARSER_BITFIELD ( halfRateChannel, 1, bool );
73 SENF_PARSER_BITFIELD ( gsm, 1, bool );
74 SENF_PARSER_BITFIELD ( staticTurbo, 1, bool );
75 SENF_PARSER_BITFIELD ( gfsk, 1, bool );
76 SENF_PARSER_BITFIELD ( cckOfdm, 1, bool );
77 SENF_PARSER_BITFIELD ( passive, 1, bool );
78 SENF_PARSER_BITFIELD ( flag5ghz, 1, bool );
80 SENF_PARSER_FINALIZE ( RadiotapPacketParser_ChannelOptions );
83 /** \brief Parse an Radiotap header
85 Parser implementing the Radiotap header
87 \see <a href="http://www.radiotap.org">Radiotap.org</a>
89 \todo extended present field (bit 31 of present field is set)
91 struct RadiotapPacketParser : public senf::PacketParserBase
93 # include SENF_PARSER()
98 SENF_PARSER_FIELD ( version, UInt8Parser );
99 //padding bits, currently unused, it simply aligns the fields onto natural word boundaries.
100 SENF_PARSER_SKIP ( 1,1 );
101 SENF_PARSER_FIELD ( length, UInt16LSBParser );
105 * indicate which data field are contained in the packet
107 SENF_PARSER_BITFIELD_RO ( lockQualityPresent, 1, bool );
108 SENF_PARSER_BITFIELD_RO ( dbmAntennaNoisePresent, 1, bool );
109 SENF_PARSER_BITFIELD_RO ( dbmAntennaSignalPresent, 1, bool );
110 SENF_PARSER_BITFIELD_RO ( fhssPresent, 1, bool );
111 SENF_PARSER_BITFIELD_RO ( channelOptionsPresent, 1, bool );
112 SENF_PARSER_BITFIELD_RO ( ratePresent, 1, bool );
113 SENF_PARSER_BITFIELD_RO ( flagsPresent, 1, bool );
114 SENF_PARSER_BITFIELD_RO ( tsftPresent, 1, bool );
115 SENF_PARSER_SKIP_BITS ( 2 ); //currently unused bits
116 SENF_PARSER_BITFIELD_RO ( dbAntennaNoisePresent, 1, bool );
117 SENF_PARSER_BITFIELD_RO ( dbAntennaSignalPresent, 1, bool );
118 SENF_PARSER_BITFIELD_RO ( antennaPresent, 1, bool );
119 SENF_PARSER_BITFIELD_RO ( dbmTxAttenuationPresent, 1, bool );
120 SENF_PARSER_BITFIELD_RO ( dbTxAttenuationPresent, 1, bool );
121 SENF_PARSER_BITFIELD_RO ( txAttenuationPresent, 1, bool );
122 SENF_PARSER_SKIP_BITS ( 8 ); //currently unused bits
123 //if bit is set,another 32 bit present flag is attached (not implemented yet)
124 SENF_PARSER_BITFIELD ( extendedBitmaskPresent, 1, bool );
125 SENF_PARSER_SKIP_BITS ( 7 ); //currently unused bits
129 * parsing data according to present flags
131 #define OPTIONAL_FIELD(name, parser) SENF_PARSER_VARIANT \
132 ( name##_, name##Present, \
133 ( novalue( disable_##name, VoidPacketParser )) \
134 ( id( name, parser )) );
136 OPTIONAL_FIELD ( tsft, UInt64LSBParser );
137 OPTIONAL_FIELD ( flags, RadiotapPacketParser_Flags );
138 OPTIONAL_FIELD ( rate, UInt8Parser );
139 OPTIONAL_FIELD ( channelOptions, RadiotapPacketParser_ChannelOptions );
140 OPTIONAL_FIELD ( fhss, UInt16LSBParser );
141 OPTIONAL_FIELD ( dbmAntennaSignal, Int8Parser );
142 OPTIONAL_FIELD ( dbmAntennaNoise, Int8Parser );
143 OPTIONAL_FIELD ( txAttenuation, UInt16LSBParser );
144 OPTIONAL_FIELD ( dbTxAttenuation, UInt16LSBParser );
145 OPTIONAL_FIELD ( antenna, UInt8Parser );
146 OPTIONAL_FIELD ( dbAntennaSignal, UInt8Parser );
147 OPTIONAL_FIELD ( dbAntennaNoise, UInt8Parser );
153 SENF_PARSER_FINALIZE(RadiotapPacketParser);
156 /** \brief Radiotap packet
158 \par Packet type (typedef):
162 \ref RadiotapPacketParser
164 \ingroup protocolbundle_80211
166 struct RadiotapPacketType
167 : public senf::PacketTypeBase,
168 public senf::PacketTypeMixin<RadiotapPacketType>
170 typedef senf::PacketTypeMixin<RadiotapPacketType> mixin;
171 typedef senf::ConcretePacket<RadiotapPacketType> packet;
172 typedef senf::RadiotapPacketParser parser;
174 using mixin::nextPacketRange;
176 using mixin::initSize;
178 static void dump(packet p, std::ostream &os);
179 static void finalize(packet p);
182 typedef senf::ConcretePacket<RadiotapPacketType> RadiotapPacket;