typedef GenericTLVParserBase<WLANInfoElementParser> 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<UInt8Parser> );
+ SENF_PARSER_FINALIZE ( WLANSSIDInfoElementParser );
+
+ SENF_PARSER_INIT() {
+ type() = TYPEID;
+ }
+ static const type_t::value_type TYPEID = 0x00u;
+ };
}
///////////////////////////////hh.e////////////////////////////////////////
{
# 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 );
\ingroup protocolbundle_80211
*/
struct WLANBeaconPacketType
- : public senf::PacketTypeBase,
- public senf::PacketTypeMixin<WLANBeaconPacketType>
+ : public PacketTypeBase,
+ public PacketTypeMixin<WLANBeaconPacketType>
{
- typedef senf::PacketTypeMixin<WLANBeaconPacketType> mixin;
- typedef senf::ConcretePacket<WLANBeaconPacketType> packet;
+ typedef PacketTypeMixin<WLANBeaconPacketType> mixin;
+ typedef ConcretePacket<WLANBeaconPacketType> 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);
};
///////////////////////////////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
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////////////////////////////////////////
{
validate(bytes());
resize(bytes(), v.size()+senf::bytes(length()));
- parse<UInt16Parser>(0) = v.size();
+ length() << v.size();
std::copy(v.begin(), v.end(), i()+senf::bytes(length()));
}