--- /dev/null
+// $Id: $
+//
+// Copyright (C) 2006
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Christian Niephaus <christian.niephaus@fokus.fraunhofer.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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+// Definition of non-inline non-template functions
+
+// Custom includes
+#include "RadiotapPacket.hh"
+#include "../../Packets/Packets.hh"
+#include <boost/io/ios_state.hpp>
+
+#define prefix_
+
+namespace
+{
+
+}
+
+prefix_ void senf::RadiotapPacketType::dump(packet p, std::ostream &os)
+{
+ boost::io::ios_all_saver ias(os);
+ os << "Radiotap:\n"
+ << " Version : " << p->version() << "\n"
+ << " Length : " << p->length() << "\n";
+}
+
+prefix_ void senf::RadiotapPacketType::finalize(packet p)
+{
+ p->length() << p.size();
+}
+
+
+#undef prefix_
--- /dev/null
+// $Id:$
+//
+// Copyright (C) 2006
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Christian Niephaus <christian.niephaus@fokus.fraunhofer.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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief Radiotap header \n
+ <b>Radiotap uses least significant bit byte order</b>
+
+
+ */
+
+#ifndef HH_RadiotapPacket_
+#define HH_RadioPacket_ 1
+
+#include "../../Packets/Packets.hh"
+
+namespace senf
+{
+
+ /** \brief Parse Flag field in Radiotap header
+ * <b>Re-ordering of bits due to LSB byte order</b>
+
+ */
+ struct RadiotapPacketParser_Flags : public senf::PacketParserBase
+ {
+ # 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_FINALIZE ( RadiotapPacketParser_Flags );
+
+ };
+
+ /** \brief Parse in Radiotap Header channel frequency and flag field
+
+ <b>Re-ordering of bits due to LSB byte order</b>
+ */
+ struct RadiotapPacketParser_ChannelOptions : public senf::PacketParserBase
+ {
+ # 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_FINALIZE ( RadiotapPacketParser_ChannelOptions );
+ };
+
+ /** \brief Parse an Radiotap header
+
+ Parser implementing the Radiotap header
+
+ \see <a href="http://www.radiotap.org">Radiotap.org</a>
+
+ \todo extended present field (bit 31 of present field is set)
+ */
+ struct RadiotapPacketParser : public senf::PacketParserBase
+ {
+ # include SENF_PARSER()
+
+ /*
+ * mandatory fields
+ */
+ 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);
+
+ /*
+ * 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
+ //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
+
+
+ /*
+ * 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 )) );
+
+ SENF_PARSER_INIT() {
+ version() = 0;
+ }
+
+
+ SENF_PARSER_FINALIZE(RadiotapPacketParser);
+ };
+
+
+
+ struct RadiotapPacketType
+ : public senf::PacketTypeBase,
+ public senf::PacketTypeMixin<RadiotapPacketType>
+ {
+ typedef senf::PacketTypeMixin<RadiotapPacketType> mixin;
+ typedef senf::ConcretePacket<RadiotapPacketType> packet;
+ typedef senf::RadiotapPacketParser parser;
+
+ using mixin::nextPacketRange;
+ using mixin::init;
+ using mixin::initSize;
+
+ static void dump(packet p, std::ostream &os);
+ static void finalize(packet p);
+
+
+ };
+
+ typedef RadiotapPacketType::packet RadiotapPacket;
+}
+
+#endif
--- /dev/null
+// $Id: $
+//
+// Copyright (C) 2006
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Christian Niephaus <christian.niephaus@fokus.fraunhofer.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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+// Definition of non-inline non-template functions
+
+// Custom includes
+#include "../../Packets/Packets.hh"
+#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
+ };
+ senf::RadiotapPacket p (senf::RadiotapPacket::create(data));
+
+ /* mandatory fields*/
+ BOOST_CHECK_EQUAL( p->version(), 0u);
+ BOOST_CHECK_EQUAL( p->length(), 26u);
+
+ /* present flags */
+ BOOST_CHECK_EQUAL( p->tsftPresent(), true);
+ 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->fhssPresent(), false);
+ BOOST_CHECK_EQUAL( p->dbmAntennaSignalPresent(), true);
+ BOOST_CHECK_EQUAL( p->dbmAntennaNoisePresent(), true);
+ BOOST_CHECK_EQUAL( p->lockQualityPresent(), false);
+ BOOST_CHECK_EQUAL( p->txAttenuationPresent(), false);
+ BOOST_CHECK_EQUAL( p->dbmTxAttenuationPresent(), false);
+ BOOST_CHECK_EQUAL( p->dbTxAttenuationPresent(), false);
+ BOOST_CHECK_EQUAL( p->antennaPresent(), true);
+ BOOST_CHECK_EQUAL( p->dbAntennaSignalPresent(), true);
+ BOOST_CHECK_EQUAL( p->dbAntennaNoisePresent(), false);
+
+ /* data flieds */
+ BOOST_CHECK_EQUAL( p->tsft(), 81059833346uLL);
+ BOOST_CHECK_EQUAL( p->rate(), 12u);
+ BOOST_CHECK_EQUAL( p->channelOptions().freq(), 5320u);
+ BOOST_CHECK_EQUAL( p->dbmAntennaSignal(), -61);
+ BOOST_CHECK_EQUAL( p->dbmAntennaNoise(), -96);
+ BOOST_CHECK_EQUAL( p->antenna(), 2u);
+ BOOST_CHECK_EQUAL( p->dbAntennaSignal(), 35u);
+
+ /* flags */
+ BOOST_CHECK_EQUAL( p->flags().cfp(), false);
+ BOOST_CHECK_EQUAL( p->flags().shortPreamble(), true);
+ BOOST_CHECK_EQUAL( p->flags().wep(), false);
+ BOOST_CHECK_EQUAL( p->flags().fragmentation(), false);
+ BOOST_CHECK_EQUAL( p->flags().fcsPresent(), true);
+ BOOST_CHECK_EQUAL( p->flags().padding(), false);
+ BOOST_CHECK_EQUAL( p->flags().badFCS(), false);
+ BOOST_CHECK_EQUAL( p->flags().shortGI(), false);
+
+ /* channel flags */
+ BOOST_CHECK_EQUAL( p->channelOptions().ofdm(), true);
+ BOOST_CHECK_EQUAL( p->channelOptions().turbo(), false);
+ BOOST_CHECK_EQUAL( p->channelOptions().cck(), false);
+ BOOST_CHECK_EQUAL( p->channelOptions().flag5ghz(), true);
+ BOOST_CHECK_EQUAL( p->channelOptions().passive(), false);
+ BOOST_CHECK_EQUAL( p->channelOptions().cckOfdm(), false);
+ BOOST_CHECK_EQUAL( p->channelOptions().gfsk(), false);
+ BOOST_CHECK_EQUAL( p->channelOptions().gsm(), false);
+ BOOST_CHECK_EQUAL( p->channelOptions().staticTurbo(), false);
+ BOOST_CHECK_EQUAL( p->channelOptions().halfRateChannel(), false);
+ BOOST_CHECK_EQUAL( p->channelOptions().quarterRateChannel(), false);
+}
+
+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
+ };
+
+ 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);
+
+ p.finalizeAll();
+
+ BOOST_CHECK_EQUAL( p->length(), 26u );
+ BOOST_CHECK( equal( p.data().begin(), p.data().end(), data ));
+
+}
+
+
--- /dev/null
+# -*- python -*-
+
+Import('env')
+import SENFSCons, glob
+
+###########################################################################
+
+sources = SENFSCons.GlobSources()
+
+SENFSCons.StandardTargets(env)
+
+SENFSCons.Object(env,
+ target = '80211Bundle',
+ sources=sources,
+ LIBS = ['Packets', 'Socket', 'Utils'])
+
+SENFSCons.Lib(env,
+ library = 'Packets_80211Bundle',
+ sources = sources[0],
+ no_includes = 1)
+
+SConscript(glob.glob("*/SConscript"))
--- /dev/null
+// $Id: main.test.cc 206 2007-02-20 14:20:52Z g0dil $
+//
+// Copyright (C) 2006
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+// Definition of non-inline non-template functions
+
+//#include "test.hh"
+//#include "test.ih"
+
+// Custom includes
+#define BOOST_AUTO_TEST_MAIN
+#include "../../Utils/auto_unit_test.hh"
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
+// End: