Packets/80211Bundle: fixed endian-bug in Radiotap offset calculation
tho [Wed, 9 Nov 2011 16:13:40 +0000 (16:13 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1824 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/80211Bundle/RadiotapPacket.cc
senf/Packets/80211Bundle/RadiotapPacket.test.cc

index 5f51504..8f02f2c 100644 (file)
@@ -95,7 +95,8 @@ prefix_ void senf::RadiotapPacketParser::buildOffsetTable(boost::uint32_t presen
     // radiotap.c nor we will ever dereference those pointers, we just calculate the offsets.
     // This works, as long as we don't support extension headers ...
     header.it_len = 0xFFFF;
-    header.it_present = presentFlags;
+    // Note that all data in the header is little endian!
+    header.it_present = htole32(presentFlags);
 
     parseOffsetTable((boost::uint8_t*)&header, header.it_len, table);
 }
index 70c5128..bbf3c75 100644 (file)
@@ -137,6 +137,8 @@ SENF_AUTO_UNIT_TEST(RadiotapPacket_create)
     BOOST_CHECK_EQUAL( p.size(), senf::RadiotapPacketParser_Header::fixed_bytes+0 );
 
     SENF_CHECK_NO_THROW( p->init_tsft()             = 81059833346uLL );
+    BOOST_CHECK_EQUAL( p.size(), senf::RadiotapPacketParser_Header::fixed_bytes +
+            senf::RadiotapPacketParser::tsft_t::fixed_bytes );
     SENF_CHECK_NO_THROW( p->init_rate()             =          12u   );
     SENF_CHECK_NO_THROW( p->init_dbmAntennaSignal() =         -61    );
     SENF_CHECK_NO_THROW( p->init_dbmAntennaNoise()  =         -96    );