ofdm_mac: add parameter to strip MAC header from incoming MPDUs
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<key>ieee802_11_ofdm_mac</key>
|
<key>ieee802_11_ofdm_mac</key>
|
||||||
<category>IEEE802.11</category>
|
<category>IEEE802.11</category>
|
||||||
<import>import ieee802_11</import>
|
<import>import ieee802_11</import>
|
||||||
<make>ieee802_11.ofdm_mac($src_mac, $dst_mac, $bss_mac)</make>
|
<make>ieee802_11.ofdm_mac($src_mac, $dst_mac, $bss_mac, $strip_header)</make>
|
||||||
|
|
||||||
<param>
|
<param>
|
||||||
<name>SRC MAC</name>
|
<name>SRC MAC</name>
|
||||||
@@ -28,6 +28,22 @@
|
|||||||
<type>int_vector</type>
|
<type>int_vector</type>
|
||||||
</param>
|
</param>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Strip header</name>
|
||||||
|
<key>strip_header</key>
|
||||||
|
<value>False</value>
|
||||||
|
<type>bool</type>
|
||||||
|
|
||||||
|
<option>
|
||||||
|
<name>Yes</name>
|
||||||
|
<key>True</key>
|
||||||
|
</option>
|
||||||
|
<option>
|
||||||
|
<name>No</name>
|
||||||
|
<key>False</key>
|
||||||
|
</option>
|
||||||
|
</param>
|
||||||
|
|
||||||
<check>len($src_mac) == 6</check>
|
<check>len($src_mac) == 6</check>
|
||||||
<check>len($dst_mac) == 6</check>
|
<check>len($dst_mac) == 6</check>
|
||||||
<check>len($bss_mac) == 6</check>
|
<check>len($bss_mac) == 6</check>
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ public:
|
|||||||
typedef boost::shared_ptr<ofdm_mac> sptr;
|
typedef boost::shared_ptr<ofdm_mac> sptr;
|
||||||
static sptr make(std::vector<uint8_t> src_mac,
|
static sptr make(std::vector<uint8_t> src_mac,
|
||||||
std::vector<uint8_t> dst_mac,
|
std::vector<uint8_t> dst_mac,
|
||||||
std::vector<uint8_t> bss_mac);
|
std::vector<uint8_t> bss_mac,
|
||||||
|
bool strip_header);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ieee802_11
|
} // namespace ieee802_11
|
||||||
|
|||||||
+19
-4
@@ -38,11 +38,12 @@ class ofdm_mac_impl : public ofdm_mac {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ofdm_mac_impl(std::vector<uint8_t> src_mac, std::vector<uint8_t> dst_mac, std::vector<uint8_t> bss_mac) :
|
ofdm_mac_impl(std::vector<uint8_t> src_mac, std::vector<uint8_t> dst_mac, std::vector<uint8_t> bss_mac, bool strip_header) :
|
||||||
block("ofdm_mac",
|
block("ofdm_mac",
|
||||||
gr::io_signature::make(0, 0, 0),
|
gr::io_signature::make(0, 0, 0),
|
||||||
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("phy out"));
|
||||||
message_port_register_out(pmt::mp("app out"));
|
message_port_register_out(pmt::mp("app out"));
|
||||||
@@ -65,6 +66,19 @@ ofdm_mac_impl(std::vector<uint8_t> src_mac, std::vector<uint8_t> dst_mac, std::v
|
|||||||
}
|
}
|
||||||
|
|
||||||
void phy_in (pmt::pmt_t msg) {
|
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<const char *>(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);
|
message_port_pub(pmt::mp("app out"), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,10 +175,11 @@ private:
|
|||||||
uint8_t d_src_mac[6];
|
uint8_t d_src_mac[6];
|
||||||
uint8_t d_dst_mac[6];
|
uint8_t d_dst_mac[6];
|
||||||
uint8_t d_bss_mac[6];
|
uint8_t d_bss_mac[6];
|
||||||
|
bool d_strip_header;
|
||||||
};
|
};
|
||||||
|
|
||||||
ofdm_mac::sptr
|
ofdm_mac::sptr
|
||||||
ofdm_mac::make(std::vector<uint8_t> src_mac, std::vector<uint8_t> dst_mac, std::vector<uint8_t> bss_mac) {
|
ofdm_mac::make(std::vector<uint8_t> src_mac, std::vector<uint8_t> dst_mac, std::vector<uint8_t> bss_mac, bool strip_header) {
|
||||||
return gnuradio::get_initial_sptr(new ofdm_mac_impl(src_mac, dst_mac, bss_mac));
|
return gnuradio::get_initial_sptr(new ofdm_mac_impl(src_mac, dst_mac, bss_mac, strip_header));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user