mac: always remove header
This commit is contained in:
+13
-17
@@ -38,12 +38,11 @@ class ofdm_mac_impl : public ofdm_mac {
|
||||
|
||||
public:
|
||||
|
||||
ofdm_mac_impl(std::vector<uint8_t> src_mac, std::vector<uint8_t> dst_mac, std::vector<uint8_t> bss_mac, bool strip_header) :
|
||||
ofdm_mac_impl(std::vector<uint8_t> src_mac, std::vector<uint8_t> dst_mac, std::vector<uint8_t> bss_mac) :
|
||||
block("ofdm_mac",
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(0, 0, 0)),
|
||||
d_seq_nr(0),
|
||||
d_strip_header(strip_header) {
|
||||
d_seq_nr(0) {
|
||||
|
||||
message_port_register_out(pmt::mp("phy out"));
|
||||
message_port_register_out(pmt::mp("app out"));
|
||||
@@ -66,19 +65,17 @@ ofdm_mac_impl(std::vector<uint8_t> src_mac, std::vector<uint8_t> 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");
|
||||
// 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);
|
||||
// strip MAC header and CRC
|
||||
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 - 4);
|
||||
|
||||
// update original msg, note that the fcs is still there
|
||||
pmt::set_cdr(msg, msdu);
|
||||
}
|
||||
// update msg
|
||||
pmt::set_cdr(msg, msdu);
|
||||
message_port_pub(pmt::mp("app out"), msg);
|
||||
}
|
||||
|
||||
@@ -175,11 +172,10 @@ 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<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, strip_header));
|
||||
ofdm_mac::make(std::vector<uint8_t> src_mac, std::vector<uint8_t> dst_mac, std::vector<uint8_t> bss_mac) {
|
||||
return gnuradio::get_initial_sptr(new ofdm_mac_impl(src_mac, dst_mac, bss_mac));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user