return addr1();
}
+prefix_ senf::PacketInterpreterBase::factory_t senf::WLANPacketType::nextPacketType(packet p)
+{
+ if (p->is_dataFrame() && (p->subtype()==0 || p->subtype()==8)) //data frame and subtype is Data or QoS Data
+ return LlcSnapPacket::factory();
+ return no_factory();
+}
+
+prefix_ senf::PacketInterpreterBase::optional_range senf::WLANPacketType::nextPacketRange(packet p)
+{
+ if (p->is_dataFrame()) {
+ size_type sz = 24; //header length of wlan data frame (WDS is not considered)
+ if (p->subtype()==8) //subtype QoSData
+ sz+=2; //2 bytes for QoS field
+ return range(
+ boost::next(p.data().begin(),sz),
+ boost::prior(p.data().end(),4) ); //-4 bytes FCS
+ }
+ //TODO beacon frame payload
+ return no_range();
+}
prefix_ void senf::WLANPacketType::dump(packet p, std::ostream &os)
{
struct WLANPacket_MgtFrameParser : public senf::PacketParserBase
{
# include SENF_FIXED_PARSER()
-
+
SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned ); //<pkgdraw: hide
//skip type and version
SENF_PARSER_SKIP_BITS ( 4 ); //<pkgdraw: hide
struct WLANPacket_CtrlFrameParser : public senf::PacketParserBase
{
# include SENF_PARSER()
-
+
SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned ); //<pkgdraw: hide
//skip type and version
SENF_PARSER_SKIP_BITS ( 4 ); //<pkgdraw: hide
typedef senf::ConcretePacket<WLANPacketType> packet;
typedef WLANPacketParser parser;
-// using mixin::nextPacketRange;
+
using mixin::init;
using mixin::initSize;
- using senf::PacketTypeBase::nextPacketRange;;
+// using senf::PacketTypeBase::nextPacketRange;
+ static optional_range nextPacketRange(packet p);
+ static factory_t nextPacketType(packet p);
static void dump(packet p, std::ostream &os);
// static PacketParserBase::size_type initSize();
// Custom includes
#include "WLANPacket.hh"
#include "../../Packets/Packets.hh"
+#include "../DefaultBundle/LlcSnapPacket.hh"
#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
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
+ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, //llc header
0x38, 0x39, 0x30, 0x31 //trailer
};
+
senf::WLANPacket p (senf::WLANPacket::create(data));
BOOST_CHECK_EQUAL( p->version(), 0u );
std::ostringstream oss (std::ostringstream::out);
SENF_CHECK_NO_THROW( p.dump( oss));
+
+ BOOST_CHECK( p.next());
+ BOOST_CHECK( p.next().is<senf::LlcSnapPacket>() );
}