17 #ifndef HH_SENF_Packets_80211Bundle_RadiotapPacket_ 18 #define HH_SENF_Packets_80211Bundle_RadiotapPacket_ 1 22 #include <boost/unordered_map.hpp> 23 #include <boost/array.hpp> 24 #include <boost/functional/hash.hpp> 35 # include SENF_FIXED_PARSER() 57 # include SENF_FIXED_PARSER() 79 # include SENF_FIXED_PARSER() 90 # include SENF_FIXED_PARSER() 104 # include SENF_FIXED_PARSER() 125 # include SENF_FIXED_PARSER() 171 # include SENF_FIXED_PARSER() 201 # include SENF_FIXED_PARSER() 226 DBM_ANTSIGNAL_INDEX = 5,
227 DBM_ANTNOISE_INDEX = 6,
228 LOCK_QUALITY_INDEX = 7,
229 TX_ATTENUATION_INDEX = 8,
230 DB_TX_ATTENUATION_INDEX = 9,
231 DBM_TX_POWER_INDEX = 10,
233 DB_ANTSIGNAL_INDEX = 12,
234 DB_ANTNOISE_INDEX = 13,
237 RTS_RETRIES_INDEX = 16,
238 DATA_RETRIES_INDEX = 17,
240 A_MPDU_STATUS_INDEX = 20,
245 RADIOTOP_NS_INDEX = 29,
246 VENDOR_NS_INDEX = 30,
247 EXTENDED_BITMASK_INDEX = 31
251 TSFT_FLAG = (1<<TSFT_INDEX),
252 FLAGS_FLAG = (1<<FLAGS_INDEX),
253 RATE_FLAG = (1<<RATE_INDEX),
254 CHANNEL_FLAG = (1<<CHANNEL_INDEX),
255 FHSS_FLAG = (1<<FHSS_INDEX),
256 DBM_ANTSIGNAL_FLAG = (1<<DBM_ANTSIGNAL_INDEX),
257 DBM_ANTNOISE_FLAG = (1<<DBM_ANTNOISE_INDEX),
258 LOCK_QUALITY_FLAG = (1<<LOCK_QUALITY_INDEX),
259 TX_ATTENUATION_FLAG = (1<<TX_ATTENUATION_INDEX),
260 DB_TX_ATTENUATION_FLAG = (1<<DB_TX_ATTENUATION_INDEX),
261 DBM_TX_POWER_FLAG = (1<<DBM_TX_POWER_INDEX),
262 ANTENNA_FLAG = (1<<ANTENNA_INDEX),
263 DB_ANTSIGNAL_FLAG = (1<<DB_ANTSIGNAL_INDEX),
264 DB_ANTNOISE_FLAG = (1<<DB_ANTNOISE_INDEX),
265 RX_FLAGS_FLAG = (1<<RX_FLAGS_INDEX),
266 TX_FLAGS_FLAG = (1<<TX_FLAGS_INDEX),
267 RTS_RETRIES_FLAG = (1<<RTS_RETRIES_INDEX),
268 DATA_RETRIES_FLAG = (1<<DATA_RETRIES_INDEX),
270 A_MPDU_STATUS_FLAG = (1<<A_MPDU_STATUS_INDEX),
273 RADIOTOP_NS_FLAG = (1<<RADIOTOP_NS_INDEX),
274 VENDOR_NS_FLAG = (1<<VENDOR_NS_INDEX),
275 EXTENDED_BITMASK_FLAG = (1<<EXTENDED_BITMASK_INDEX)
278 static unsigned const FIELD_SIZE[MAX_INDEX+2];
283 # include SENF_FIXED_PARSER() 302 # define FIELD(name,type,index) \ 303 typedef type name ## _t; \ 304 type name(unsigned extIndex = 0) { return parseField<type>(index, extIndex); } \ 305 bool has_ ## name(unsigned extIndex = 0) { return currentTable()[(extIndex+1)*index]; } \ 306 bool name ## Present(unsigned extIndex = 0) { return has_ ## name(extIndex); } \ 307 type init_ ## name() { initField(index); return name(); } \ 308 void disable_ ## name() { disableField(index); } 310 FIELD( tsft, UInt64LSBParser, TSFT_INDEX );
314 flags_t
flags(
unsigned extIndex = 0) {
return parseField<flags_t>(FLAGS_INDEX, extIndex); }
315 bool has_flags(
unsigned extIndex = 0) {
return currentTable()[(extIndex+1)*FLAGS_INDEX]; }
316 bool flagsPresent(
unsigned extIndex = 0) {
return has_flags(extIndex); }
317 flags_t
init_flags() { initField(FLAGS_INDEX);
return flags(); }
348 unsigned frameType();
349 unsigned rateInKbps();
350 unsigned bandwidth();
355 typedef boost::array<size_type, MAX_INDEX * 3 + 2> OffsetTable;
356 typedef boost::unordered_map<std::size_t, OffsetTable> OffsetMap;
362 static void parseOffsetTable(boost::uint8_t *
data,
int maxLength, OffsetTable & table);
364 static void buildOffsetTable(boost::uint32_t presentFlags, OffsetTable & table);
368 OffsetTable
const & currentTable()
const;
369 OffsetTable
const & getTable(boost::uint32_t presentFlags)
const;
371 template <
class Parser>
372 Parser parseField(
unsigned index,
unsigned extIndex);
373 void initField(
unsigned index);
374 void disableField(
unsigned index);
378 void updatePresentFlags(boost::uint32_t flags);
379 void insertRemoveBytes(
unsigned from,
unsigned to,
int bytes);
381 static OffsetMap offsetMap_;
382 OffsetTable
const * currentTable_;
408 using mixin::initSize;
410 static void init(packet p);
411 static void dump(packet p, std::ostream & os);
412 static factory_t nextPacketType(packet p);
RadiotapPacketParser parser
senf::FlagParser<?> cfp() const
senf::FlagParser<?> shortPreamble() const
#define SENF_PARSER_BITFIELD(name, bits, type)
Define bit-field.
PacketInterpreterBase::optional_range optional_range
senf::FlagParser<?>::value_type fcsAtEnd() const
Mixin to provide standard implementations for nextPacketRange and nextPacketType. ...
Parse 8bit unsigned byte aligned integer.
Parse in Radiotap Header channel frequency and flag field.
#define VHT_FLAG(name, desc, longDesc)
senf::FlagParser<?> fragmentation() const
Return number of bytes to allocate to new object of given type.
PacketTypeMixin< RadiotapPacketType > mixin
PacketParserBase::size_type bytes(Parser const &p)
Return raw size parsed by the given parser object.
#define SENF_PARSER_FIELD(name, type)
Define normal parser field.
bool flagsPresent(unsigned extIndex=0)
#define SENF_PARSER_PRIVATE_FIELD(name, type)
Define parser field (private)
senf::FlagParser<?> padding() const
#define SENF_PARSER_FINALIZE(name)
Generate parser control members.
ConcretePacket< RadiotapPacketType > RadiotapPacket
Parse Flag field in Radiotap header.
#define MCS_FLAG(name, desc, longDesc)
void dump(std::ostream &os, DirectoryNode &dir=root())
Protocol specific packet handle.
Helper base-class implementing the PacketType interface.
Packet data STL-sequence view.
#define SENF_PARSER_BITFIELD_RO(name, bits, type)
Define bit-field (read-only)
data_iterator i() const
Return beginning of data to parse.
senf::FlagParser<?> shortGI() const
flags_t flags(unsigned extIndex=0)
#define SENF_PARSER_SKIP(skip)
Skip bytes.
friend struct RadiotapPacketParser
SENF_PACKET_PREVENT_TEMPLATE_INSTANTIATION(RadiotapPacket)
Parse 8bit signed byte aligned integer.
void init() const
Default implementation.
Parse 16bit unsigned byte aligned integer LSB.
detail::packet::size_type size_type
Unsigned integral type.
senf::FlagParser<?> wep() const
bool has_flags(unsigned extIndex=0)
#define FIELD(name, type, index)
ConcretePacket< RadiotapPacketType > packet
senf::FlagParser<?> badFCS() const
#define SENF_PARSER_SKIP_BITS(bits)
Skip bits within bitfield group.
PacketData & data() const
Access the packets raw data container.
struct ieee80211_mcs_info mcs
Parse 32bit unsigned byte aligned integer.
PacketInterpreterBase::factory_t factory_t
Parse 16bit unsigned byte aligned integer.
RadiotapPacket_FlagsParser flags_t
detail::packet::iterator data_iterator
Raw data iterator type.