#define prefix_
-prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::da()
+prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::destinationAddress()
const
{
- switch (dsBits())
- {
+ switch (dsBits()) {
case 0 :
case 2 :
return addr1();
- break;
- case 1 :
- case 3 :
- return addr3();
- break;
}
- //just to avoid compiler warning
- //TODO
- return addr1();
+ return addr3();
}
-prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::sa()
+prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::sourceAddress()
const
{
switch (dsBits())
prefix_ void senf::WLANPacketType::dump(packet p, std::ostream &os)
{
boost::io::ios_all_saver ias(os);
- os << "802.11 MAC Frame:\n"
- << " Type : " << unsigned (p->type()) << "\n"
- << " Subtype : " << unsigned (p->subtype()) << "\n"
- << " Retransmission : " << unsigned (p->retry()) << "\n"
- << " Duration : " << unsigned (p->duration()) << "\n";
-
- if (p->has_mgtFrame())
- {
- os << " BSSID : " << p->mgtFrame().bssid() << "\n";
- os << " Destination Address : " << p->mgtFrame().destinationAddress() << "\n";
- os << " Source Address : " << p->mgtFrame().sourceAddress() << "\n";
+ os << "802.11 MAC Frame:\n"
+ << " Type : " << unsigned( p->type()) << "\n"
+ << " Subtype : " << unsigned( p->subtype()) << "\n"
+ << " Retransmission : " << unsigned( p->retry()) << "\n"
+ << " Duration : " << unsigned( p->duration()) << "\n";
+ if (p->is_mgtFrame()) {
+ os << " Management-Frame:\n"
+ << " BSSID : " << p->mgtFrame().bssid() << "\n"
+ << " Destination Address : " << p->mgtFrame().destinationAddress() << "\n"
+ << " Source Address : " << p->mgtFrame().sourceAddress() << "\n"
+ << " Sequence Number : " << unsigned( p->mgtFrame().sequenceNumber()) << "\n"
+ << " Fragment Number : " << unsigned( p->mgtFrame().fragmentNumber()) << "\n";
+ }
+ if (p->is_ctrlFrame()) {
+ os << " Control-Frame ";
+ if (p->ctrlFrame().is_cts()) os << "(CTS):\n";
+ if (p->ctrlFrame().is_ack()) os << "(ACK):\n";
+ if (p->ctrlFrame().is_rts()) os << "(RTS):\n";
+ os << " Receiver Address : " << p->ctrlFrame().receiverAddress() << "\n";
+ if (p->ctrlFrame().is_rts())
+ os << " Source Address : " << p->ctrlFrame().sourceAddress() << "\n";
+ }
+ if (p->is_dataFrame()) {
+ os << " Data-Frame:\n"
+ << " Sequence Number : " << unsigned( p->mgtFrame().sequenceNumber()) << "\n"
+ << " Fragment Number : " << unsigned( p->mgtFrame().fragmentNumber()) << "\n";
}
-
};
SENF_PARSER_SKIP_BITS ( 4 ); //skip type and version
//jump to fist address field
SENF_PARSER_SKIP ( 3, 3 );
- SENF_PARSER_FIELD ( recieverAddress, MACAddressParser );
+ SENF_PARSER_FIELD ( receiverAddress, MACAddressParser );
//only RTS frame contains a source address field
//variant is also needed to set correct subtype value
struct WLANPacket_DataFrameParser : public senf::PacketParserBase
{
# include SENF_PARSER()
- SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned);
+ SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned );
//jump to 'toDS' and 'fromDS' bits
//skip type and version
- SENF_PARSER_SKIP_BITS ( 4 );
+ SENF_PARSER_SKIP_BITS ( 4 );
//skip other flags
- SENF_PARSER_SKIP_BITS ( 6 );
+ SENF_PARSER_SKIP_BITS ( 6 );
//needed in data frames due to the variable address fields
- SENF_PARSER_PRIVATE_BITFIELD ( dsBits, 2, unsigned);
+ SENF_PARSER_PRIVATE_BITFIELD ( dsBits, 2, unsigned );
//skip duration field
- SENF_PARSER_SKIP ( 2,0 );
+ SENF_PARSER_SKIP ( 2, 0 );
- SENF_PARSER_PRIVATE_FIELD ( addr1, MACAddressParser );
- SENF_PARSER_PRIVATE_FIELD ( addr2, MACAddressParser );
- SENF_PARSER_PRIVATE_FIELD ( addr3, MACAddressParser );
+ SENF_PARSER_PRIVATE_FIELD ( addr1, MACAddressParser );
+ SENF_PARSER_PRIVATE_FIELD ( addr2, MACAddressParser );
+ SENF_PARSER_PRIVATE_FIELD ( addr3, MACAddressParser );
//sequence Number and fragment number
//shift bits manually due to LSB
- SENF_PARSER_PRIVATE_BITFIELD (seqNumber_1, 4, unsigned);
- SENF_PARSER_BITFIELD (fragmentNumber, 4, unsigned);
- SENF_PARSER_PRIVATE_FIELD (seqNumber_2, UInt8Parser)
+ SENF_PARSER_PRIVATE_BITFIELD ( seqNumber_1, 4, unsigned );
+ SENF_PARSER_BITFIELD ( fragmentNumber, 4, unsigned );
+ SENF_PARSER_PRIVATE_FIELD ( seqNumber_2, UInt8Parser );
//TODO fourth address field in case of WDS
// SENF_PARSER_PRIVATE_VARIANT (wds_, dsBits,
// ( id ( addr4, key (3, MACAddressParser ))) );
//QoS Filed
- SENF_PARSER_VARIANT (qosField_, subtype,
- ( ids (na, na, set_data, key(0, VoidPacketParser)))
- ( ids (na, na, set_nullData, key(4, VoidPacketParser)))
- ( ids (qosField, has_qosField, set_qosData, key(8, UInt16LSBParser)))
+ SENF_PARSER_VARIANT ( qosField_, subtype,
+ ( ids( na, na, set_data, key(0, VoidPacketParser)) )
+ ( ids( na, na, set_nullData, key(4, VoidPacketParser)) )
+ ( ids( qosField, has_qosField, set_qosData, key(8, UInt16LSBParser )) )
//we cannot parse qos Null (data) frames at the moment
- ( ids (na, na, set_qosNullData, key(12, UInt16LSBParser))) );
-
-
+ ( ids( na, na, set_qosNullData, key(12, UInt16LSBParser)) ) );
SENF_PARSER_FINALIZE(WLANPacket_DataFrameParser);
boost::uint16_t sequenceNumber() const;
- MACAddressParser ra() const { return addr1(); }; //ra is always addr1
- MACAddressParser ta() const { return addr2(); }; //ta is always addr2
- MACAddressParser sa() const;
- MACAddressParser da() const;
+ MACAddressParser receiverAddress() const { return addr1(); }; //ra is always addr1
+ MACAddressParser transmitterAddress() const { return addr2(); }; //ta is always addr2
+ MACAddressParser sourceAddress() const;
+ MACAddressParser destinationAddress() const;
MACAddressParser bssid() const;
};
SENF_PARSER_BITFIELD ( fromDS, 1, bool );
SENF_PARSER_BITFIELD ( toDS, 1, bool );
- SENF_PARSER_FIELD (duration, UInt16LSBParser);
+ SENF_PARSER_FIELD ( duration, UInt16LSBParser );
- SENF_PARSER_GOTO( subtype ); //subparsers need to know the subtype
- SENF_PARSER_VARIANT ( type__, type,
- ( id( mgtFrame, WLANPacket_MgtFrameParser ))
- ( id( ctrlFrame, WLANPacket_CtrlFrameParser ))
- ( id( dataFrame, WLANPacket_DataFrameParser ))
- ( novalue( reserved, WLANPacket_CtrlFrameParser )) );
+ SENF_PARSER_GOTO( subtype ); // subparsers need to know the subtype
+ SENF_PARSER_VARIANT ( frameType_, type,
+ ( ids( mgtFrame, is_mgtFrame, init_mgtFrame, WLANPacket_MgtFrameParser ))
+ ( ids( ctrlFrame, is_ctrlFrame, init_ctrlFrame, WLANPacket_CtrlFrameParser ))
+ ( ids( dataFrame, is_dataFrame, init_dataFrame, WLANPacket_DataFrameParser ))
+ ( novalue( reserved, WLANPacket_CtrlFrameParser )) );
SENF_PARSER_CUSTOM_FIELD( fcs, senf::UInt32Parser, fcs_t::fixed_bytes, fcs_t::fixed_bytes) {
return parse<UInt32Parser>( data().size()-4 ); }
};
+ /** \brief WLAN packet
+
+ \par Packet type (typedef):
+ \ref WLANPacket
+
+ \par Fields:
+ \ref WLANPacketParser
+
+ \ingroup protocolbundle_80211
+ */
struct WLANPacketType
: public senf::PacketTypeBase,
public senf::PacketTypeMixin<WLANPacketType>
BOOST_CHECK_EQUAL( p->duration(), 0u );
BOOST_CHECK_EQUAL(
- p->dataFrame().da().value(),
+ p->dataFrame().destinationAddress().value(),
senf::MACAddress::from_string("00:18:4d:6e:78:48") );
BOOST_CHECK_EQUAL(
- p->dataFrame().sa().value(),
+ p->dataFrame().sourceAddress().value(),
senf::MACAddress::from_string("00:0b:6b:57:06:b0") );
BOOST_CHECK_EQUAL(
p->dataFrame().bssid().value(),
senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") );
BOOST_CHECK_EQUAL(
- p->dataFrame().bssid().value(), p->dataFrame().ra().value() );
+ p->dataFrame().bssid().value(),
+ p->dataFrame().receiverAddress().value() );
BOOST_CHECK_EQUAL(
- p->dataFrame().ta().value(), p->dataFrame().sa().value() );
+ p->dataFrame().transmitterAddress().value(),
+ p->dataFrame().sourceAddress().value() );
BOOST_CHECK_EQUAL( p->dataFrame().sequenceNumber(), 3u );
BOOST_CHECK_EQUAL( p->dataFrame().fragmentNumber(), 0u );
BOOST_CHECK_EQUAL( p->order(), false );
BOOST_CHECK_EQUAL( p->duration(), 0u );
- BOOST_CHECK_EQUAL( p->has_mgtFrame(), true );
+ BOOST_CHECK_EQUAL( p->is_mgtFrame(), true );
BOOST_CHECK_EQUAL(
p->mgtFrame().destinationAddress().value(),
BOOST_CHECK_EQUAL( p->duration(), 0u );
BOOST_CHECK_EQUAL(
- p->ctrlFrame().recieverAddress().value(),
+ p->ctrlFrame().receiverAddress().value(),
senf::MACAddress::from_string("00:0b:6b:57:06:b0") );
}
// std::cout << unsigned( senf::init_bytes<senf::WLANPacketParser_CtrlFrameParser>::value ) << "\n";
SENF_CHECK_NO_THROW(p->init_ctrlFrame());
// std::cout << unsigned( senf::init_bytes<senf::WLANPacketParser_CtrlFrameParser>::value ) << "\n";
- p->ctrlFrame().recieverAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c");
+ p->ctrlFrame().receiverAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c");
p->ctrlFrame().set_ack();
BOOST_CHECK_EQUAL( p->type(), 1u);
BOOST_CHECK_EQUAL( p->subtype(), 13u);