X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2F80211Bundle%2FRadiotapPacket.hh;h=ebea56717b765a028127f955395526bdc58721d4;hb=d498c7507e2eaa191e859ae525df97dc257e0d7a;hp=48d020bb19735f8bf3514d27bdc4270ed0cffc9d;hpb=703dda9bbad122844e213475b7a4c0ce1759b65f;p=senf.git
diff --git a/Packets/80211Bundle/RadiotapPacket.hh b/Packets/80211Bundle/RadiotapPacket.hh
index 48d020b..ebea567 100644
--- a/Packets/80211Bundle/RadiotapPacket.hh
+++ b/Packets/80211Bundle/RadiotapPacket.hh
@@ -21,9 +21,7 @@
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief Radiotap header \n
- Radiotap uses least significant bit byte order
- */
+ \brief Radiotap header */
#ifndef HH_SENF_Packets_80211Bundle_RadiotapPacket_
#define HH_SENF_Packets_80211Bundle_RadiotapPacket_ 1
@@ -34,10 +32,10 @@ namespace senf
{
/** \brief Parse Flag field in Radiotap header
- * Re-ordering of bits due to LSB byte order
+ Re-ordering of bits due to LSB byte order
*/
- struct RadiotapPacketParser_Flags : public senf::PacketParserBase
+ struct RadiotapPacketParser_Flags : public PacketParserBase
{
# include SENF_FIXED_PARSER()
@@ -57,7 +55,7 @@ namespace senf
Re-ordering of bits due to LSB byte order
*/
- struct RadiotapPacketParser_ChannelOptions : public senf::PacketParserBase
+ struct RadiotapPacketParser_ChannelOptions : public PacketParserBase
{
# include SENF_FIXED_PARSER()
@@ -84,11 +82,20 @@ namespace senf
Parser implementing the Radiotap header
+ Radiotap requires that all fields in the radiotap header
+ are aligned to natural boundaries. For radiotap,
+ that means all 8-, 16-, 32-, and 64-bit fields
+ must begin on 8-, 16-, 32-, and 64-bit boundaries, respectively.
+ In this way, generators and parsers can avoid unaligned
+ accesses to radiotap capture fields. Radiotap-compliant
+ generators must insert padding before a capture field
+ to ensure its natural alignment.
+
\see Radiotap.org
\todo extended present field (bit 31 of present field is set)
*/
- struct RadiotapPacketParser : public senf::PacketParserBase
+ struct RadiotapPacketParser : public PacketParserBase
{
# include SENF_PARSER()
@@ -112,7 +119,8 @@ namespace senf
SENF_PARSER_BITFIELD_RO ( ratePresent, 1, bool );
SENF_PARSER_BITFIELD_RO ( flagsPresent, 1, bool );
SENF_PARSER_BITFIELD_RO ( tsftPresent, 1, bool );
- SENF_PARSER_SKIP_BITS ( 2 ); //currently unused bits
+ SENF_PARSER_SKIP_BITS ( 1 ); //currently unused bits
+ SENF_PARSER_BITFIELD_RO ( fcsPresent, 1, bool );
SENF_PARSER_BITFIELD_RO ( dbAntennaNoisePresent, 1, bool );
SENF_PARSER_BITFIELD_RO ( dbAntennaSignalPresent, 1, bool );
SENF_PARSER_BITFIELD_RO ( antennaPresent, 1, bool );
@@ -127,30 +135,49 @@ namespace senf
/*
* Radiotap data
* parsing data according to present flags
+ *
+ * PARSER_SKIP required to skip correct length of padding bits
*/
+
+ /* macro to create required variant parser */
#define OPTIONAL_FIELD(name, parser) SENF_PARSER_VARIANT \
( name##_, name##Present, \
( novalue( disable_##name, VoidPacketParser )) \
- ( id( name, parser )) );
-
- OPTIONAL_FIELD ( tsft, UInt64LSBParser );
- OPTIONAL_FIELD ( flags, RadiotapPacketParser_Flags );
- OPTIONAL_FIELD ( rate, UInt8Parser );
- OPTIONAL_FIELD ( channelOptions, RadiotapPacketParser_ChannelOptions );
- OPTIONAL_FIELD ( fhss, UInt16LSBParser );
- OPTIONAL_FIELD ( dbmAntennaSignal, Int8Parser );
- OPTIONAL_FIELD ( dbmAntennaNoise, Int8Parser );
- OPTIONAL_FIELD ( txAttenuation, UInt16LSBParser );
- OPTIONAL_FIELD ( dbTxAttenuation, UInt16LSBParser );
- OPTIONAL_FIELD ( antenna, UInt8Parser );
- OPTIONAL_FIELD ( dbAntennaSignal, UInt8Parser );
- OPTIONAL_FIELD ( dbAntennaNoise, UInt8Parser );
+ ( id( name, parser )) )
+
+ /* macro to create padding parser */
+ #define SKIP_OPTIONAL_PADDING(cond, parser, size) \
+ SENF_PARSER_SKIP( \
+ (cond ? (size - (parser##__offset() + \
+ senf::bytes(parser##_())) % size) % size : 0) , 0 );
+
+ OPTIONAL_FIELD ( tsft, UInt64LSBParser );
+ OPTIONAL_FIELD ( flags, RadiotapPacketParser_Flags ); //
+ : public PacketTypeBase,
+ public PacketTypeMixin
{
- typedef senf::PacketTypeMixin mixin;
- typedef senf::ConcretePacket packet;
- typedef senf::RadiotapPacketParser parser;
+ typedef PacketTypeMixin mixin;
+ typedef ConcretePacket packet;
+ typedef RadiotapPacketParser parser;
using mixin::nextPacketRange;
using mixin::init;
@@ -177,9 +207,10 @@ namespace senf
static void dump(packet p, std::ostream &os);
static void finalize(packet p);
+ static factory_t nextPacketType(packet p);
};
- typedef senf::ConcretePacket RadiotapPacket;
+ typedef ConcretePacket RadiotapPacket;
}
#endif