From: tho Date: Tue, 9 Dec 2008 14:12:44 +0000 (+0000) Subject: WLANPacket: some more renaming X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=148834587eec2d0fcc0b87a7b3fa50644161aa1c;p=senf.git WLANPacket: some more renaming git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1008 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/80211Bundle/WLANPacket.cc b/Packets/80211Bundle/WLANPacket.cc index 33a2809..c4c6512 100644 --- a/Packets/80211Bundle/WLANPacket.cc +++ b/Packets/80211Bundle/WLANPacket.cc @@ -30,26 +30,18 @@ #define prefix_ -prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::da() +prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::destinationAddress() const { - switch (dsBits()) - { + switch (dsBits()) { case 0 : case 2 : return addr1(); - break; - case 1 : - case 3 : - return addr3(); - break; } - //just to avoid compiler warning - //TODO - return addr1(); + return addr3(); } -prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::sa() +prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::sourceAddress() const { switch (dsBits()) @@ -114,19 +106,33 @@ prefix_ boost::uint16_t senf::WLANPacket_DataFrameParser::sequenceNumber() prefix_ void senf::WLANPacketType::dump(packet p, std::ostream &os) { boost::io::ios_all_saver ias(os); - os << "802.11 MAC Frame:\n" - << " Type : " << unsigned (p->type()) << "\n" - << " Subtype : " << unsigned (p->subtype()) << "\n" - << " Retransmission : " << unsigned (p->retry()) << "\n" - << " Duration : " << unsigned (p->duration()) << "\n"; - - if (p->has_mgtFrame()) - { - os << " BSSID : " << p->mgtFrame().bssid() << "\n"; - os << " Destination Address : " << p->mgtFrame().destinationAddress() << "\n"; - os << " Source Address : " << p->mgtFrame().sourceAddress() << "\n"; + os << "802.11 MAC Frame:\n" + << " Type : " << unsigned( p->type()) << "\n" + << " Subtype : " << unsigned( p->subtype()) << "\n" + << " Retransmission : " << unsigned( p->retry()) << "\n" + << " Duration : " << unsigned( p->duration()) << "\n"; + if (p->is_mgtFrame()) { + os << " Management-Frame:\n" + << " BSSID : " << p->mgtFrame().bssid() << "\n" + << " Destination Address : " << p->mgtFrame().destinationAddress() << "\n" + << " Source Address : " << p->mgtFrame().sourceAddress() << "\n" + << " Sequence Number : " << unsigned( p->mgtFrame().sequenceNumber()) << "\n" + << " Fragment Number : " << unsigned( p->mgtFrame().fragmentNumber()) << "\n"; + } + if (p->is_ctrlFrame()) { + os << " Control-Frame "; + if (p->ctrlFrame().is_cts()) os << "(CTS):\n"; + if (p->ctrlFrame().is_ack()) os << "(ACK):\n"; + if (p->ctrlFrame().is_rts()) os << "(RTS):\n"; + os << " Receiver Address : " << p->ctrlFrame().receiverAddress() << "\n"; + if (p->ctrlFrame().is_rts()) + os << " Source Address : " << p->ctrlFrame().sourceAddress() << "\n"; + } + if (p->is_dataFrame()) { + os << " Data-Frame:\n" + << " Sequence Number : " << unsigned( p->mgtFrame().sequenceNumber()) << "\n" + << " Fragment Number : " << unsigned( p->mgtFrame().fragmentNumber()) << "\n"; } - }; diff --git a/Packets/80211Bundle/WLANPacket.hh b/Packets/80211Bundle/WLANPacket.hh index f7c5688..52c71b5 100644 --- a/Packets/80211Bundle/WLANPacket.hh +++ b/Packets/80211Bundle/WLANPacket.hh @@ -75,7 +75,7 @@ namespace senf SENF_PARSER_SKIP_BITS ( 4 ); //skip type and version //jump to fist address field SENF_PARSER_SKIP ( 3, 3 ); - SENF_PARSER_FIELD ( recieverAddress, MACAddressParser ); + SENF_PARSER_FIELD ( receiverAddress, MACAddressParser ); //only RTS frame contains a source address field //variant is also needed to set correct subtype value @@ -97,26 +97,26 @@ namespace senf struct WLANPacket_DataFrameParser : public senf::PacketParserBase { # include SENF_PARSER() - SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned); + SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned ); //jump to 'toDS' and 'fromDS' bits //skip type and version - SENF_PARSER_SKIP_BITS ( 4 ); + SENF_PARSER_SKIP_BITS ( 4 ); //skip other flags - SENF_PARSER_SKIP_BITS ( 6 ); + SENF_PARSER_SKIP_BITS ( 6 ); //needed in data frames due to the variable address fields - SENF_PARSER_PRIVATE_BITFIELD ( dsBits, 2, unsigned); + SENF_PARSER_PRIVATE_BITFIELD ( dsBits, 2, unsigned ); //skip duration field - SENF_PARSER_SKIP ( 2,0 ); + SENF_PARSER_SKIP ( 2, 0 ); - SENF_PARSER_PRIVATE_FIELD ( addr1, MACAddressParser ); - SENF_PARSER_PRIVATE_FIELD ( addr2, MACAddressParser ); - SENF_PARSER_PRIVATE_FIELD ( addr3, MACAddressParser ); + SENF_PARSER_PRIVATE_FIELD ( addr1, MACAddressParser ); + SENF_PARSER_PRIVATE_FIELD ( addr2, MACAddressParser ); + SENF_PARSER_PRIVATE_FIELD ( addr3, MACAddressParser ); //sequence Number and fragment number //shift bits manually due to LSB - 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 ); //TODO fourth address field in case of WDS // SENF_PARSER_PRIVATE_VARIANT (wds_, dsBits, @@ -124,14 +124,12 @@ namespace senf // ( id ( addr4, key (3, MACAddressParser ))) ); //QoS Filed - SENF_PARSER_VARIANT (qosField_, subtype, - ( ids (na, na, set_data, key(0, VoidPacketParser))) - ( ids (na, na, set_nullData, key(4, VoidPacketParser))) - ( ids (qosField, has_qosField, set_qosData, key(8, UInt16LSBParser))) + SENF_PARSER_VARIANT ( qosField_, subtype, + ( ids( na, na, set_data, key(0, VoidPacketParser)) ) + ( ids( na, na, set_nullData, key(4, VoidPacketParser)) ) + ( ids( qosField, has_qosField, set_qosData, key(8, UInt16LSBParser )) ) //we cannot parse qos Null (data) frames at the moment - ( ids (na, na, set_qosNullData, key(12, UInt16LSBParser))) ); - - + ( ids( na, na, set_qosNullData, key(12, UInt16LSBParser)) ) ); SENF_PARSER_FINALIZE(WLANPacket_DataFrameParser); @@ -140,10 +138,10 @@ namespace senf boost::uint16_t sequenceNumber() const; - MACAddressParser ra() const { return addr1(); }; //ra is always addr1 - MACAddressParser ta() const { return addr2(); }; //ta is always addr2 - MACAddressParser sa() const; - MACAddressParser da() const; + MACAddressParser receiverAddress() const { return addr1(); }; //ra is always addr1 + MACAddressParser transmitterAddress() const { return addr2(); }; //ta is always addr2 + MACAddressParser sourceAddress() const; + MACAddressParser destinationAddress() const; MACAddressParser bssid() const; }; @@ -173,14 +171,14 @@ namespace senf SENF_PARSER_BITFIELD ( fromDS, 1, bool ); SENF_PARSER_BITFIELD ( toDS, 1, bool ); - SENF_PARSER_FIELD (duration, UInt16LSBParser); + SENF_PARSER_FIELD ( duration, UInt16LSBParser ); - SENF_PARSER_GOTO( subtype ); //subparsers need to know the subtype - SENF_PARSER_VARIANT ( type__, type, - ( id( mgtFrame, WLANPacket_MgtFrameParser )) - ( id( ctrlFrame, WLANPacket_CtrlFrameParser )) - ( id( dataFrame, WLANPacket_DataFrameParser )) - ( novalue( reserved, WLANPacket_CtrlFrameParser )) ); + SENF_PARSER_GOTO( subtype ); // subparsers need to know the subtype + SENF_PARSER_VARIANT ( frameType_, type, + ( ids( mgtFrame, is_mgtFrame, init_mgtFrame, WLANPacket_MgtFrameParser )) + ( ids( ctrlFrame, is_ctrlFrame, init_ctrlFrame, WLANPacket_CtrlFrameParser )) + ( ids( dataFrame, is_dataFrame, init_dataFrame, WLANPacket_DataFrameParser )) + ( novalue( reserved, WLANPacket_CtrlFrameParser )) ); SENF_PARSER_CUSTOM_FIELD( fcs, senf::UInt32Parser, fcs_t::fixed_bytes, fcs_t::fixed_bytes) { return parse( data().size()-4 ); } @@ -197,6 +195,16 @@ namespace senf }; + /** \brief WLAN packet + + \par Packet type (typedef): + \ref WLANPacket + + \par Fields: + \ref WLANPacketParser + + \ingroup protocolbundle_80211 + */ struct WLANPacketType : public senf::PacketTypeBase, public senf::PacketTypeMixin diff --git a/Packets/80211Bundle/WLANPacket.test.cc b/Packets/80211Bundle/WLANPacket.test.cc index 9de635f..ed1c889 100644 --- a/Packets/80211Bundle/WLANPacket.test.cc +++ b/Packets/80211Bundle/WLANPacket.test.cc @@ -59,19 +59,21 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_dataFrame_packet) BOOST_CHECK_EQUAL( p->duration(), 0u ); BOOST_CHECK_EQUAL( - p->dataFrame().da().value(), + p->dataFrame().destinationAddress().value(), senf::MACAddress::from_string("00:18:4d:6e:78:48") ); BOOST_CHECK_EQUAL( - p->dataFrame().sa().value(), + p->dataFrame().sourceAddress().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() ); + p->dataFrame().bssid().value(), + p->dataFrame().receiverAddress().value() ); BOOST_CHECK_EQUAL( - p->dataFrame().ta().value(), p->dataFrame().sa().value() ); + p->dataFrame().transmitterAddress().value(), + p->dataFrame().sourceAddress().value() ); BOOST_CHECK_EQUAL( p->dataFrame().sequenceNumber(), 3u ); BOOST_CHECK_EQUAL( p->dataFrame().fragmentNumber(), 0u ); @@ -129,7 +131,7 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_beaconFrame_packet) BOOST_CHECK_EQUAL( p->order(), false ); BOOST_CHECK_EQUAL( p->duration(), 0u ); - BOOST_CHECK_EQUAL( p->has_mgtFrame(), true ); + BOOST_CHECK_EQUAL( p->is_mgtFrame(), true ); BOOST_CHECK_EQUAL( p->mgtFrame().destinationAddress().value(), @@ -193,7 +195,7 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_ctrlFrame_packet) BOOST_CHECK_EQUAL( p->duration(), 0u ); BOOST_CHECK_EQUAL( - p->ctrlFrame().recieverAddress().value(), + p->ctrlFrame().receiverAddress().value(), senf::MACAddress::from_string("00:0b:6b:57:06:b0") ); } @@ -205,7 +207,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().recieverAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c"); + p->ctrlFrame().receiverAddress() = 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);