From b60a133ac81288807203478cb3b3c6621f8a70e5 Mon Sep 17 00:00:00 2001 From: Bastian Bloessl Date: Sun, 16 Jun 2013 07:06:00 +0200 Subject: [PATCH] wireshark: add Option for different link types --- grc/foo_wireshark_connector.xml | 17 ++++++++++++++++- include/foo/wireshark_connector.h | 7 ++++++- lib/wireshark_connector_impl.cc | 11 ++++++----- lib/wireshark_connector_impl.h | 7 ++----- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/grc/foo_wireshark_connector.xml b/grc/foo_wireshark_connector.xml index 5b6ba0a..4f6187e 100644 --- a/grc/foo_wireshark_connector.xml +++ b/grc/foo_wireshark_connector.xml @@ -4,7 +4,22 @@ foo_wireshark_connector Foo import foo - foo.wireshark_connector($debug) + foo.wireshark_connector($tech, $debug) + + + Technology + tech + 127 + enum + + + Debug diff --git a/include/foo/wireshark_connector.h b/include/foo/wireshark_connector.h index 01cca48..bdc441b 100644 --- a/include/foo/wireshark_connector.h +++ b/include/foo/wireshark_connector.h @@ -23,12 +23,17 @@ namespace gr { namespace foo { +enum LinkType { + WIFI = 127, + ZIGBEE = 195 +}; + class FOO_API wireshark_connector : virtual public gr::block { public: typedef boost::shared_ptr sptr; - static sptr make(bool debug= false); + static sptr make(LinkType type, bool debug= false); }; } // namespace foo diff --git a/lib/wireshark_connector_impl.cc b/lib/wireshark_connector_impl.cc index c0a7cb0..3791ffc 100644 --- a/lib/wireshark_connector_impl.cc +++ b/lib/wireshark_connector_impl.cc @@ -27,12 +27,13 @@ using namespace gr::foo; #define dout d_debug && std::cout -wireshark_connector_impl::wireshark_connector_impl(bool debug) : +wireshark_connector_impl::wireshark_connector_impl(LinkType type, bool debug) : block ("wireshark_connector", gr::io_signature::make(0, 0, 0), gr::io_signature::make(1, 1, sizeof(uint8_t))), d_msg_offset(0), - d_debug(debug) { + d_debug(debug), + d_link(type) { message_port_register_in(pmt::mp("in")); @@ -43,7 +44,7 @@ wireshark_connector_impl::wireshark_connector_impl(bool debug) : hdr->thiszone = 0; hdr->sigfigs = 0; hdr->snaplen = 65535; - hdr->network = ZIGBEE; + hdr->network = d_link; d_msg_len = sizeof(pcap_global); } @@ -115,6 +116,6 @@ wireshark_connector_impl::general_work(int noutput, gr_vector_int& ninput_items, } wireshark_connector::sptr -wireshark_connector::make(bool debug) { - return gnuradio::get_initial_sptr(new wireshark_connector_impl(debug)); +wireshark_connector::make(LinkType type, bool debug) { + return gnuradio::get_initial_sptr(new wireshark_connector_impl(type, debug)); } diff --git a/lib/wireshark_connector_impl.h b/lib/wireshark_connector_impl.h index 348dbf0..d173367 100644 --- a/lib/wireshark_connector_impl.h +++ b/lib/wireshark_connector_impl.h @@ -29,8 +29,9 @@ namespace foo { int d_msg_offset; int d_msg_len; char d_msg[256]; + LinkType d_link; public: - wireshark_connector_impl(bool debug); + wireshark_connector_impl(LinkType type, bool debug); virtual ~wireshark_connector_impl(); int general_work(int noutput, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, @@ -38,10 +39,6 @@ namespace foo { void copy_message(const char *buf, int len); }; - enum LINK_LAYER_PROTOCOL { - ZIGBEE = 195 - }; - struct pcap_global { uint32_t magic_number; /* magic number */ uint16_t version_major; /* major version number */