From: g0dil Date: Wed, 1 Dec 2010 19:30:37 +0000 (+0000) Subject: BUG #17752: Fix RadiotapPacket parser X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=9b2b809a695e148c041415c6ff20325e77531a7d;p=senf.git BUG #17752: Fix RadiotapPacket parser correctly parse packets with additional padding after the ordinary radiotap header. git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1753 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/80211Bundle/RadiotapPacket.cc b/senf/Packets/80211Bundle/RadiotapPacket.cc index 3d17391..d732aad 100644 --- a/senf/Packets/80211Bundle/RadiotapPacket.cc +++ b/senf/Packets/80211Bundle/RadiotapPacket.cc @@ -184,6 +184,7 @@ prefix_ void senf::RadiotapPacketParser::updatePresentFlags(boost::uint32_t flag cumulativeNewBytes += newBytes; b = newTable[index] + FIELD_SIZE[index]; } + length() += cumulativeNewBytes; presentFlags() = flags; currentTable_ = &newTable; } @@ -288,11 +289,9 @@ prefix_ void senf::RadiotapPacketType::dump(packet p, std::ostream &os) # undef FIELD } - -prefix_ void senf::RadiotapPacketType::finalize(packet p) +prefix_ void senf::RadiotapPacketType::init(packet p) { - ///\fixme Is this really correct ? shouldn't I use nextPacket.begin() - begin() here ? - p->length() << p->calculateSize(); + p->length() << RadiotapPacketParser_Header::fixed_bytes; } prefix_ senf::PacketInterpreterBase::factory_t senf::RadiotapPacketType::nextPacketType(packet p) diff --git a/senf/Packets/80211Bundle/RadiotapPacket.cci b/senf/Packets/80211Bundle/RadiotapPacket.cci index 15ffad7..8351b62 100644 --- a/senf/Packets/80211Bundle/RadiotapPacket.cci +++ b/senf/Packets/80211Bundle/RadiotapPacket.cci @@ -45,7 +45,7 @@ prefix_ senf::RadiotapPacketParser::RadiotapPacketParser(data_iterator i, state_ prefix_ senf::RadiotapPacketParser::size_type senf::RadiotapPacketParser::bytes() const { - return calculateSize(); + return length(); } prefix_ senf::UInt32Parser senf::RadiotapPacketParser::fcs() diff --git a/senf/Packets/80211Bundle/RadiotapPacket.hh b/senf/Packets/80211Bundle/RadiotapPacket.hh index c6a0e72..69414e6 100644 --- a/senf/Packets/80211Bundle/RadiotapPacket.hh +++ b/senf/Packets/80211Bundle/RadiotapPacket.hh @@ -317,11 +317,10 @@ namespace senf { typedef ConcretePacket packet; typedef RadiotapPacketParser parser; - using mixin::init; using mixin::initSize; + static void init(packet p); static void dump(packet p, std::ostream &os); - static void finalize(packet p); static factory_t nextPacketType(packet p); static optional_range nextPacketRange(packet p); }; diff --git a/senf/Packets/80211Bundle/RadiotapPacket.test.cc b/senf/Packets/80211Bundle/RadiotapPacket.test.cc index 654fb10..e05f3e8 100644 --- a/senf/Packets/80211Bundle/RadiotapPacket.test.cc +++ b/senf/Packets/80211Bundle/RadiotapPacket.test.cc @@ -244,6 +244,76 @@ SENF_AUTO_UNIT_TEST(RadiotapPacket_packet_ath9k) BOOST_CHECK_EQUAL( p->antenna(), 0u); } +SENF_AUTO_UNIT_TEST(RadiotapPacket_parsetest) +{ + unsigned char data[] = { + '\x00', '\x00', '\x20', '\x00', '\x2f', '\x48', '\x00', '\x00', + '\xbe', '\xa5', '\xaf', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x10', '\x04', '\x6c', '\x09', '\xa0', '\x00', '\xb6', '\x01', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x80', '\x00', '\x00', '\x00', '\xff', '\xff', '\xff', '\xff', + '\xff', '\xff', '\x00', '\x0b', '\x0e', '\x26', '\xab', '\xc0', + '\x00', '\x0b', '\x0e', '\x26', '\xab', '\xc0', '\xe0', '\xec', + '\x81', '\x31', '\x0d', '\x1c', '\x72', '\x0a', '\x00', '\x00', + '\x64', '\x00', '\x31', '\x04', '\x00', '\x05', '\x46', '\x4f', + '\x4b', '\x55', '\x53', '\x01', '\x08', '\x82', '\x84', '\x8b', + '\x0c', '\x12', '\x96', '\x18', '\x24', '\x03', '\x01', '\x01', + '\x05', '\x04', '\x00', '\x01', '\x00', '\x00', '\x07', '\x06', + '\x44', '\x45', '\x20', '\x01', '\x0d', '\x12', '\x0b', '\x05', + '\x01', '\x00', '\x07', '\x00', '\x00', '\x43', '\x02', '\x00', + '\x00', '\x2a', '\x01', '\x00', '\x30', '\x14', '\x01', '\x00', + '\x00', '\x0f', '\xac', '\x04', '\x01', '\x00', '\x00', '\x0f', + '\xac', '\x04', '\x01', '\x00', '\x00', '\x0f', '\xac', '\x02', + '\x00', '\x00', '\x32', '\x04', '\x30', '\x48', '\x60', '\x6c', + '\xdd', '\x05', '\x00', '\x0b', '\x0e', '\x04', '\x00', '\xdd', + '\x22', '\x00', '\x0b', '\x0e', '\x02', '\x00', '\x00', '\x00', + '\x00', '\x12', '\x0c', '\x02', '\xa1', '\x04', '\xa2', '\x0b', + '\xa3', '\x0c', '\xa5', '\x12', '\xa6', '\x16', '\xa6', '\x18', + '\xa7', '\x24', '\xa8', '\x30', '\xab', '\x48', '\xae', '\x60', + '\xb5', '\x6c', '\xb8', '\xdd', '\x2e', '\x00', '\x0b', '\x0e', + '\x03', '\x00', '\xad', '\x67', '\x20', '\xc2', '\xc2', '\x14', + '\x0e', '\x36', '\xde', '\x3f', '\xbb', '\x2e', '\x4e', '\x02', + '\x70', '\x8a', '\x5b', '\x66', '\x59', '\x3c', '\xdb', '\xbb', + '\xc9', '\x65', '\x16', '\x99', '\x16', '\x84', '\x43', '\xaa', + '\x00', '\xa2', '\x45', '\xbc', '\xbc', '\x58', '\x9b', '\xd4', + '\x3e', '\xef', '\xca', '\xdd', '\x07', '\x00', '\x50', '\xf2', + '\x02', '\x00', '\x01', '\x01', '\xdd', '\x18', '\x00', '\x50', + '\xf2', '\x02', '\x01', '\x01', '\x01', '\x00', '\x03', '\xa4', + '\x00', '\x00', '\x27', '\xa4', '\x00', '\x00', '\x42', '\x43', + '\x5e', '\x00', '\x62', '\x32', '\x2f', '\x00', '\x0e', '\x58', + '\xcd', '\xa0' + }; + senf::RadiotapPacket p (senf::RadiotapPacket::create(data)); + + std::stringstream ss; + p.dump(ss); + + BOOST_CHECK_EQUAL(ss.str(), + "Radiotap:\n" + " version : 0\n" + " length : 32\n" + " MAC timestamp : 11511230\n" + " flags : FCSatEnd \n" + " rate : 4\n" + " channel frequency : 2412\n" + " channel flags : 2GHz CCK \n" + " antenna signal (dBm) : -74\n" + " antenna : 1\n" + " rx flags : \n" + " fcs : 240700832\n" + "802.11 MAC Mangement Frame:\n" + " version : 0\n" + " type : 0\n" + " subtype : 8\n" + " flags : none\n" + " duration : 0\n" + " destination : ff:ff:ff:ff:ff:ff\n" + " source : 00:0b:0e:26:ab:c0\n" + " bss id : 00:0b:0e:26:ab:c0\n" + " sequence number : 3790\n" + " fragment number : 0\n"); +} + // Local Variables: