-// $Id:$
+// $Id$
//
-// Copyright (C) 2006
+// Copyright (C) 2008
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
-// Christian Niephaus <christian.niephaus@fokus.fraunhofer.de>
+// Christian Niephaus <cni@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
/** \file
\brief Radiotap header \n
<b>Radiotap uses least significant bit byte order</b>
-
-
*/
-#ifndef HH_RadiotapPacket_
-#define HH_RadioPacket_ 1
+#ifndef HH_SENF_Packets_80211Bundle_RadiotapPacket_
+#define HH_SENF_Packets_80211Bundle_RadiotapPacket_ 1
#include "../../Packets/Packets.hh"
{
# include SENF_FIXED_PARSER()
- SENF_PARSER_BITFIELD ( shortGI, 1, bool);
- SENF_PARSER_BITFIELD ( badFCS, 1, bool);
- SENF_PARSER_BITFIELD ( padding, 1, bool);
- SENF_PARSER_BITFIELD ( fcsPresent, 1, bool);
- SENF_PARSER_BITFIELD ( fragmentation, 1, bool);
- SENF_PARSER_BITFIELD ( wep, 1, bool);
- SENF_PARSER_BITFIELD ( shortPreamble, 1, bool);
- SENF_PARSER_BITFIELD ( cfp, 1, bool);
+ SENF_PARSER_BITFIELD ( shortGI, 1, bool );
+ SENF_PARSER_BITFIELD ( badFCS, 1, bool );
+ SENF_PARSER_BITFIELD ( padding, 1, bool );
+ SENF_PARSER_BITFIELD ( fcsPresent, 1, bool );
+ SENF_PARSER_BITFIELD ( fragmentation, 1, bool );
+ SENF_PARSER_BITFIELD ( wep, 1, bool );
+ SENF_PARSER_BITFIELD ( shortPreamble, 1, bool );
+ SENF_PARSER_BITFIELD ( cfp, 1, bool );
SENF_PARSER_FINALIZE ( RadiotapPacketParser_Flags );
-
};
/** \brief Parse in Radiotap Header channel frequency and flag field
{
# include SENF_FIXED_PARSER()
- SENF_PARSER_FIELD ( freq, UInt16LSBParser );
-
- SENF_PARSER_BITFIELD ( flag2ghz, 1, bool );
- SENF_PARSER_BITFIELD ( ofdm, 1, bool );
- SENF_PARSER_BITFIELD ( cck, 1, bool );
- SENF_PARSER_BITFIELD ( turbo, 1, bool );
- SENF_PARSER_SKIP_BITS ( 4 ); //currently unused in radiotap
- SENF_PARSER_BITFIELD ( quarterRateChannel, 1, bool );
- SENF_PARSER_BITFIELD ( halfRateChannel, 1, bool );
- SENF_PARSER_BITFIELD ( gsm, 1, bool );
- SENF_PARSER_BITFIELD ( staticTurbo, 1, bool );
- SENF_PARSER_BITFIELD ( gfsk, 1, bool );
- SENF_PARSER_BITFIELD ( cckOfdm, 1, bool );
- SENF_PARSER_BITFIELD ( passive, 1, bool );
- SENF_PARSER_BITFIELD ( flag5ghz, 1, bool );
+ SENF_PARSER_FIELD ( freq, UInt16LSBParser );
+
+ SENF_PARSER_BITFIELD ( flag2ghz, 1, bool );
+ SENF_PARSER_BITFIELD ( ofdm, 1, bool );
+ SENF_PARSER_BITFIELD ( cck, 1, bool );
+ SENF_PARSER_BITFIELD ( turbo, 1, bool );
+ SENF_PARSER_SKIP_BITS ( 4 ); //currently unused in radiotap
+ SENF_PARSER_BITFIELD ( quarterRateChannel, 1, bool );
+ SENF_PARSER_BITFIELD ( halfRateChannel, 1, bool );
+ SENF_PARSER_BITFIELD ( gsm, 1, bool );
+ SENF_PARSER_BITFIELD ( staticTurbo, 1, bool );
+ SENF_PARSER_BITFIELD ( gfsk, 1, bool );
+ SENF_PARSER_BITFIELD ( cckOfdm, 1, bool );
+ SENF_PARSER_BITFIELD ( passive, 1, bool );
+ SENF_PARSER_BITFIELD ( flag5ghz, 1, bool );
SENF_PARSER_FINALIZE ( RadiotapPacketParser_ChannelOptions );
};
/*
* mandatory fields
*/
- SENF_PARSER_FIELD ( version, UInt8Parser );
+ SENF_PARSER_FIELD ( version, UInt8Parser );
//padding bits, currently unused, it simply aligns the fields onto natural word boundaries.
- SENF_PARSER_SKIP ( 1,1 );
- SENF_PARSER_FIELD ( length, UInt16LSBParser);
+ SENF_PARSER_SKIP ( 1,1 );
+ SENF_PARSER_FIELD ( length, UInt16LSBParser );
/*
* present flags
* indicate which data field are contained in the packet
*/
- SENF_PARSER_BITFIELD_RO ( lockQualityPresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( dbmAntennaNoisePresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( dbmAntennaSignalPresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( fhssPresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( channelPresent, 1, bool );
- 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_BITFIELD_RO ( dbAntennaNoisePresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( dbAntennaSignalPresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( antennaPresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( dbmTxAttenuationPresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( dbTxAttenuationPresent, 1, bool );
- SENF_PARSER_BITFIELD_RO ( txAttenuationPresent, 1, bool );
- SENF_PARSER_SKIP_BITS ( 8 ); //currently unused bits
+ SENF_PARSER_BITFIELD_RO ( lockQualityPresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( dbmAntennaNoisePresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( dbmAntennaSignalPresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( fhssPresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( channelOptionsPresent, 1, bool );
+ 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_BITFIELD_RO ( dbAntennaNoisePresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( dbAntennaSignalPresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( antennaPresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( dbmTxAttenuationPresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( dbTxAttenuationPresent, 1, bool );
+ SENF_PARSER_BITFIELD_RO ( txAttenuationPresent, 1, bool );
+ SENF_PARSER_SKIP_BITS ( 8 ); //currently unused bits
//if bit is set,another 32 bit present flag is attached (not implemented yet)
- SENF_PARSER_BITFIELD ( extendedBitmaskPresent, 1, bool );
- SENF_PARSER_SKIP_BITS ( 7 ); //currently unused bits
-
+ SENF_PARSER_BITFIELD ( extendedBitmaskPresent, 1, bool );
+ SENF_PARSER_SKIP_BITS ( 7 ); //currently unused bits
/*
* Radiotap data
* parsing data according to present flags
*/
- SENF_PARSER_VARIANT ( tsft_, tsftPresent,
- ( novalue ( disable_tsft, VoidPacketParser ))
- ( id ( tsft, UInt64LSBParser )) );
- SENF_PARSER_VARIANT ( flags_, flagsPresent,
- ( novalue ( disable_flags, VoidPacketParser ))
- ( id ( flags, RadiotapPacketParser_Flags )) );
- SENF_PARSER_VARIANT ( rate_, ratePresent,
- ( novalue ( disable_rate, VoidPacketParser ))
- ( id ( rate, UInt8Parser )) );
- SENF_PARSER_VARIANT ( channelFlags_, channelPresent,
- ( novalue ( disable_channelOptions, VoidPacketParser ))
- ( id ( channelOptions, RadiotapPacketParser_ChannelOptions )) );
- SENF_PARSER_VARIANT ( fhss_, fhssPresent,
- ( novalue ( disable_fhss, VoidPacketParser ))
- ( id ( fhss, UInt16LSBParser )) );
- SENF_PARSER_VARIANT ( dbmAntennaSignal_, dbmAntennaSignalPresent,
- ( novalue ( disable_dbmAntennaSignal, VoidPacketParser ))
- ( id ( dbmAntennaSignal, Int8Parser )) );
- SENF_PARSER_VARIANT ( dbmAntennaNoise_, dbmAntennaNoisePresent,
- ( novalue ( disable_dbmAntennaNoise, VoidPacketParser ))
- ( id ( dbmAntennaNoise, Int8Parser )) );
- SENF_PARSER_VARIANT ( lockQuality_, lockQualityPresent,
- ( novalue ( disable_lockQuality, VoidPacketParser ))
- ( id ( lockQuality, UInt16LSBParser )) );
- SENF_PARSER_VARIANT ( txAttenuation_, txAttenuationPresent,
- ( novalue ( disable_txAttenuation, VoidPacketParser ))
- ( id ( txAttenuation, UInt16LSBParser )) );
- SENF_PARSER_VARIANT ( dbTxAttenuation_, dbTxAttenuationPresent,
- ( novalue ( disable_dbTxAttenuation, VoidPacketParser ))
- ( id ( dbTxAttenuation, UInt16LSBParser )) );
- SENF_PARSER_VARIANT ( antenna_, antennaPresent,
- ( novalue ( disable_antenna, VoidPacketParser ))
- ( id ( antenna, UInt8Parser )) );
- SENF_PARSER_VARIANT ( dbAntennaSignal_, dbAntennaSignalPresent,
- ( novalue ( disable_dbAntennaSignal, VoidPacketParser ))
- ( id ( dbAntennaSignal, UInt8Parser )) );
- SENF_PARSER_VARIANT ( dbAntennaNoise_, dbAntennaNoisePresent,
- ( novalue ( disable_dbAntennaNoise, VoidPacketParser ))
- ( id ( dbAntennaNoise, UInt8Parser )) );
+ #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 );
SENF_PARSER_INIT() {
version() = 0;
}
-
SENF_PARSER_FINALIZE(RadiotapPacketParser);
};
+ /** \brief Radiotap packet
+ \par Packet type (typedef):
+ \ref RadiotapPacket
+ \par Fields:
+ \ref RadiotapPacketParser
+
+ \ingroup protocolbundle_80211
+ */
struct RadiotapPacketType
: public senf::PacketTypeBase,
public senf::PacketTypeMixin<RadiotapPacketType>
static void dump(packet p, std::ostream &os);
static void finalize(packet p);
-
-
};
- typedef RadiotapPacketType::packet RadiotapPacket;
+ typedef senf::ConcretePacket<RadiotapPacketType> RadiotapPacket;
}
#endif
-// $Id: $
+// $Id$
//
-// Copyright (C) 2006
+// Copyright (C) 2008
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
-// Christian Niephaus <christian.niephaus@fokus.fraunhofer.de>
+// Christian Niephaus <cni@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#include "RadiotapPacket.hh"
-#include <senf/Utils/hexdump.hh>
+
BOOST_AUTO_UNIT_TEST(RadiotapPacket_packet)
{
/* used madwifi 0.9.4 */
- unsigned char data[] = { 0x00 ,0x00 ,0x1a ,0x00, 0x6f, 0x18, 0x00, 0x00,
- 0x02, 0xe6, 0x8a, 0xdf, 0x12, 0x00, 0x00, 0x00,
- 0x12, 0x0c, 0xc8, 0x14, 0x40, 0x01, 0xc3, 0xa0,
- 0x02, 0x23
- };
+ unsigned char data[] = {
+ 0x00 ,0x00 ,0x1a ,0x00, 0x6f, 0x18, 0x00, 0x00,
+ 0x02, 0xe6, 0x8a, 0xdf, 0x12, 0x00, 0x00, 0x00,
+ 0x12, 0x0c, 0xc8, 0x14, 0x40, 0x01, 0xc3, 0xa0,
+ 0x02, 0x23
+ };
senf::RadiotapPacket p (senf::RadiotapPacket::create(data));
/* mandatory fields*/
BOOST_CHECK_EQUAL( p->flagsPresent(), true);
BOOST_CHECK_EQUAL( p->extendedBitmaskPresent(), false);
BOOST_CHECK_EQUAL( p->ratePresent(), true);
- BOOST_CHECK_EQUAL( p->channelPresent(), true);
+ BOOST_CHECK_EQUAL( p->channelOptionsPresent(), true);
BOOST_CHECK_EQUAL( p->fhssPresent(), false);
BOOST_CHECK_EQUAL( p->dbmAntennaSignalPresent(), true);
BOOST_CHECK_EQUAL( p->dbmAntennaNoisePresent(), true);
BOOST_AUTO_UNIT_TEST(RadiotapPacket_create)
{
- unsigned char data[] = { 0x00 ,0x00 ,0x1a ,0x00, 0x6f, 0x18, 0x00, 0x00,
- 0x02, 0xe6, 0x8a, 0xdf, 0x12, 0x00, 0x00, 0x00,
- 0x12, 0x0c, 0xc8, 0x14, 0x40, 0x01, 0xc3, 0xa0,
- 0x02, 0x23
- };
+ unsigned char data[] = {
+ 0x00 ,0x00 ,0x1a ,0x00, 0x6f, 0x18, 0x00, 0x00,
+ 0x02, 0xe6, 0x8a, 0xdf, 0x12, 0x00, 0x00, 0x00,
+ 0x12, 0x0c, 0xc8, 0x14, 0x40, 0x01, 0xc3, 0xa0,
+ 0x02, 0x23
+ };
senf::RadiotapPacket p (senf::RadiotapPacket::create());
- SENF_CHECK_NO_THROW(p->init_tsft());
- SENF_CHECK_NO_THROW(p->tsft()=81059833346uLL);
-
- SENF_CHECK_NO_THROW(p->init_rate());
- SENF_CHECK_NO_THROW(p->rate()=12u);
- SENF_CHECK_NO_THROW(p->init_dbmAntennaSignal());
- SENF_CHECK_NO_THROW(p->dbmAntennaSignal()=-61);
- SENF_CHECK_NO_THROW(p->init_dbmAntennaNoise());
- SENF_CHECK_NO_THROW(p->dbmAntennaNoise()=-96);
- SENF_CHECK_NO_THROW(p->init_antenna());
- SENF_CHECK_NO_THROW(p->antenna()=2u);
- SENF_CHECK_NO_THROW(p->init_dbAntennaSignal());
- SENF_CHECK_NO_THROW(p->dbAntennaSignal()=35);
-
- SENF_CHECK_NO_THROW(p->init_flags());
- SENF_CHECK_NO_THROW(p->flags().cfp()=false);
- SENF_CHECK_NO_THROW(p->flags().shortPreamble()=true);
- SENF_CHECK_NO_THROW(p->flags().wep()=false);
- SENF_CHECK_NO_THROW(p->flags().fragmentation()=false);
- SENF_CHECK_NO_THROW(p->flags().fcsPresent()=true);
- SENF_CHECK_NO_THROW(p->flags().padding()=false);
- SENF_CHECK_NO_THROW(p->flags().badFCS()=false);
- SENF_CHECK_NO_THROW(p->flags().shortGI()=false);
-
- SENF_CHECK_NO_THROW(p->init_channelOptions());
- SENF_CHECK_NO_THROW(p->channelOptions().freq()=5320u)
- SENF_CHECK_NO_THROW(p->channelOptions().ofdm()=true);
- SENF_CHECK_NO_THROW(p->channelOptions().turbo()=false);
- SENF_CHECK_NO_THROW(p->channelOptions().cck()=false);
- SENF_CHECK_NO_THROW(p->channelOptions().flag5ghz()=true);
- SENF_CHECK_NO_THROW(p->channelOptions().passive()=false);
- SENF_CHECK_NO_THROW(p->channelOptions().cckOfdm()=false);
- SENF_CHECK_NO_THROW(p->channelOptions().gfsk()=false);
- SENF_CHECK_NO_THROW(p->channelOptions().gsm()=false);
- SENF_CHECK_NO_THROW(p->channelOptions().staticTurbo()=false);
- SENF_CHECK_NO_THROW(p->channelOptions().halfRateChannel()=false);
- SENF_CHECK_NO_THROW(p->channelOptions().quarterRateChannel()=false);
+ SENF_CHECK_NO_THROW( p->init_tsft());
+ SENF_CHECK_NO_THROW( p->tsft()=81059833346uLL);
+
+ SENF_CHECK_NO_THROW( p->init_rate());
+ SENF_CHECK_NO_THROW( p->rate() = 12u);
+ SENF_CHECK_NO_THROW( p->init_dbmAntennaSignal());
+ SENF_CHECK_NO_THROW( p->dbmAntennaSignal() = -61);
+ SENF_CHECK_NO_THROW( p->init_dbmAntennaNoise());
+ SENF_CHECK_NO_THROW( p->dbmAntennaNoise() = -96);
+ SENF_CHECK_NO_THROW( p->init_antenna());
+ SENF_CHECK_NO_THROW( p->antenna() = 2u);
+ SENF_CHECK_NO_THROW( p->init_dbAntennaSignal());
+ SENF_CHECK_NO_THROW( p->dbAntennaSignal() = 35);
+
+ SENF_CHECK_NO_THROW( p->init_flags());
+ SENF_CHECK_NO_THROW( p->flags().cfp() = false);
+ SENF_CHECK_NO_THROW( p->flags().shortPreamble() = true);
+ SENF_CHECK_NO_THROW( p->flags().wep() = false);
+ SENF_CHECK_NO_THROW( p->flags().fragmentation() = false);
+ SENF_CHECK_NO_THROW( p->flags().fcsPresent() = true);
+ SENF_CHECK_NO_THROW( p->flags().padding() = false);
+ SENF_CHECK_NO_THROW( p->flags().badFCS() = false);
+ SENF_CHECK_NO_THROW( p->flags().shortGI() = false);
+
+ SENF_CHECK_NO_THROW( p->init_channelOptions());
+ SENF_CHECK_NO_THROW( p->channelOptions().freq() = 5320u)
+ SENF_CHECK_NO_THROW( p->channelOptions().ofdm() = true);
+ SENF_CHECK_NO_THROW( p->channelOptions().turbo() = false);
+ SENF_CHECK_NO_THROW( p->channelOptions().cck() = false);
+ SENF_CHECK_NO_THROW( p->channelOptions().flag5ghz() = true);
+ SENF_CHECK_NO_THROW( p->channelOptions().passive() = false);
+ SENF_CHECK_NO_THROW( p->channelOptions().cckOfdm() = false);
+ SENF_CHECK_NO_THROW( p->channelOptions().gfsk() = false);
+ SENF_CHECK_NO_THROW( p->channelOptions().gsm() = false);
+ SENF_CHECK_NO_THROW( p->channelOptions().staticTurbo() = false);
+ SENF_CHECK_NO_THROW( p->channelOptions().halfRateChannel() = false);
+ SENF_CHECK_NO_THROW( p->channelOptions().quarterRateChannel() = false);
p.finalizeAll();
BOOST_CHECK_EQUAL( p->length(), 26u );
BOOST_CHECK( equal( p.data().begin(), p.data().end(), data ));
-
}
-
-