From: tho Date: Tue, 9 Dec 2008 11:14:57 +0000 (+0000) Subject: some clean-ups X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=0cfb397285c36522faa97c801e6f8332fdd539cf;p=senf.git some clean-ups git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1007 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/RateStuffer/Doxyfile b/Examples/RateStuffer/Doxyfile index a9ffe3f..fb922ad 100644 --- a/Examples/RateStuffer/Doxyfile +++ b/Examples/RateStuffer/Doxyfile @@ -1,7 +1,8 @@ @INCLUDE = "$(TOPDIR)/doclib/Doxyfile.global" -PROJECT_NAME = RateStuffer +SHOW_NAMESPACES = NO ALPHABETICAL_INDEX = NO +PROJECT_NAME = RateStuffer EXAMPLE_PATH = . TAGFILES = \ diff --git a/Examples/Sniffer/Doxyfile b/Examples/Sniffer/Doxyfile index c0880ed..0387e19 100644 --- a/Examples/Sniffer/Doxyfile +++ b/Examples/Sniffer/Doxyfile @@ -1,5 +1,7 @@ @INCLUDE = "$(TOPDIR)/doclib/Doxyfile.global" +SHOW_NAMESPACES = NO +ALPHABETICAL_INDEX = NO PROJECT_NAME = Sniffer EXAMPLE_PATH = . diff --git a/Examples/UDPClientServer/Doxyfile b/Examples/UDPClientServer/Doxyfile index 8e274d1..c4ed1e4 100644 --- a/Examples/UDPClientServer/Doxyfile +++ b/Examples/UDPClientServer/Doxyfile @@ -1,5 +1,7 @@ @INCLUDE = "$(TOPDIR)/doclib/Doxyfile.global" +SHOW_NAMESPACES = NO +ALPHABETICAL_INDEX = NO PROJECT_NAME = UDPClientServer EXAMPLE_PATH = . diff --git a/Packets/80211Bundle/WLANPacket.cc b/Packets/80211Bundle/WLANPacket.cc index 5695f4b..33a2809 100644 --- a/Packets/80211Bundle/WLANPacket.cc +++ b/Packets/80211Bundle/WLANPacket.cc @@ -1,9 +1,9 @@ -// $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 // // 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 @@ -30,12 +30,7 @@ #define prefix_ -namespace -{ - -} - -prefix_ senf::MACAddressParser senf::WLANPacketParser_DataFrameParser::da() +prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::da() const { switch (dsBits()) @@ -54,7 +49,7 @@ prefix_ senf::MACAddressParser senf::WLANPacketParser_DataFrameParser::da() return addr1(); } -prefix_ senf::MACAddressParser senf::WLANPacketParser_DataFrameParser::sa() +prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::sa() const { switch (dsBits()) @@ -75,7 +70,7 @@ prefix_ senf::MACAddressParser senf::WLANPacketParser_DataFrameParser::sa() return addr1(); } -prefix_ senf::MACAddressParser senf::WLANPacketParser_DataFrameParser::bssid() +prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::bssid() const { switch (dsBits()) @@ -95,7 +90,7 @@ prefix_ senf::MACAddressParser senf::WLANPacketParser_DataFrameParser::bssid() } //shift some bits to read the 12bit sequence number bit field in LSB byte order -prefix_ boost::uint16_t senf::WLANPacketParser_MgtFrameParser::sequenceNumber() +prefix_ boost::uint16_t senf::WLANPacket_MgtFrameParser::sequenceNumber() const { boost::uint16_t seqN = 0; @@ -106,7 +101,7 @@ prefix_ boost::uint16_t senf::WLANPacketParser_MgtFrameParser::sequenceNumber() } //shift some bits to read the 12bit sequence number bit field in LSB byte order -prefix_ boost::uint16_t senf::WLANPacketParser_DataFrameParser::sequenceNumber() +prefix_ boost::uint16_t senf::WLANPacket_DataFrameParser::sequenceNumber() const { boost::uint16_t seqN = 0; @@ -127,9 +122,9 @@ prefix_ void senf::WLANPacketType::dump(packet p, std::ostream &os) if (p->has_mgtFrame()) { - os << " BSSID : " << p->mgtFrame().bssid() << "\n"; - os << " Destination Addr. : " << p->mgtFrame().da() << "\n"; - os << " Source Addr. : " << p->mgtFrame().sa() << "\n"; + os << " BSSID : " << p->mgtFrame().bssid() << "\n"; + os << " Destination Address : " << p->mgtFrame().destinationAddress() << "\n"; + os << " Source Address : " << p->mgtFrame().sourceAddress() << "\n"; } }; diff --git a/Packets/80211Bundle/WLANPacket.hh b/Packets/80211Bundle/WLANPacket.hh index 47f4930..f7c5688 100644 --- a/Packets/80211Bundle/WLANPacket.hh +++ b/Packets/80211Bundle/WLANPacket.hh @@ -1,9 +1,9 @@ -// $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 // // 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 @@ -21,17 +21,13 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief 802.11 WLan MAC frame \n + \brief 802.11 WLANPacket public header */ - - */ - -#ifndef WLANPACKET_HH_ -#define WLANPACKET_HH_ +#ifndef HH_SENF_Packets_80211Bundle_WLANPacket_ +#define HH_SENF_Packets_80211Bundle_WLANPacket_ 1 #include "../../Packets/Packets.hh" #include "../DefaultBundle/EthernetPacket.hh" -#include namespace senf { @@ -40,29 +36,29 @@ namespace senf * Re-ordering of bits due to LSB byte order */ - struct WLANPacketParser_MgtFrameParser : public senf::PacketParserBase + struct WLANPacket_MgtFrameParser : public senf::PacketParserBase { # include SENF_FIXED_PARSER() - SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned); - SENF_PARSER_SKIP_BITS ( 4 ); //skip type and version + + SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned ); + SENF_PARSER_SKIP_BITS ( 4 ); //skip type and version //jump to fist address field - SENF_PARSER_SKIP ( 3 ); - SENF_PARSER_FIELD ( da, MACAddressParser ); - SENF_PARSER_FIELD ( sa, MACAddressParser ); - SENF_PARSER_FIELD ( bssid, MACAddressParser ); + SENF_PARSER_SKIP ( 3 ); + SENF_PARSER_FIELD ( destinationAddress, MACAddressParser ); + SENF_PARSER_FIELD ( sourceAddress, MACAddressParser ); + SENF_PARSER_FIELD ( bssid, MACAddressParser ); //workaround since bitfield LSB parsers are not available - SENF_PARSER_PRIVATE_BITFIELD (seqNumber_1, 4, unsigned); - SENF_PARSER_BITFIELD (fragmentNumber, 4, unsigned); - SENF_PARSER_PRIVATE_FIELD (seqNumber_2, UInt8Parser); + SENF_PARSER_PRIVATE_BITFIELD ( seqNumber_1, 4, unsigned ); + SENF_PARSER_BITFIELD ( fragmentNumber, 4, unsigned ); + SENF_PARSER_PRIVATE_FIELD ( seqNumber_2, UInt8Parser ); - SENF_PARSER_FINALIZE(WLANPacketParser_MgtFrameParser); + SENF_PARSER_FINALIZE(WLANPacket_MgtFrameParser); //this is needed due to the goto in the WLANPacketParser. Don't know exactly why yet. SENF_PARSER_INIT() {} boost::uint16_t sequenceNumber() const; - }; /** \brief Control frame parser @@ -71,23 +67,24 @@ namespace senf * currently only CTS, RTS and ACK control frames are supported */ - struct WLANPacketParser_CtrlFrameParser : public senf::PacketParserBase + struct WLANPacket_CtrlFrameParser : public senf::PacketParserBase { # include SENF_PARSER() - SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned); - SENF_PARSER_SKIP_BITS ( 4 ); //skip type and version + + SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned ); + SENF_PARSER_SKIP_BITS ( 4 ); //skip type and version //jump to fist address field - SENF_PARSER_SKIP ( 3,3 ); - SENF_PARSER_FIELD ( ra, MACAddressParser ); + SENF_PARSER_SKIP ( 3, 3 ); + SENF_PARSER_FIELD ( recieverAddress, MACAddressParser ); //only RTS frame contains a source address field - //variant is also needed so set to correct subtype value - SENF_PARSER_VARIANT ( subtype__, subtype, - ( ids (na, na, set_cts, key(12, VoidPacketParser)) ) - ( ids (na, na, set_ack, key(13, VoidPacketParser)) ) - ( ids (sa, has_sa, set_rts, key(11, MACAddressParser)) ) ); + //variant is also needed to set correct subtype value + SENF_PARSER_VARIANT ( subtype__, subtype, + ( ids( na, is_cts, set_cts, key(12, VoidPacketParser)) ) + ( ids( na, is_ack, set_ack, key(13, VoidPacketParser)) ) + ( ids( sourceAddress, is_rts, set_rts, key(11, MACAddressParser)) ) ); - SENF_PARSER_FINALIZE(WLANPacketParser_CtrlFrameParser); + SENF_PARSER_FINALIZE(WLANPacket_CtrlFrameParser); //this is needed to due to the goto in the WLANPacketParser. Don't know exactly why yet. SENF_PARSER_INIT() {} @@ -97,7 +94,7 @@ namespace senf * Re-ordering of bits due to LSB byte order */ - struct WLANPacketParser_DataFrameParser : public senf::PacketParserBase + struct WLANPacket_DataFrameParser : public senf::PacketParserBase { # include SENF_PARSER() SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned); @@ -136,7 +133,7 @@ namespace senf - SENF_PARSER_FINALIZE(WLANPacketParser_DataFrameParser); + SENF_PARSER_FINALIZE(WLANPacket_DataFrameParser); //this is needed to due to the goto in the WLANPacketParser. Don't know exactly why yet. SENF_PARSER_INIT() {} @@ -164,36 +161,34 @@ namespace senf * Frame control field * re-ordering of fields due to the byte order */ - SENF_PARSER_BITFIELD_RO ( subtype, 4, unsigned); - SENF_PARSER_BITFIELD_RO ( type, 2, unsigned); - SENF_PARSER_BITFIELD ( version, 2, unsigned); - SENF_PARSER_BITFIELD ( order, 1, bool); - SENF_PARSER_BITFIELD ( protectedFrame, 1, bool); - SENF_PARSER_BITFIELD ( moreData, 1, bool); - SENF_PARSER_BITFIELD ( pwrMgt, 1, bool); - SENF_PARSER_BITFIELD ( retry, 1, bool); - SENF_PARSER_BITFIELD ( moreFrag, 1, bool); - SENF_PARSER_BITFIELD ( fromDS, 1, bool); - SENF_PARSER_BITFIELD ( toDS, 1, bool); - - SENF_PARSER_FIELD (duration, UInt16LSBParser); + SENF_PARSER_BITFIELD_RO ( subtype, 4, unsigned ); + SENF_PARSER_BITFIELD_RO ( type, 2, unsigned ); + SENF_PARSER_BITFIELD ( version, 2, unsigned ); + SENF_PARSER_BITFIELD ( order, 1, bool ); + SENF_PARSER_BITFIELD ( protectedFrame, 1, bool ); + SENF_PARSER_BITFIELD ( moreData, 1, bool ); + SENF_PARSER_BITFIELD ( pwrMgt, 1, bool ); + SENF_PARSER_BITFIELD ( retry, 1, bool ); + SENF_PARSER_BITFIELD ( moreFrag, 1, bool ); + SENF_PARSER_BITFIELD ( fromDS, 1, bool ); + SENF_PARSER_BITFIELD ( toDS, 1, bool ); + + SENF_PARSER_FIELD (duration, UInt16LSBParser); SENF_PARSER_GOTO( subtype ); //subparsers need to know the subtype SENF_PARSER_VARIANT ( type__, type, - ( id ( mgtFrame, WLANPacketParser_MgtFrameParser )) - ( id ( ctrlFrame, WLANPacketParser_CtrlFrameParser )) - ( id ( dataFrame, WLANPacketParser_DataFrameParser )) - ( novalue ( reserved, WLANPacketParser_CtrlFrameParser )) ); + ( id( mgtFrame, WLANPacket_MgtFrameParser )) + ( id( ctrlFrame, WLANPacket_CtrlFrameParser )) + ( id( dataFrame, WLANPacket_DataFrameParser )) + ( novalue( reserved, WLANPacket_CtrlFrameParser )) ); - SENF_PARSER_CUSTOM_FIELD( fcs, senf:: UInt32Parser, fcs_t::fixed_bytes, fcs_t::fixed_bytes) { + SENF_PARSER_CUSTOM_FIELD( fcs, senf::UInt32Parser, fcs_t::fixed_bytes, fcs_t::fixed_bytes) { return parse( data().size()-4 ); } SENF_PARSER_FINALIZE(WLANPacketParser); SENF_PARSER_INIT() { version() = 0; - - } //Problems can occur with old madwifi and ath5k. Some frames only @@ -204,9 +199,8 @@ namespace senf struct WLANPacketType : public senf::PacketTypeBase, - public senf::PacketTypeMixin + public senf::PacketTypeMixin { - typedef senf::PacketTypeMixin mixin; typedef senf::ConcretePacket packet; typedef WLANPacketParser parser; @@ -216,15 +210,12 @@ namespace senf using mixin::initSize; using senf::PacketTypeBase::nextPacketRange;; - static void dump(packet p, std::ostream &os); // static PacketParserBase::size_type initSize(); }; - typedef WLANPacketType::packet WLANPacket; - + typedef senf::ConcretePacket WLANPacket; } - -#endif /* WLANPACKET_HH_ */ +#endif /* HH_SENF_Packets_80211Bundle_WLANPacket_ */ diff --git a/Packets/80211Bundle/WLANPacket.test.cc b/Packets/80211Bundle/WLANPacket.test.cc index e66acd0..9de635f 100644 --- a/Packets/80211Bundle/WLANPacket.test.cc +++ b/Packets/80211Bundle/WLANPacket.test.cc @@ -1,9 +1,9 @@ -// $Id: main.test.cc 206 2008-08-06 14:20:52Z pug $ +// $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 // // 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 @@ -20,7 +20,8 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline non-template functions +/** \file + \brief WLANPacket.test unit tests */ // Custom includes @@ -32,187 +33,171 @@ /* test parser with a data frame */ BOOST_AUTO_UNIT_TEST(WLANPacket_dataFrame_packet) { - - - unsigned char data[] = {0x88, 0x01, 0x00, 0x00, 0x00, 0x1a, //header - 0x4d, 0x3e, 0xc7, 0x5c, 0x00, 0x0b, 0x6b, 0x57, - 0x06, 0xb0, 0x00, 0x18, 0x4d, 0x6e, 0x78, 0x48, - 0x30, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //dummy data - 0x38, 0x39, 0x30, 0x31 //trailer - }; - - - + unsigned char data[] = { + 0x88, 0x01, 0x00, 0x00, 0x00, 0x1a, //header + 0x4d, 0x3e, 0xc7, 0x5c, 0x00, 0x0b, 0x6b, 0x57, + 0x06, 0xb0, 0x00, 0x18, 0x4d, 0x6e, 0x78, 0x48, + 0x30, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //dummy data + 0x38, 0x39, 0x30, 0x31 //trailer + }; senf::WLANPacket p (senf::WLANPacket::create(data)); - BOOST_CHECK_EQUAL( p->version(), 0u); - BOOST_CHECK_EQUAL( p->type(), 2u); - BOOST_CHECK_EQUAL( p->subtype(), 8u); - BOOST_CHECK_EQUAL( p->toDS(), true); - BOOST_CHECK_EQUAL( p->fromDS(), false); - BOOST_CHECK_EQUAL( p->moreFrag(), false); - BOOST_CHECK_EQUAL( p->retry(), false); - BOOST_CHECK_EQUAL( p->pwrMgt(), false); - BOOST_CHECK_EQUAL( p->moreData(), false); - BOOST_CHECK_EQUAL( p->protectedFrame(), false); - BOOST_CHECK_EQUAL( p->order(), false); - - BOOST_CHECK_EQUAL( p->duration(), 0u); - - BOOST_CHECK_EQUAL( p->dataFrame().da()[0], 0x00 ); - BOOST_CHECK_EQUAL( p->dataFrame().da()[1], 0x18 ); - BOOST_CHECK_EQUAL( p->dataFrame().da()[2], 0x4d ); - BOOST_CHECK_EQUAL( p->dataFrame().da()[3], 0x6e ); - BOOST_CHECK_EQUAL( p->dataFrame().da()[4], 0x78 ); - BOOST_CHECK_EQUAL( p->dataFrame().da()[5], 0x48 ); - - BOOST_CHECK_EQUAL( p->dataFrame().sa()[0], 0x00 ); - BOOST_CHECK_EQUAL( p->dataFrame().sa()[3], 0x57 ); - BOOST_CHECK_EQUAL( p->dataFrame().sa()[5], 0xb0 ); - - BOOST_CHECK_EQUAL( p->dataFrame().bssid()[0], 0x00 ); - BOOST_CHECK_EQUAL( p->dataFrame().bssid()[3], 0x3e ); - BOOST_CHECK_EQUAL( p->dataFrame().bssid()[5], 0x5c ); - - BOOST_CHECK_EQUAL( p->dataFrame().bssid()[3], - p->dataFrame().ra()[3]); - - BOOST_CHECK_EQUAL( p->dataFrame().ta()[3], - p->dataFrame().sa()[3]); + BOOST_CHECK_EQUAL( p->version(), 0u ); + BOOST_CHECK_EQUAL( p->type(), 2u ); + BOOST_CHECK_EQUAL( p->subtype(), 8u ); + BOOST_CHECK_EQUAL( p->toDS(), true ); + BOOST_CHECK_EQUAL( p->fromDS(), false ); + BOOST_CHECK_EQUAL( p->moreFrag(), false ); + BOOST_CHECK_EQUAL( p->retry(), false ); + BOOST_CHECK_EQUAL( p->pwrMgt(), false ); + BOOST_CHECK_EQUAL( p->moreData(), false ); + BOOST_CHECK_EQUAL( p->protectedFrame(), false ); + BOOST_CHECK_EQUAL( p->order(), false ); + + BOOST_CHECK_EQUAL( p->duration(), 0u ); + + BOOST_CHECK_EQUAL( + p->dataFrame().da().value(), + senf::MACAddress::from_string("00:18:4d:6e:78:48") ); + BOOST_CHECK_EQUAL( + p->dataFrame().sa().value(), + senf::MACAddress::from_string("00:0b:6b:57:06:b0") ); + BOOST_CHECK_EQUAL( + p->dataFrame().bssid().value(), + senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); + + BOOST_CHECK_EQUAL( + p->dataFrame().bssid().value(), p->dataFrame().ra().value() ); + BOOST_CHECK_EQUAL( + p->dataFrame().ta().value(), p->dataFrame().sa().value() ); BOOST_CHECK_EQUAL( p->dataFrame().sequenceNumber(), 3u ); BOOST_CHECK_EQUAL( p->dataFrame().fragmentNumber(), 0u ); - - - } + /* test parser with creating a data frame*/ BOOST_AUTO_UNIT_TEST(WLANPacket_dataFrame_create) { senf::WLANPacket p (senf::WLANPacket::create()); - SENF_CHECK_NO_THROW(p->init_dataFrame()); - p->dataFrame().bssid()=senf::MACAddress::from_string("00:1a:4d:3e:c7:5c"); - BOOST_CHECK_EQUAL( p->type(), 2u); + SENF_CHECK_NO_THROW( p->init_dataFrame() ); + SENF_CHECK_NO_THROW( p->dataFrame().bssid() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); + BOOST_CHECK_EQUAL( p->type(), 2u ); } - /* test parser with a beacon frame */ BOOST_AUTO_UNIT_TEST(WLANPacket_beaconFrame_packet) { - - - unsigned char data[] = {0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0x1a, 0x4d, 0x3e, 0xc7, 0x5c, - 0x00, 0x1a, 0x4d, 0x3e, 0xc7, 0x5c, 0xe0, 0x12, - 0x38, 0xa0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x01, 0x05, 0x00, 0x05, 0x62, 0x6f, - 0x78, 0x43, 0x31, 0x01, 0x08, 0x8c, 0x12, 0x98, - 0x24, 0xb0, 0x48, 0x60, 0x6c, 0x03, 0x01, 0x40, - 0x05, 0x04, 0x00, 0x01, 0x00, 0x00, 0x07, 0x2a, - 0x4e, 0x41, 0x49, 0x24, 0x01, 0x11, 0x28, 0x01, - 0x11, 0x2c, 0x01, 0x11, 0x30, 0x01, 0x11, 0x34, - 0x01, 0x17, 0x38, 0x01, 0x17, 0x3c, 0x01, 0x17, - 0x40, 0x01, 0x17, 0x95, 0x01, 0x1e, 0x99, 0x01, - 0x1e, 0x9d, 0x01, 0x1e, 0xa1, 0x01, 0x1e, 0xa5, - 0x01, 0x1e, 0x20, 0x01, 0x00, 0xdd, 0x18, 0x00, - 0x50, 0xf2, 0x02, 0x01, 0x01, 0x81, 0x00, 0x02, - 0xa3, 0x40, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, - 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00, 0xa0, - 0x00, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, - 0x00, 0x24, 0xff, 0x7f, 0x87, 0x07, 0x1f, 0xf5, - }; + unsigned char data[] = { + 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x1a, 0x4d, 0x3e, 0xc7, 0x5c, + 0x00, 0x1a, 0x4d, 0x3e, 0xc7, 0x5c, 0xe0, 0x12, + 0x38, 0xa0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x01, 0x05, 0x00, 0x05, 0x62, 0x6f, + 0x78, 0x43, 0x31, 0x01, 0x08, 0x8c, 0x12, 0x98, + 0x24, 0xb0, 0x48, 0x60, 0x6c, 0x03, 0x01, 0x40, + 0x05, 0x04, 0x00, 0x01, 0x00, 0x00, 0x07, 0x2a, + 0x4e, 0x41, 0x49, 0x24, 0x01, 0x11, 0x28, 0x01, + 0x11, 0x2c, 0x01, 0x11, 0x30, 0x01, 0x11, 0x34, + 0x01, 0x17, 0x38, 0x01, 0x17, 0x3c, 0x01, 0x17, + 0x40, 0x01, 0x17, 0x95, 0x01, 0x1e, 0x99, 0x01, + 0x1e, 0x9d, 0x01, 0x1e, 0xa1, 0x01, 0x1e, 0xa5, + 0x01, 0x1e, 0x20, 0x01, 0x00, 0xdd, 0x18, 0x00, + 0x50, 0xf2, 0x02, 0x01, 0x01, 0x81, 0x00, 0x02, + 0xa3, 0x40, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, + 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00, 0xa0, + 0x00, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, + 0x00, 0x24, 0xff, 0x7f, 0x87, 0x07, 0x1f, 0xf5, + }; senf::WLANPacket p (senf::WLANPacket::create(data)); - BOOST_CHECK_EQUAL( p->version(), 0u); - BOOST_CHECK_EQUAL( p->type(), 0u); - BOOST_CHECK_EQUAL( p->subtype(), 8u); - BOOST_CHECK_EQUAL( p->toDS(), false); - BOOST_CHECK_EQUAL( p->fromDS(), false); - BOOST_CHECK_EQUAL( p->moreFrag(), false); - BOOST_CHECK_EQUAL( p->retry(), false); - BOOST_CHECK_EQUAL( p->pwrMgt(), false); - BOOST_CHECK_EQUAL( p->moreData(), false); - BOOST_CHECK_EQUAL( p->protectedFrame(), false); - BOOST_CHECK_EQUAL( p->order(), false); - - BOOST_CHECK_EQUAL( p->duration(), 0u); - - BOOST_CHECK_EQUAL (p->has_mgtFrame(), true); - - BOOST_CHECK_EQUAL( p->mgtFrame().da()[0], 0xff ); - BOOST_CHECK_EQUAL( p->mgtFrame().da()[3], 0xff ); - BOOST_CHECK_EQUAL( p->mgtFrame().da()[5], 0xff ); - - BOOST_CHECK_EQUAL( p->mgtFrame().sa()[0], 0x00 ); - BOOST_CHECK_EQUAL( p->mgtFrame().sa()[3], 0x3e ); - BOOST_CHECK_EQUAL( p->mgtFrame().sa()[5], 0x5c ); - - BOOST_CHECK_EQUAL( p->mgtFrame().bssid()[0], 0x00 ); - BOOST_CHECK_EQUAL( p->mgtFrame().bssid()[3], 0x3e ); - BOOST_CHECK_EQUAL( p->mgtFrame().bssid()[5], 0x5c ); - + BOOST_CHECK_EQUAL( p->version(), 0u ); + BOOST_CHECK_EQUAL( p->type(), 0u ); + BOOST_CHECK_EQUAL( p->subtype(), 8u ); + BOOST_CHECK_EQUAL( p->toDS(), false ); + BOOST_CHECK_EQUAL( p->fromDS(), false ); + BOOST_CHECK_EQUAL( p->moreFrag(), false ); + BOOST_CHECK_EQUAL( p->retry(), false ); + BOOST_CHECK_EQUAL( p->pwrMgt(), false ); + BOOST_CHECK_EQUAL( p->moreData(), false ); + BOOST_CHECK_EQUAL( p->protectedFrame(), false ); + BOOST_CHECK_EQUAL( p->order(), false ); + BOOST_CHECK_EQUAL( p->duration(), 0u ); + + BOOST_CHECK_EQUAL( p->has_mgtFrame(), true ); + + BOOST_CHECK_EQUAL( + p->mgtFrame().destinationAddress().value(), + senf::MACAddress::from_string("ff:ff:ff:ff:ff:ff") ); + BOOST_CHECK_EQUAL( + p->mgtFrame().sourceAddress().value(), + senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); + BOOST_CHECK_EQUAL( + p->mgtFrame().bssid().value(), + senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); + BOOST_CHECK_EQUAL( p->mgtFrame().sequenceNumber(), 302u ); - BOOST_CHECK_EQUAL( p->mgtFrame().fragmentNumber(), 0u ); - - - BOOST_CHECK_EQUAL ( p->fcs(), 0x87071ff5); + BOOST_CHECK_EQUAL( p->mgtFrame().fragmentNumber(), 0u ); + BOOST_CHECK_EQUAL( p->fcs(), 0x87071ff5 ); } + /* test parser with creating a beacon frame*/ BOOST_AUTO_UNIT_TEST(WLANPacket_mgtFrame_create) { senf::WLANPacket p (senf::WLANPacket::create()); - SENF_CHECK_NO_THROW(p->init_mgtFrame()); + SENF_CHECK_NO_THROW( p->init_mgtFrame() ); SENF_CHECK_NO_THROW( - p->mgtFrame().da()=senf::MACAddress::from_string("ff:ff:ff:ff:ff:ff") + p->mgtFrame().destinationAddress() = senf::MACAddress::from_string("ff:ff:ff:ff:ff:ff") ); SENF_CHECK_NO_THROW( - p->mgtFrame().sa()=senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") + p->mgtFrame().sourceAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); SENF_CHECK_NO_THROW( - p->mgtFrame().bssid()=senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") + p->mgtFrame().bssid() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); - BOOST_CHECK_EQUAL( p->type(), 0u); + BOOST_CHECK_EQUAL( p->type(), 0u ); } + /* test parser with an ACK frame*/ BOOST_AUTO_UNIT_TEST(WLANPacket_ctrlFrame_packet) { - - - unsigned char data[] = {0xd4, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x6b, 0x57, - 0x06, 0xb0, 0x4f, 0xda}; + unsigned char data[] = { + 0xd4, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x6b, 0x57, + 0x06, 0xb0, 0x4f, 0xda + }; senf::WLANPacket p (senf::WLANPacket::create(data)); - BOOST_CHECK_EQUAL( p->version(), 0u); - BOOST_CHECK_EQUAL( p->type(), 1u); - BOOST_CHECK_EQUAL( p->subtype(), 13u); - BOOST_CHECK_EQUAL( p->toDS(), false); - BOOST_CHECK_EQUAL( p->fromDS(), false); - BOOST_CHECK_EQUAL( p->moreFrag(), false); - BOOST_CHECK_EQUAL( p->retry(), false); - BOOST_CHECK_EQUAL( p->pwrMgt(), false); - BOOST_CHECK_EQUAL( p->moreData(), false); - BOOST_CHECK_EQUAL( p->protectedFrame(), false); - BOOST_CHECK_EQUAL( p->order(), false); - - BOOST_CHECK_EQUAL( p->duration(), 0u); - - BOOST_CHECK_EQUAL (p->ctrlFrame().ra()[0], 0x00); - BOOST_CHECK_EQUAL (p->ctrlFrame().ra()[3], 0x57); - BOOST_CHECK_EQUAL (p->ctrlFrame().ra()[5], 0xb0); + BOOST_CHECK_EQUAL( p->version(), 0u ); + BOOST_CHECK_EQUAL( p->type(), 1u ); + BOOST_CHECK_EQUAL( p->subtype(), 13u ); + BOOST_CHECK_EQUAL( p->toDS(), false ); + BOOST_CHECK_EQUAL( p->fromDS(), false ); + BOOST_CHECK_EQUAL( p->moreFrag(), false ); + BOOST_CHECK_EQUAL( p->retry(), false ); + BOOST_CHECK_EQUAL( p->pwrMgt(), false ); + BOOST_CHECK_EQUAL( p->moreData(), false ); + BOOST_CHECK_EQUAL( p->protectedFrame(), false ); + BOOST_CHECK_EQUAL( p->order(), false ); + + BOOST_CHECK_EQUAL( p->duration(), 0u ); + + BOOST_CHECK_EQUAL( + p->ctrlFrame().recieverAddress().value(), + senf::MACAddress::from_string("00:0b:6b:57:06:b0") ); } + /* test parser with creating an ACK frame*/ BOOST_AUTO_UNIT_TEST(WLANPacket_ctrlFrame_create) { @@ -220,7 +205,7 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_ctrlFrame_create) // std::cout << unsigned( senf::init_bytes::value ) << "\n"; SENF_CHECK_NO_THROW(p->init_ctrlFrame()); // std::cout << unsigned( senf::init_bytes::value ) << "\n"; - p->ctrlFrame().ra()=senf::MACAddress::from_string("00:1a:4d:3e:c7:5c"); + p->ctrlFrame().recieverAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c"); p->ctrlFrame().set_ack(); BOOST_CHECK_EQUAL( p->type(), 1u); BOOST_CHECK_EQUAL( p->subtype(), 13u); diff --git a/Socket/Protocols/Raw/MACAddress.test.cc b/Socket/Protocols/Raw/MACAddress.test.cc index 29a3617..a678df6 100644 --- a/Socket/Protocols/Raw/MACAddress.test.cc +++ b/Socket/Protocols/Raw/MACAddress.test.cc @@ -39,7 +39,7 @@ BOOST_AUTO_UNIT_TEST(macAddress) { - std::string test ("A1-b2-C3:d4:E5:f6"); + std::string test ("A1-b2-C3:d4:E5:f6"); senf::MACAddress mac (senf::MACAddress::from_string(test)); BOOST_CHECK_EQUAL( mac[0], 0xA1u ); diff --git a/Socket/Protocols/Raw/TunTapSocketHandle.hh b/Socket/Protocols/Raw/TunTapSocketHandle.hh index 4301a0f..fb5f95f 100644 --- a/Socket/Protocols/Raw/TunTapSocketHandle.hh +++ b/Socket/Protocols/Raw/TunTapSocketHandle.hh @@ -121,7 +121,7 @@ namespace senf { std::string ifaceName() const; ///< returns the actual name of the correspondent tap interface private: - mutable unsigned int ifaceIndex_; + mutable unsigned int ifaceIndex_; ///@} };