diff --git a/grc/ieee802_11_ofdm_mac.xml b/grc/ieee802_11_ofdm_mac.xml index 4d6e48a..9bca984 100644 --- a/grc/ieee802_11_ofdm_mac.xml +++ b/grc/ieee802_11_ofdm_mac.xml @@ -5,7 +5,7 @@ ieee802_11_ofdm_mac IEEE802.11 import ieee802_11 - ieee802_11.ofdm_mac($src_mac, $dst_mac, $bss_mac) + ieee802_11.ofdm_mac($src_mac, $dst_mac, $bss_mac, $strip_header) SRC MAC @@ -28,6 +28,22 @@ int_vector + + Strip header + strip_header + False + bool + + + + + len($src_mac) == 6 len($dst_mac) == 6 len($bss_mac) == 6 diff --git a/include/ieee802-11/ofdm_mac.h b/include/ieee802-11/ofdm_mac.h index 599b91d..ea270b9 100644 --- a/include/ieee802-11/ofdm_mac.h +++ b/include/ieee802-11/ofdm_mac.h @@ -30,7 +30,8 @@ public: typedef boost::shared_ptr sptr; static sptr make(std::vector src_mac, std::vector dst_mac, - std::vector bss_mac); + std::vector bss_mac, + bool strip_header); }; } // namespace ieee802_11 diff --git a/lib/ether_encap_impl.cc b/lib/ether_encap_impl.cc index 86bebc0..aaea027 100644 --- a/lib/ether_encap_impl.cc +++ b/lib/ether_encap_impl.cc @@ -60,7 +60,7 @@ ether_encap_impl::from_wifi(pmt::pmt_t msg) { return; } - // this is more than neeed + // this is more than needed char *buf = static_cast(std::malloc(data_len + sizeof(ethernet_header))); ethernet_header *ehdr = reinterpret_cast(buf); diff --git a/lib/ofdm_decode_mac.cc b/lib/ofdm_decode_mac.cc index 22fb428..b1e750f 100644 --- a/lib/ofdm_decode_mac.cc +++ b/lib/ofdm_decode_mac.cc @@ -309,9 +309,9 @@ private: char out_bits[40000]; char out_bytes[40000]; bvec decoded_bits; - bool d_debug; - bool d_log; + bool d_debug; + bool d_log; tx_param tx; ofdm_param ofdm; int copied; diff --git a/lib/ofdm_mac.cc b/lib/ofdm_mac.cc index 6c95f0f..be90fc7 100644 --- a/lib/ofdm_mac.cc +++ b/lib/ofdm_mac.cc @@ -38,11 +38,12 @@ class ofdm_mac_impl : public ofdm_mac { public: -ofdm_mac_impl(std::vector src_mac, std::vector dst_mac, std::vector bss_mac) : +ofdm_mac_impl(std::vector src_mac, std::vector dst_mac, std::vector bss_mac, bool strip_header) : block("ofdm_mac", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), - d_seq_nr(0) { + d_seq_nr(0), + d_strip_header(strip_header) { message_port_register_out(pmt::mp("phy out")); message_port_register_out(pmt::mp("app out")); @@ -65,6 +66,19 @@ ofdm_mac_impl(std::vector src_mac, std::vector dst_mac, std::v } void phy_in (pmt::pmt_t msg) { + if (d_strip_header) { + // this must be a pair + if (!pmt::is_blob(pmt::cdr(msg))) + throw std::runtime_error("PMT must be blob"); + + // strip MAC header and only leave PHY blob + pmt::pmt_t blob(pmt::cdr(msg)); + const char *mpdu = reinterpret_cast(pmt::blob_data(blob)); + pmt::pmt_t msdu = pmt::make_blob(mpdu + 24, pmt::blob_length(blob) - 24); + + // update original msg, note that the fcs is still there + pmt::set_cdr(msg, msdu); + } message_port_pub(pmt::mp("app out"), msg); } @@ -161,10 +175,11 @@ private: uint8_t d_src_mac[6]; uint8_t d_dst_mac[6]; uint8_t d_bss_mac[6]; + bool d_strip_header; }; ofdm_mac::sptr -ofdm_mac::make(std::vector src_mac, std::vector dst_mac, std::vector bss_mac) { - return gnuradio::get_initial_sptr(new ofdm_mac_impl(src_mac, dst_mac, bss_mac)); +ofdm_mac::make(std::vector src_mac, std::vector dst_mac, std::vector bss_mac, bool strip_header) { + return gnuradio::get_initial_sptr(new ofdm_mac_impl(src_mac, dst_mac, bss_mac, strip_header)); }