From: tho Date: Fri, 9 Oct 2009 11:39:04 +0000 (+0000) Subject: Packets/80211Bundle: added SSID-IE to BeaconPacket X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=2571369f6d1701b241a56a78c6a3d6d7569799c7;p=senf.git Packets/80211Bundle: added SSID-IE to BeaconPacket git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1487 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/80211Bundle/InformationElements.hh b/senf/Packets/80211Bundle/InformationElements.hh index 0b550f4..21911d5 100644 --- a/senf/Packets/80211Bundle/InformationElements.hh +++ b/senf/Packets/80211Bundle/InformationElements.hh @@ -45,6 +45,21 @@ namespace senf { typedef GenericTLVParserBase WLANGenericInfoElementParser; + struct WLANSSIDInfoElementParser + : public WLANInfoElementParser + { + # include SENF_PARSER() + SENF_PARSER_INHERIT ( WLANInfoElementParser ); + // the StringParser includes the length field so we have to go back + SENF_PARSER_GOTO ( length ); + SENF_PARSER_FIELD ( value, StringParser ); + SENF_PARSER_FINALIZE ( WLANSSIDInfoElementParser ); + + SENF_PARSER_INIT() { + type() = TYPEID; + } + static const type_t::value_type TYPEID = 0x00u; + }; } ///////////////////////////////hh.e//////////////////////////////////////// diff --git a/senf/Packets/80211Bundle/WLANBeaconPacket.hh b/senf/Packets/80211Bundle/WLANBeaconPacket.hh index fcfe80d..3451770 100644 --- a/senf/Packets/80211Bundle/WLANBeaconPacket.hh +++ b/senf/Packets/80211Bundle/WLANBeaconPacket.hh @@ -38,12 +38,12 @@ namespace senf { { # include SENF_PARSER() - SENF_PARSER_FIELD( timestamp, UInt64LSBParser ); - SENF_PARSER_FIELD( beaconInterval, UInt16LSBParser ); - SENF_PARSER_SKIP(2,2); //capability flags + SENF_PARSER_FIELD( timestamp, UInt64LSBParser ); + SENF_PARSER_FIELD( beaconInterval, UInt16LSBParser ); + SENF_PARSER_SKIP ( 2,2); //capability flags - //SSID element -// SENF_PARSER_FIELD() + SENF_PARSER_FIELD( ssidIE, WLANSSIDInfoElementParser ); + WLANSSIDInfoElementParser::value_t ssid() const { return ssidIE().value(); } SENF_PARSER_FINALIZE( WLANBeaconPacketParser ); @@ -60,16 +60,16 @@ namespace senf { \ingroup protocolbundle_80211 */ struct WLANBeaconPacketType - : public senf::PacketTypeBase, - public senf::PacketTypeMixin + : public PacketTypeBase, + public PacketTypeMixin { - typedef senf::PacketTypeMixin mixin; - typedef senf::ConcretePacket packet; + typedef PacketTypeMixin mixin; + typedef ConcretePacket packet; typedef WLANBeaconPacketParser parser; using mixin::init; using mixin::initSize; - using senf::PacketTypeBase::nextPacketRange; + using PacketTypeBase::nextPacketRange; static void dump(packet p, std::ostream &os); }; diff --git a/senf/Packets/80211Bundle/WLANBeaconPacket.test.cc b/senf/Packets/80211Bundle/WLANBeaconPacket.test.cc index a05ed9b..41eb81d 100644 --- a/senf/Packets/80211Bundle/WLANBeaconPacket.test.cc +++ b/senf/Packets/80211Bundle/WLANBeaconPacket.test.cc @@ -32,7 +32,7 @@ ///////////////////////////////cc.p//////////////////////////////////////// -BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_packet) +BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_parse) { unsigned char data[] = { 0x3a, 0x30, 0xaa, 0x4c, 0x9c, 0x00, 0x00, 0x00, //timestamp @@ -55,7 +55,27 @@ BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_packet) BOOST_CHECK_EQUAL( p->timestamp(), 0x0000009C4CAA303AuLL); BOOST_CHECK_EQUAL( p->beaconInterval(), 100u); + BOOST_CHECK_EQUAL( p->ssidIE().length(), 5); + BOOST_CHECK_EQUAL( p->ssidIE().value().value(), "boxC1"); + BOOST_CHECK_EQUAL( p->ssid().value(), "boxC1"); +} +BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_create) +{ + senf::WLANBeaconPacket p (senf::WLANBeaconPacket::create()); + p->timestamp() << 0x0000009C4CAA303AuLL; + p->beaconInterval() << 100u; + p->ssidIE().value() << "boxC1"; + p.finalizeThis(); + + unsigned char data[] = { + 0x3a, 0x30, 0xaa, 0x4c, 0x9c, 0x00, 0x00, 0x00, //timestamp + 0x64, 0x00, //beacon interval + 0x00, 0x00, //capability information + 0x00, 0x05, 0x62, 0x6f, 0x78, 0x43, 0x31 //SSID + }; + SENF_CHECK_EQUAL_COLLECTIONS( p.data().begin(), p.data().end(), + data, data+sizeof(data) ); } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/senf/Packets/StringParser.cti b/senf/Packets/StringParser.cti index 36b3075..11c50ee 100644 --- a/senf/Packets/StringParser.cti +++ b/senf/Packets/StringParser.cti @@ -55,7 +55,7 @@ prefix_ void senf::StringParser::value(value_type v) { validate(bytes()); resize(bytes(), v.size()+senf::bytes(length())); - parse(0) = v.size(); + length() << v.size(); std::copy(v.begin(), v.end(), i()+senf::bytes(length())); }