From 0a34f68565863218c3c010e69f6bd6a9bdfd7142 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Fri, 16 Aug 2024 22:55:05 -0400 Subject: [PATCH] wireshark: When using the ZIGBEE_TAP link type, fill the LQI TLV if the "lqi" pdu dict key is present --- lib/wireshark_connector_impl.cc | 18 ++++++++++++++++-- lib/wireshark_connector_impl.h | 9 +++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/wireshark_connector_impl.cc b/lib/wireshark_connector_impl.cc index 7cf9280..9d8f80c 100644 --- a/lib/wireshark_connector_impl.cc +++ b/lib/wireshark_connector_impl.cc @@ -148,7 +148,7 @@ wireshark_connector_impl::handle_pdu(pmt::pmt_t pdu) { case ZIGBEE_TAP:{ - const size_t max_extra_size = sizeof(tap_hdr) + sizeof(tap_tlv_fcs) + sizeof(tap_tlv_channel); + const size_t max_extra_size = sizeof(tap_hdr) + sizeof(tap_tlv_fcs) + sizeof(tap_tlv_channel) + sizeof(tap_tlv_lqi); size_t extra_size = sizeof(tap_hdr) + sizeof(tap_tlv_fcs); d_msg = reinterpret_cast(std::malloc(len + sizeof(pcap_hdr) + max_extra_size)); @@ -175,7 +175,6 @@ wireshark_connector_impl::handle_pdu(pmt::pmt_t pdu) { } offset += sizeof(tap_tlv_fcs); - pmt::pmt_t dict = pmt::car(pdu); if(pmt::dict_has_key(dict, pmt::mp("channel"))) { pmt::pmt_t s = pmt::dict_ref(dict, pmt::mp("channel"), pmt::PMT_NIL); @@ -191,6 +190,21 @@ wireshark_connector_impl::handle_pdu(pmt::pmt_t pdu) { } } + if(pmt::dict_has_key(dict, pmt::mp("lqi"))) { + pmt::pmt_t s = pmt::dict_ref(dict, pmt::mp("lqi"), pmt::PMT_NIL); + if(pmt::is_integer(s)) { + tap_tlv_lqi *lqi = reinterpret_cast(d_msg + offset); + lqi->type = 10; // LQI + lqi->length = 1; + lqi->lqi = (uint8_t)pmt::to_long(s); + for (int i = 0; i < 3; i++) { + lqi->padding[i] = 0; + } + offset += sizeof(tap_tlv_lqi); + extra_size += sizeof(tap_tlv_lqi); + } + } + tap->length = extra_size; hdr->incl_len = len + extra_size; hdr->orig_len = len + extra_size; diff --git a/lib/wireshark_connector_impl.h b/lib/wireshark_connector_impl.h index a56959b..b12518e 100644 --- a/lib/wireshark_connector_impl.h +++ b/lib/wireshark_connector_impl.h @@ -104,6 +104,15 @@ namespace foo { }; #pragma pack(pop) + #pragma pack(push, 1) + struct tap_tlv_lqi { + uint16_t type; // LQI_TYPE = 10 + uint16_t length; // 1 + uint8_t lqi; + uint8_t padding[3]; // Should be 0 padded + }; + #pragma pack(pop) + } // namespace foo } // namespace gr