From b9a80a76aa6117ad1ed865accc77004db24d0e42 Mon Sep 17 00:00:00 2001 From: Martin Braun <martin.braun@ettus.com> Date: Fri, 19 Aug 2016 10:37:37 -0700 Subject: Revert "B200: Adding separate B200 radio control code" This reverts commit 5d360ab43eca63e3f12f0e5abde5a3186b7f12dc. --- host/lib/usrp/b200/CMakeLists.txt | 1 - host/lib/usrp/b200/b200_impl.cpp | 12 +- host/lib/usrp/b200/b200_impl.hpp | 10 +- host/lib/usrp/b200/b200_io_impl.cpp | 2 +- host/lib/usrp/b200/b200_radio_ctrl_core.cpp | 347 ---------------------------- host/lib/usrp/b200/b200_radio_ctrl_core.hpp | 64 ----- 6 files changed, 12 insertions(+), 424 deletions(-) delete mode 100644 host/lib/usrp/b200/b200_radio_ctrl_core.cpp delete mode 100644 host/lib/usrp/b200/b200_radio_ctrl_core.hpp diff --git a/host/lib/usrp/b200/CMakeLists.txt b/host/lib/usrp/b200/CMakeLists.txt index d953acb19..4b9e2de55 100644 --- a/host/lib/usrp/b200/CMakeLists.txt +++ b/host/lib/usrp/b200/CMakeLists.txt @@ -30,6 +30,5 @@ IF(ENABLE_B200) ${CMAKE_CURRENT_SOURCE_DIR}/b200_io_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/b200_uart.cpp ${CMAKE_CURRENT_SOURCE_DIR}/b200_cores.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/b200_radio_ctrl_core.cpp ) ENDIF(ENABLE_B200) diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 9526ae2d1..aed1204d3 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -466,7 +466,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// // Local control endpoint //////////////////////////////////////////////////////////////////// - _local_ctrl = b200_radio_ctrl_core::make(false/*lilE*/, _ctrl_transport, zero_copy_if::sptr()/*null*/, B200_LOCAL_CTRL_SID); + _local_ctrl = radio_ctrl_core_3000::make(false/*lilE*/, _ctrl_transport, zero_copy_if::sptr()/*null*/, B200_LOCAL_CTRL_SID); _local_ctrl->hold_task(_async_task); _async_task_data->local_ctrl = _local_ctrl; //weak this->check_fpga_compat(); @@ -625,9 +625,9 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s { _codec_mgr->loopback_self_test( boost::bind( - &b200_radio_ctrl_core::poke32, perif.ctrl, TOREG(SR_CODEC_IDLE), _1 + &radio_ctrl_core_3000::poke32, perif.ctrl, TOREG(SR_CODEC_IDLE), _1 ), - boost::bind(&b200_radio_ctrl_core::peek64, perif.ctrl, RB64_CODEC_READBACK) + boost::bind(&radio_ctrl_core_3000::peek64, perif.ctrl, RB64_CODEC_READBACK) ); } @@ -756,7 +756,7 @@ void b200_impl::setup_radio(const size_t dspno) //////////////////////////////////////////////////////////////////// // radio control //////////////////////////////////////////////////////////////////// - perif.ctrl = b200_radio_ctrl_core::make( + perif.ctrl = radio_ctrl_core_3000::make( false/*lilE*/, _ctrl_transport, zero_copy_if::sptr()/*null*/, @@ -764,9 +764,9 @@ void b200_impl::setup_radio(const size_t dspno) perif.ctrl->hold_task(_async_task); _async_task_data->radio_ctrl[dspno] = perif.ctrl; //weak _tree->access<time_spec_t>(mb_path / "time" / "cmd") - .add_coerced_subscriber(boost::bind(&b200_radio_ctrl_core::set_time, perif.ctrl, _1)); + .add_coerced_subscriber(boost::bind(&radio_ctrl_core_3000::set_time, perif.ctrl, _1)); _tree->access<double>(mb_path / "tick_rate") - .add_coerced_subscriber(boost::bind(&b200_radio_ctrl_core::set_tick_rate, perif.ctrl, _1)); + .add_coerced_subscriber(boost::bind(&radio_ctrl_core_3000::set_tick_rate, perif.ctrl, _1)); this->register_loopback_self_test(perif.ctrl); //////////////////////////////////////////////////////////////////// diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index 3ca76fce6..130e93891 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -28,7 +28,7 @@ #include "tx_vita_core_3000.hpp" #include "time_core_3000.hpp" #include "gpio_atr_3000.hpp" -#include "b200_radio_ctrl_core.hpp" +#include "radio_ctrl_core_3000.hpp" #include "rx_dsp_core_3000.hpp" #include "tx_dsp_core_3000.hpp" #include <uhd/device.hpp> @@ -131,7 +131,7 @@ private: //controllers b200_iface::sptr _iface; - b200_radio_ctrl_core::sptr _local_ctrl; + radio_ctrl_core_3000::sptr _local_ctrl; uhd::usrp::ad9361_ctrl::sptr _codec_ctrl; uhd::usrp::ad936x_manager::sptr _codec_mgr; b200_local_spi_core::sptr _spi_iface; @@ -154,8 +154,8 @@ private: struct AsyncTaskData { boost::shared_ptr<async_md_type> async_md; - boost::weak_ptr<b200_radio_ctrl_core> local_ctrl; - boost::weak_ptr<b200_radio_ctrl_core> radio_ctrl[2]; + boost::weak_ptr<radio_ctrl_core_3000> local_ctrl; + boost::weak_ptr<radio_ctrl_core_3000> radio_ctrl[2]; b200_uart::sptr gpsdo_uart; }; boost::shared_ptr<AsyncTaskData> _async_task_data; @@ -179,7 +179,7 @@ private: //perifs in the radio core struct radio_perifs_t { - b200_radio_ctrl_core::sptr ctrl; + radio_ctrl_core_3000::sptr ctrl; uhd::usrp::gpio_atr::gpio_atr_3000::sptr atr; uhd::usrp::gpio_atr::gpio_atr_3000::sptr fp_gpio; time_core_3000::sptr time64; diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index d186ec907..283091140 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -318,7 +318,7 @@ boost::optional<uhd::msg_task::msg_type_t> b200_impl::handle_async_task( case B200_RESP1_MSG_SID: case B200_LOCAL_RESP_SID: { - b200_radio_ctrl_core::sptr ctrl; + radio_ctrl_core_3000::sptr ctrl; if (sid == B200_RESP0_MSG_SID) ctrl = data->radio_ctrl[0].lock(); if (sid == B200_RESP1_MSG_SID) ctrl = data->radio_ctrl[1].lock(); if (sid == B200_LOCAL_RESP_SID) ctrl = data->local_ctrl.lock(); diff --git a/host/lib/usrp/b200/b200_radio_ctrl_core.cpp b/host/lib/usrp/b200/b200_radio_ctrl_core.cpp deleted file mode 100644 index b6d8f95df..000000000 --- a/host/lib/usrp/b200/b200_radio_ctrl_core.cpp +++ /dev/null @@ -1,347 +0,0 @@ -// -// Copyright 2012-2015 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#include "b200_radio_ctrl_core.hpp" -#include "async_packet_handler.hpp" -#include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> -#include <uhd/utils/byteswap.hpp> -#include <uhd/utils/safe_call.hpp> -#include <uhd/transport/bounded_buffer.hpp> -#include <uhd/transport/vrt_if_packet.hpp> -#include <boost/thread/mutex.hpp> -#include <boost/thread/thread.hpp> -#include <boost/format.hpp> -#include <boost/bind.hpp> -#include <queue> - -using namespace uhd; -using namespace uhd::usrp; -using namespace uhd::transport; - -static const double ACK_TIMEOUT = 2.0; //supposed to be worst case practical timeout -static const double MASSIVE_TIMEOUT = 10.0; //for when we wait on a timed command -static const size_t SR_READBACK = 32; - -b200_radio_ctrl_core::~b200_radio_ctrl_core(void){ - /* NOP */ -} - -class b200_radio_ctrl_core_impl: public b200_radio_ctrl_core -{ -public: - - b200_radio_ctrl_core_impl(const bool big_endian, - uhd::transport::zero_copy_if::sptr ctrl_xport, - uhd::transport::zero_copy_if::sptr resp_xport, - const boost::uint32_t sid, const std::string &name) : - _link_type(vrt::if_packet_info_t::LINK_TYPE_CHDR), _packet_type( - vrt::if_packet_info_t::PACKET_TYPE_CONTEXT), _bige( - big_endian), _ctrl_xport(ctrl_xport), _resp_xport( - resp_xport), _sid(sid), _name(name), _seq_out(0), _timeout( - ACK_TIMEOUT), _resp_queue(128/*max response msgs*/), _resp_queue_size( - _resp_xport ? _resp_xport->get_num_recv_frames() : 15) - { - if (resp_xport) - { - while (resp_xport->get_recv_buff(0.0)) {} //flush - } - this->set_time(uhd::time_spec_t(0.0)); - this->set_tick_rate(1.0); //something possible but bogus - } - - ~b200_radio_ctrl_core_impl(void) - { - _timeout = ACK_TIMEOUT; //reset timeout to something small - UHD_SAFE_CALL( - this->peek32(0);//dummy peek with the purpose of ack'ing all packets - _async_task.reset();//now its ok to release the task - ) - } - - /******************************************************************* - * Peek and poke 32 bit implementation - ******************************************************************/ - void poke32(const wb_addr_type addr, const boost::uint32_t data) - { - boost::mutex::scoped_lock lock(_mutex); - this->send_pkt(addr/4, data); - this->wait_for_ack(false); - } - - boost::uint32_t peek32(const wb_addr_type addr) - { - boost::mutex::scoped_lock lock(_mutex); - this->send_pkt(SR_READBACK, addr/8); - const boost::uint64_t res = this->wait_for_ack(true); - const boost::uint32_t lo = boost::uint32_t(res & 0xffffffff); - const boost::uint32_t hi = boost::uint32_t(res >> 32); - return ((addr/4) & 0x1)? hi : lo; - } - - boost::uint64_t peek64(const wb_addr_type addr) - { - boost::mutex::scoped_lock lock(_mutex); - this->send_pkt(SR_READBACK, addr/8); - return this->wait_for_ack(true); - } - - /******************************************************************* - * Update methods for time - ******************************************************************/ - void set_time(const uhd::time_spec_t &time) - { - boost::mutex::scoped_lock lock(_mutex); - _time = time; - _use_time = _time != uhd::time_spec_t(0.0); - if (_use_time) _timeout = MASSIVE_TIMEOUT; //permanently sets larger timeout - } - - uhd::time_spec_t get_time(void) - { - boost::mutex::scoped_lock lock(_mutex); - return _time; - } - - void set_tick_rate(const double rate) - { - boost::mutex::scoped_lock lock(_mutex); - _tick_rate = rate; - } - -private: - // This is the buffer type for messages in radio control core. - struct resp_buff_type - { - boost::uint32_t data[8]; - }; - - /******************************************************************* - * Primary control and interaction private methods - ******************************************************************/ - UHD_INLINE void send_pkt(const boost::uint32_t addr, const boost::uint32_t data = 0) - { - managed_send_buffer::sptr buff = _ctrl_xport->get_send_buff(0.0); - if (not buff) { - throw uhd::runtime_error("fifo ctrl timed out getting a send buffer"); - } - boost::uint32_t *pkt = buff->cast<boost::uint32_t *>(); - - //load packet info - vrt::if_packet_info_t packet_info; - packet_info.link_type = _link_type; - packet_info.packet_type = _packet_type; - packet_info.num_payload_words32 = 2; - packet_info.num_payload_bytes = packet_info.num_payload_words32*sizeof(boost::uint32_t); - packet_info.packet_count = _seq_out; - packet_info.tsf = _time.to_ticks(_tick_rate); - packet_info.sob = false; - packet_info.eob = false; - packet_info.sid = _sid; - packet_info.has_sid = true; - packet_info.has_cid = false; - packet_info.has_tsi = false; - packet_info.has_tsf = _use_time; - packet_info.has_tlr = false; - - //load header - if (_bige) vrt::if_hdr_pack_be(pkt, packet_info); - else vrt::if_hdr_pack_le(pkt, packet_info); - - //load payload - pkt[packet_info.num_header_words32+0] = (_bige)? uhd::htonx(addr) : uhd::htowx(addr); - pkt[packet_info.num_header_words32+1] = (_bige)? uhd::htonx(data) : uhd::htowx(data); - //UHD_MSG(status) << boost::format("0x%08x, 0x%08x\n") % addr % data; - //send the buffer over the interface - _outstanding_seqs.push(_seq_out); - buff->commit(sizeof(boost::uint32_t)*(packet_info.num_packet_words32)); - - _seq_out++;//inc seq for next call - } - - UHD_INLINE boost::uint64_t wait_for_ack(const bool readback) - { - while (readback or (_outstanding_seqs.size() >= _resp_queue_size)) - { - //get seq to ack from outstanding packets list - UHD_ASSERT_THROW(not _outstanding_seqs.empty()); - const size_t seq_to_ack = _outstanding_seqs.front(); - _outstanding_seqs.pop(); - - //parse the packet - vrt::if_packet_info_t packet_info; - resp_buff_type resp_buff; - memset(&resp_buff, 0x00, sizeof(resp_buff)); - boost::uint32_t const *pkt = NULL; - managed_recv_buffer::sptr buff; - - //get buffer from response endpoint - or die in timeout - if (_resp_xport) - { - buff = _resp_xport->get_recv_buff(_timeout); - try - { - UHD_ASSERT_THROW(bool(buff)); - UHD_ASSERT_THROW(buff->size() > 0); - } - catch(const std::exception &ex) - { - throw uhd::io_error(str(boost::format("Radio ctrl (%s) no response packet - %s") % _name % ex.what())); - } - pkt = buff->cast<const boost::uint32_t *>(); - packet_info.num_packet_words32 = buff->size()/sizeof(boost::uint32_t); - } - - //get buffer from response endpoint - or die in timeout - else - { - /* - * Couldn't get message with haste. - * Now check both possible queues for messages. - * Messages should come in on _resp_queue, - * but could end up in dump_queue. - * If we don't get a message --> Die in timeout. - */ - double accum_timeout = 0.0; - const double short_timeout = 0.005; // == 5ms - while(not ((_resp_queue.pop_with_haste(resp_buff)) - || (check_dump_queue(resp_buff)) - || (_resp_queue.pop_with_timed_wait(resp_buff, short_timeout)) - )){ - /* - * If a message couldn't be received within a given timeout - * --> throw AssertionError! - */ - accum_timeout += short_timeout; - UHD_ASSERT_THROW(accum_timeout < _timeout); - } - - pkt = resp_buff.data; - packet_info.num_packet_words32 = sizeof(resp_buff)/sizeof(boost::uint32_t); - } - - //parse the buffer - try - { - packet_info.link_type = _link_type; - if (_bige) vrt::if_hdr_unpack_be(pkt, packet_info); - else vrt::if_hdr_unpack_le(pkt, packet_info); - } - catch(const std::exception &ex) - { - UHD_MSG(error) << "Radio ctrl bad VITA packet: " << ex.what() << std::endl; - if (buff){ - UHD_VAR(buff->size()); - } - else{ - UHD_MSG(status) << "buff is NULL" << std::endl; - } - UHD_MSG(status) << std::hex << pkt[0] << std::dec << std::endl; - UHD_MSG(status) << std::hex << pkt[1] << std::dec << std::endl; - UHD_MSG(status) << std::hex << pkt[2] << std::dec << std::endl; - UHD_MSG(status) << std::hex << pkt[3] << std::dec << std::endl; - } - - //check the buffer - try - { - UHD_ASSERT_THROW(packet_info.has_sid); - UHD_ASSERT_THROW(packet_info.sid == boost::uint32_t((_sid >> 16) | (_sid << 16))); - UHD_ASSERT_THROW(packet_info.packet_count == (seq_to_ack & 0xfff)); - UHD_ASSERT_THROW(packet_info.num_payload_words32 == 2); - UHD_ASSERT_THROW(packet_info.packet_type == _packet_type); - } - catch(const std::exception &ex) - { - throw uhd::io_error(str(boost::format("Radio ctrl (%s) packet parse error - %s") % _name % ex.what())); - } - - //return the readback value - if (readback and _outstanding_seqs.empty()) - { - const boost::uint64_t hi = (_bige)? uhd::ntohx(pkt[packet_info.num_header_words32+0]) : uhd::wtohx(pkt[packet_info.num_header_words32+0]); - const boost::uint64_t lo = (_bige)? uhd::ntohx(pkt[packet_info.num_header_words32+1]) : uhd::wtohx(pkt[packet_info.num_header_words32+1]); - return ((hi << 32) | lo); - } - } - - return 0; - } - - /* - * If ctrl_core waits for a message that didn't arrive it can search for it in the dump queue. - * This actually happens during shutdown. - * handle_async_task can't access radio_ctrl_cores queue anymore thus it returns the corresponding message. - * msg_task class implements a dump_queue to store such messages. - * With check_dump_queue we can check if a message we are waiting for got stranded there. - * If a message got stuck we get it here and push it onto our own message_queue. - */ - bool check_dump_queue(resp_buff_type& b) { - const size_t min_buff_size = 8; // Same value as in b200_io_impl->handle_async_task - boost::uint32_t recv_sid = (((_sid)<<16)|((_sid)>>16)); - uhd::msg_task::msg_payload_t msg; - do{ - msg = _async_task->get_msg_from_dump_queue(recv_sid); - } - while(msg.size() < min_buff_size && msg.size() != 0); - - if(msg.size() >= min_buff_size) { - memcpy(b.data, &msg.front(), std::min(msg.size(), sizeof(b.data))); - return true; - } - return false; - } - - void push_response(const boost::uint32_t *buff) - { - resp_buff_type resp_buff; - std::memcpy(resp_buff.data, buff, sizeof(resp_buff)); - _resp_queue.push_with_haste(resp_buff); - } - - void hold_task(uhd::msg_task::sptr task) - { - _async_task = task; - } - - const vrt::if_packet_info_t::link_type_t _link_type; - const vrt::if_packet_info_t::packet_type_t _packet_type; - const bool _bige; - const uhd::transport::zero_copy_if::sptr _ctrl_xport; - const uhd::transport::zero_copy_if::sptr _resp_xport; - uhd::msg_task::sptr _async_task; - const boost::uint32_t _sid; - const std::string _name; - boost::mutex _mutex; - size_t _seq_out; - uhd::time_spec_t _time; - bool _use_time; - double _tick_rate; - double _timeout; - std::queue<size_t> _outstanding_seqs; - bounded_buffer<resp_buff_type> _resp_queue; - const size_t _resp_queue_size; -}; - -b200_radio_ctrl_core::sptr b200_radio_ctrl_core::make(const bool big_endian, - zero_copy_if::sptr ctrl_xport, zero_copy_if::sptr resp_xport, - const boost::uint32_t sid, const std::string &name) -{ - return sptr( - new b200_radio_ctrl_core_impl(big_endian, ctrl_xport, resp_xport, - sid, name)); -} diff --git a/host/lib/usrp/b200/b200_radio_ctrl_core.hpp b/host/lib/usrp/b200/b200_radio_ctrl_core.hpp deleted file mode 100644 index 51f7e3301..000000000 --- a/host/lib/usrp/b200/b200_radio_ctrl_core.hpp +++ /dev/null @@ -1,64 +0,0 @@ -// -// Copyright 2012-2015 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_LIBUHD_USRP_B200_RADIO_CTRL_HPP -#define INCLUDED_LIBUHD_USRP_B200_RADIO_CTRL_HPP - -#include <uhd/utils/msg_task.hpp> -#include <uhd/types/time_spec.hpp> -#include <uhd/transport/zero_copy.hpp> -#include <uhd/types/wb_iface.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/utility.hpp> -#include <string> - -/*! - * Provide access to peek, poke for the radio ctrl module - */ -class b200_radio_ctrl_core : public uhd::timed_wb_iface -{ -public: - typedef boost::shared_ptr<b200_radio_ctrl_core> sptr; - - virtual ~b200_radio_ctrl_core(void) = 0; - - //! Make a new control object - static sptr make( - const bool big_endian, - uhd::transport::zero_copy_if::sptr ctrl_xport, - uhd::transport::zero_copy_if::sptr resp_xport, - const boost::uint32_t sid, - const std::string &name = "0" - ); - - //! Hold a ref to a task thats feeding push response - virtual void hold_task(uhd::msg_task::sptr task) = 0; - - //! Push a response externall (resp_xport is NULL) - virtual void push_response(const boost::uint32_t *buff) = 0; - - //! Set the command time that will activate - virtual void set_time(const uhd::time_spec_t &time) = 0; - - //! Get the command time that will activate - virtual uhd::time_spec_t get_time(void) = 0; - - //! Set the tick rate (converting time into ticks) - virtual void set_tick_rate(const double rate) = 0; -}; - -#endif /* INCLUDED_LIBUHD_USRP_B200_RADIO_CTRL_HPP */ -- cgit v1.2.3 From 62f38b8f0607a70287bdfdbb0d71aff9cc0e723e Mon Sep 17 00:00:00 2001 From: Martin Braun <martin.braun@ettus.com> Date: Fri, 19 Aug 2016 11:31:30 -0700 Subject: rfnoc: legacy compat cache will always recreate entries --- host/lib/rfnoc/legacy_compat.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/host/lib/rfnoc/legacy_compat.cpp b/host/lib/rfnoc/legacy_compat.cpp index 843cdea34..2c8e10c4a 100644 --- a/host/lib/rfnoc/legacy_compat.cpp +++ b/host/lib/rfnoc/legacy_compat.cpp @@ -38,7 +38,7 @@ using uhd::usrp::subdev_spec_pair_t; using uhd::stream_cmd_t; /************************************************************************ - * Constants + * Constants and globals ***********************************************************************/ static const std::string RADIO_BLOCK_NAME = "Radio"; static const std::string DFIFO_BLOCK_NAME = "DmaFIFO"; @@ -47,6 +47,7 @@ static const std::string DUC_BLOCK_NAME = "DUC"; static const size_t MAX_BYTES_PER_HEADER = uhd::transport::vrt::chdr::max_if_hdr_words64 * sizeof(uint64_t); static const size_t BYTES_PER_SAMPLE = 4; // We currently only support sc16 +static boost::mutex _make_mutex; /************************************************************************ * Static helpers @@ -700,15 +701,13 @@ legacy_compat::sptr legacy_compat::make( uhd::device3::sptr device, const uhd::device_addr_t &args ) { + boost::lock_guard<boost::mutex> lock(_make_mutex); UHD_ASSERT_THROW(bool(device)); static std::map<void *, boost::weak_ptr<legacy_compat> > legacy_cache; - if (legacy_cache.count(device.get())) { + if (legacy_cache.count(device.get()) and not legacy_cache.at(device.get()).expired()) { legacy_compat::sptr legacy_compat_copy = legacy_cache.at(device.get()).lock(); - if (not bool(legacy_compat_copy)) { - throw uhd::runtime_error("Reference to existing legacy compat object expired prematurely!"); - } - + UHD_ASSERT_THROW(bool(legacy_compat_copy)); UHD_LEGACY_LOG() << "[legacy_compat] Using existing legacy compat object for this device." << std::endl; return legacy_compat_copy; } -- cgit v1.2.3 From fe7fe8b6ceb21da3e3636b955f2248b511a6d146 Mon Sep 17 00:00:00 2001 From: Derek Kozel <derek.kozel@ettus.com> Date: Wed, 24 Aug 2016 12:22:20 -0700 Subject: Combined dissectors and added Wireshark 2 support --- tools/chdr-dissector/.gitignore | 2 - tools/chdr-dissector/CMakeLists.txt | 96 ----- tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake | 238 ---------- .../cmake/Modules/FindWireshark.cmake | 28 -- tools/chdr-dissector/make-dissector-reg.py | 305 ------------- tools/chdr-dissector/moduleinfo.h | 9 - tools/chdr-dissector/packet-chdr.c | 472 -------------------- tools/chdr-dissector/plugin.rc.in | 34 -- tools/dissectors/.gitignore | 2 + tools/dissectors/CMakeLists.txt | 106 +++++ tools/dissectors/cmake/Modules/FindGLIB2.cmake | 238 ++++++++++ tools/dissectors/cmake/Modules/FindWireshark.cmake | 28 ++ tools/dissectors/make-dissector-reg.py | 305 +++++++++++++ tools/dissectors/moduleinfo.h.in | 10 + tools/dissectors/packet-chdr.c | 477 +++++++++++++++++++++ tools/dissectors/packet-octoclock.c | 212 +++++++++ tools/dissectors/packet-zpu.c | 242 +++++++++++ tools/dissectors/plugin.rc.in | 34 ++ tools/dissectors/zpu_addr_names.h | 38 ++ tools/octoclock-dissector/.gitignore | 2 - tools/octoclock-dissector/CMakeLists.txt | 96 ----- .../cmake/Modules/FindGLIB2.cmake | 238 ---------- .../cmake/Modules/FindWireshark.cmake | 28 -- tools/octoclock-dissector/make-dissector-reg.py | 305 ------------- tools/octoclock-dissector/moduleinfo.h | 9 - tools/octoclock-dissector/packet-octoclock.c | 212 --------- tools/octoclock-dissector/plugin.rc.in | 34 -- tools/zpu-dissector/.gitignore | 2 - tools/zpu-dissector/CMakeLists.txt | 96 ----- tools/zpu-dissector/cmake | 1 - tools/zpu-dissector/make-dissector-reg.py | 1 - tools/zpu-dissector/moduleinfo.h | 9 - tools/zpu-dissector/packet-zpu.c | 237 ---------- tools/zpu-dissector/plugin.rc.in | 34 -- tools/zpu-dissector/zpu_addr_names.h | 38 -- 35 files changed, 1692 insertions(+), 2526 deletions(-) delete mode 100644 tools/chdr-dissector/.gitignore delete mode 100644 tools/chdr-dissector/CMakeLists.txt delete mode 100644 tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake delete mode 100644 tools/chdr-dissector/cmake/Modules/FindWireshark.cmake delete mode 100755 tools/chdr-dissector/make-dissector-reg.py delete mode 100644 tools/chdr-dissector/moduleinfo.h delete mode 100644 tools/chdr-dissector/packet-chdr.c delete mode 100644 tools/chdr-dissector/plugin.rc.in create mode 100644 tools/dissectors/.gitignore create mode 100644 tools/dissectors/CMakeLists.txt create mode 100644 tools/dissectors/cmake/Modules/FindGLIB2.cmake create mode 100644 tools/dissectors/cmake/Modules/FindWireshark.cmake create mode 100755 tools/dissectors/make-dissector-reg.py create mode 100644 tools/dissectors/moduleinfo.h.in create mode 100644 tools/dissectors/packet-chdr.c create mode 100644 tools/dissectors/packet-octoclock.c create mode 100644 tools/dissectors/packet-zpu.c create mode 100644 tools/dissectors/plugin.rc.in create mode 100644 tools/dissectors/zpu_addr_names.h delete mode 100644 tools/octoclock-dissector/.gitignore delete mode 100644 tools/octoclock-dissector/CMakeLists.txt delete mode 100644 tools/octoclock-dissector/cmake/Modules/FindGLIB2.cmake delete mode 100644 tools/octoclock-dissector/cmake/Modules/FindWireshark.cmake delete mode 100755 tools/octoclock-dissector/make-dissector-reg.py delete mode 100644 tools/octoclock-dissector/moduleinfo.h delete mode 100644 tools/octoclock-dissector/packet-octoclock.c delete mode 100644 tools/octoclock-dissector/plugin.rc.in delete mode 100644 tools/zpu-dissector/.gitignore delete mode 100644 tools/zpu-dissector/CMakeLists.txt delete mode 120000 tools/zpu-dissector/cmake delete mode 120000 tools/zpu-dissector/make-dissector-reg.py delete mode 100644 tools/zpu-dissector/moduleinfo.h delete mode 100644 tools/zpu-dissector/packet-zpu.c delete mode 100644 tools/zpu-dissector/plugin.rc.in delete mode 100644 tools/zpu-dissector/zpu_addr_names.h diff --git a/tools/chdr-dissector/.gitignore b/tools/chdr-dissector/.gitignore deleted file mode 100644 index 0187b3dac..000000000 --- a/tools/chdr-dissector/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build/ -*~ diff --git a/tools/chdr-dissector/CMakeLists.txt b/tools/chdr-dissector/CMakeLists.txt deleted file mode 100644 index 8d19807d8..000000000 --- a/tools/chdr-dissector/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2010-2013 Ettus Research LLC -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - - -######################################################################## -# Project setup -######################################################################## -cmake_minimum_required(VERSION 2.6) -project(chdr-dissector C) -set(chdr-dissector_VERSION_MAJOR 0) -set(chdr-dissector_VERSION_MINOR 0) -enable_testing() - -#select the release build type by default to get optimization flags -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to release.") -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) - -######################################################################## -# Compiler specific setup -######################################################################## -#if(CMAKE_COMPILER_IS_GNUC AND NOT WIN32) -# #http://gcc.gnu.org/wiki/Visibility -# add_definitions(-fvisibility=visible) -#endif() - -find_package(GLIB2) -if(NOT GLIB2_FOUND) - message(FATAL_ERROR "Glib not found") -endif() - -find_package(Wireshark) -if(NOT WIRESHARK_FOUND) - message(FATAL_ERROR "Wireshark dev package not found") -endif() - - -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${CMAKE_SOURCE_DIR} - ${GLIB2_INCLUDE_DIRS} - ${WIRESHARK_INCLUDE_DIRS} -) - -#link_directories( -# ${Boost_LIBRARY_DIRS} -#) -set(CMAKE_INSTALL_LIBDIR ~/.wireshark) - -# Set component parameters -set(CHDR_DISSECTOR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR} CACHE INTERNAL "" FORCE) - -set(CHDR_PLUGIN_SRC ${CMAKE_SOURCE_DIR}/packet-chdr.c) - -set(PLUGIN_C_GENERATOR ${CMAKE_SOURCE_DIR}/make-dissector-reg.py) -set(PLUGIN_C plugin.c) - -add_custom_command( - OUTPUT ${PLUGIN_C} - DEPENDS ${CHDR_PLUGIN_SRC} - COMMAND ${PLUGIN_C_GENERATOR} ${CMAKE_SOURCE_DIR} plugin ${CHDR_PLUGIN_SRC} - COMMENT "Generating ${PLUGIN_C}" -) - -add_library(chdr-plugin MODULE - ${PLUGIN_C} - moduleinfo.h - ${CHDR_PLUGIN_SRC} -) -set_target_properties(chdr-plugin PROPERTIES PREFIX "") -set_target_properties(chdr-plugin PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") -target_link_libraries(chdr-plugin wireshark) - -install(TARGETS chdr-plugin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugins NAMELINK_SKIP -) diff --git a/tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake b/tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake deleted file mode 100644 index ae7baddbb..000000000 --- a/tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake +++ /dev/null @@ -1,238 +0,0 @@ -# -# $Id: FindGLIB2.cmake 34248 2010-09-25 15:38:12Z jmayer $ -# -# - Try to find GLib2 -# Once done this will define -# -# GLIB2_FOUND - system has GLib2 -# GLIB2_INCLUDE_DIRS - the GLib2 include directory -# GLIB2_LIBRARIES - Link these to use GLib2 -# -# HAVE_GLIB_GREGEX_H glib has gregex.h header and -# supports g_regex_match_simple -# -# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org> -# Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com> -# Copyright (c) 2007 Daniel Gollub <gollub@b1-systems.de> -# Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com> -# Copyright (c) 2008 Michael Bell <michael.bell@web.de> -# Copyright (c) 2008-2009 Bjoern Ricks <bjoern.ricks@googlemail.com> -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - - -IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) - # in cache already - SET(GLIB2_FOUND TRUE) -ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) - - INCLUDE(FindPkgConfig) - - ## Glib - IF ( GLIB2_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "REQUIRED" ) - ELSE ( GLIB2_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "" ) - ENDIF ( GLIB2_FIND_REQUIRED ) - - IF ( GLIB2_MIN_VERSION ) - PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) - ELSE ( GLIB2_MIN_VERSION ) - PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) - ENDIF ( GLIB2_MIN_VERSION ) - IF ( PKG_CONFIG_FOUND ) - IF ( GLIB2_FOUND ) - SET ( GLIB2_CORE_FOUND TRUE ) - ELSE ( GLIB2_FOUND ) - SET ( GLIB2_CORE_FOUND FALSE ) - ENDIF ( GLIB2_FOUND ) - ENDIF ( PKG_CONFIG_FOUND ) - - # Look for glib2 include dir and libraries w/o pkgconfig - IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) - FIND_PATH( - _glibconfig_include_DIR - NAMES - glibconfig.h - PATHS - /opt/gnome/lib64 - /opt/gnome/lib - /opt/lib/ - /opt/local/lib - /sw/lib/ - /usr/lib64 - /usr/lib - /usr/local/include - ${CMAKE_LIBRARY_PATH} - PATH_SUFFIXES - glib-2.0/include - ) - - FIND_PATH( - _glib2_include_DIR - NAMES - glib.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - PATH_SUFFIXES - glib-2.0 - ) - - #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") - - FIND_LIBRARY( - _glib2_link_DIR - NAMES - glib-2.0 - glib - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - IF ( _glib2_include_DIR AND _glib2_link_DIR ) - SET ( _glib2_FOUND TRUE ) - ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) - - - IF ( _glib2_FOUND ) - SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) - SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) - SET ( GLIB2_CORE_FOUND TRUE ) - ELSE ( _glib2_FOUND ) - SET ( GLIB2_CORE_FOUND FALSE ) - ENDIF ( _glib2_FOUND ) - - # Handle dependencies - # libintl - IF ( NOT LIBINTL_FOUND ) - FIND_PATH(LIBINTL_INCLUDE_DIR - NAMES - libintl.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - ) - - FIND_LIBRARY(LIBINTL_LIBRARY - NAMES - intl - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/local/lib - /usr/lib - ) - - IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) - SET (LIBINTL_FOUND TRUE) - ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) - ENDIF ( NOT LIBINTL_FOUND ) - - # libiconv - IF ( NOT LIBICONV_FOUND ) - FIND_PATH(LIBICONV_INCLUDE_DIR - NAMES - iconv.h - PATHS - /opt/gnome/include - /opt/local/include - /opt/local/include - /sw/include - /sw/include - /usr/local/include - /usr/include - PATH_SUFFIXES - glib-2.0 - ) - - FIND_LIBRARY(LIBICONV_LIBRARY - NAMES - iconv - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - - IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - SET (LIBICONV_FOUND TRUE) - ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - ENDIF ( NOT LIBICONV_FOUND ) - - IF (LIBINTL_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) - ENDIF (LIBINTL_FOUND) - - IF (LIBICONV_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) - ENDIF (LIBICONV_FOUND) - - ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) - ## - - IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) - SET (GLIB2_FOUND TRUE) - ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) - - IF (GLIB2_FOUND) - IF (NOT GLIB2_FIND_QUIETLY) - MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") - ENDIF (NOT GLIB2_FIND_QUIETLY) - ELSE (GLIB2_FOUND) - IF (GLIB2_FIND_REQUIRED) - MESSAGE (SEND_ERROR "Could not find GLib2") - ENDIF (GLIB2_FIND_REQUIRED) - ENDIF (GLIB2_FOUND) - - # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view - MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) - MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) - MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) - -ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) - -IF ( WIN32 ) - # include libiconv for win32 - IF ( NOT LIBICONV_FOUND ) - FIND_PATH(LIBICONV_INCLUDE_DIR iconv.h PATH_SUFFIXES glib-2.0) - - FIND_LIBRARY(LIBICONV_LIBRARY NAMES iconv) - - IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - SET (LIBICONV_FOUND TRUE) - ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - ENDIF ( NOT LIBICONV_FOUND ) - IF (LIBICONV_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) - ENDIF (LIBICONV_FOUND) -ENDIF ( WIN32 ) - -IF ( GLIB2_FOUND ) - # Check if system has a newer version of glib - # which supports g_regex_match_simple - INCLUDE( CheckIncludeFiles ) - SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) - CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) - CHECK_INCLUDE_FILES ( glib/gchecksum.h HAVE_GLIB_GCHECKSUM_H ) - # Reset CMAKE_REQUIRED_INCLUDES - SET( CMAKE_REQUIRED_INCLUDES "" ) -ENDIF( GLIB2_FOUND ) diff --git a/tools/chdr-dissector/cmake/Modules/FindWireshark.cmake b/tools/chdr-dissector/cmake/Modules/FindWireshark.cmake deleted file mode 100644 index 276201245..000000000 --- a/tools/chdr-dissector/cmake/Modules/FindWireshark.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# -# Try to find the wireshark library and its includes -# -# This snippet sets the following variables: -# WIRESHARK_FOUND True if wireshark library got found -# WIRESHARK_INCLUDE_DIRS Location of the wireshark headers -# WIRESHARK_LIBRARIES List of libraries to use wireshark -# -# Copyright (c) 2011 Reinhold Kainhofer <reinhold@kainhofer.com> -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - -# wireshark does not install its library with pkg-config information, -# so we need to manually find the libraries and headers - -FIND_PATH( WIRESHARK_INCLUDE_DIRS epan/column.h PATH_SUFFIXES wireshark ) -FIND_LIBRARY( WIRESHARK_LIBRARIES wireshark ) - -# Report results -IF ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - SET( WIRESHARK_FOUND 1 ) -ELSE ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - MESSAGE( SEND_ERROR "Could NOT find the wireshark library and headers" ) -ENDIF ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - diff --git a/tools/chdr-dissector/make-dissector-reg.py b/tools/chdr-dissector/make-dissector-reg.py deleted file mode 100755 index 44972909b..000000000 --- a/tools/chdr-dissector/make-dissector-reg.py +++ /dev/null @@ -1,305 +0,0 @@ -#!/usr/bin/env python -# -# Looks for registration routines in the protocol dissectors, -# and assembles C code to call all the routines. -# -# This is a Python version of the make-reg-dotc shell script. -# Running the shell script on Win32 is very very slow because of -# all the process-launching that goes on --- multiple greps and -# seds for each input file. I wrote this python version so that -# less processes would have to be started. -# -# $Id: make-dissector-reg.py 30447 2009-10-09 20:47:18Z krj $ - -import os -import sys -import re -import pickle -from stat import * - -VERSION_KEY = '_VERSION' -CUR_VERSION = '$Id: make-dissector-reg.py 30447 2009-10-09 20:47:18Z krj $' - -# -# The first argument is the directory in which the source files live. -# -srcdir = sys.argv[1] - -# -# The second argument is either "plugin" or "dissectors"; if it's -# "plugin", we build a plugin.c for a plugin, and if it's -# "dissectors", we build a register.c for libwireshark. -# -registertype = sys.argv[2] -if registertype == "plugin" or registertype == "plugin_wtap": - tmp_filename = "plugin.c-tmp" - final_filename = "plugin.c" - cache_filename = None - preamble = """\ -/* - * Do not modify this file. - * - * It is created automatically by Makefile or Makefile.nmake. - */ -""" -elif registertype == "dissectors": - tmp_filename = "register.c-tmp" - final_filename = "register.c" - cache_filename = "register-cache.pkl" - preamble = """\ -/* - * Do not modify this file. - * - * It is created automatically by the "register.c" target in - * epan/dissectors/Makefile or Makefile.nmake using information in - * epan/dissectors/register-cache.pkl. - * - * You can force this file to be regenerated completely by deleting - * it along with epan/dissectors/register-cache.pkl. - */ -""" -else: - print "Unknown output type '%s'" % registertype - sys.exit(1) - - -# -# All subsequent arguments are the files to scan. -# -files = sys.argv[3:] - -# Create the proper list of filenames -filenames = [] -for file in files: - if os.path.isfile(file): - filenames.append(file) - else: - filenames.append(os.path.join(srcdir, file)) - -if len(filenames) < 1: - print "No files found" - sys.exit(1) - - -# Look through all files, applying the regex to each line. -# If the pattern matches, save the "symbol" section to the -# appropriate array. -regs = { - 'proto_reg': [], - 'handoff_reg': [], - 'wtap_register': [], - } - -# For those that don't know Python, r"" indicates a raw string, -# devoid of Python escapes. -proto_regex0 = r"^(?P<symbol>proto_register_[_A-Za-z0-9]+)\s*\([^;]+$" -proto_regex1 = r"void\s+(?P<symbol>proto_register_[_A-Za-z0-9]+)\s*\([^;]+$" - -handoff_regex0 = r"^(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" -handoff_regex1 = r"void\s+(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" - -wtap_reg_regex0 = r"^(?P<symbol>wtap_register_[_A-Za-z0-9]+)\s*\([^;]+$" -wtap_reg_regex1 = r"void\s+(?P<symbol>wtap_register_[_A-Za-z0-9]+)\s*\([^;]+$" - -# This table drives the pattern-matching and symbol-harvesting -patterns = [ - ( 'proto_reg', re.compile(proto_regex0) ), - ( 'proto_reg', re.compile(proto_regex1) ), - ( 'handoff_reg', re.compile(handoff_regex0) ), - ( 'handoff_reg', re.compile(handoff_regex1) ), - ( 'wtap_register', re.compile(wtap_reg_regex0) ), - ( 'wtap_register', re.compile(wtap_reg_regex1) ), - ] - -# Open our registration symbol cache -cache = None -if cache_filename: - try: - cache_file = open(cache_filename, 'rb') - cache = pickle.load(cache_file) - cache_file.close() - if not cache.has_key(VERSION_KEY) or cache[VERSION_KEY] != CUR_VERSION: - cache = {VERSION_KEY: CUR_VERSION} - except: - cache = {VERSION_KEY: CUR_VERSION} - -# Grep -for filename in filenames: - file = open(filename) - cur_mtime = os.fstat(file.fileno())[ST_MTIME] - if cache and cache.has_key(filename): - cdict = cache[filename] - if cur_mtime == cdict['mtime']: -# print "Pulling %s from cache" % (filename) - regs['proto_reg'].extend(cdict['proto_reg']) - regs['handoff_reg'].extend(cdict['handoff_reg']) - regs['wtap_register'].extend(cdict['wtap_register']) - file.close() - continue - # We don't have a cache entry - if cache is not None: - cache[filename] = { - 'mtime': cur_mtime, - 'proto_reg': [], - 'handoff_reg': [], - 'wtap_register': [], - } -# print "Searching %s" % (filename) - for line in file.readlines(): - for action in patterns: - regex = action[1] - match = regex.search(line) - if match: - symbol = match.group("symbol") - sym_type = action[0] - regs[sym_type].append(symbol) - if cache is not None: -# print "Caching %s for %s: %s" % (sym_type, filename, symbol) - cache[filename][sym_type].append(symbol) - file.close() - -if cache is not None and cache_filename is not None: - cache_file = open(cache_filename, 'wb') - pickle.dump(cache, cache_file) - cache_file.close() - -# Make sure we actually processed something -if len(regs['proto_reg']) < 1: - print "No protocol registrations found" - sys.exit(1) - -# Sort the lists to make them pretty -regs['proto_reg'].sort() -regs['handoff_reg'].sort() -regs['wtap_register'].sort() - -reg_code = open(tmp_filename, "w") - -reg_code.write(preamble) - -# Make the routine to register all protocols -if registertype == "plugin" or registertype == "plugin_wtap": - reg_code.write(""" -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gmodule.h> - -#include "moduleinfo.h" - -#ifndef ENABLE_STATIC -G_MODULE_EXPORT const gchar version[] = VERSION; - -/* Start the functions we need for the plugin stuff */ - -G_MODULE_EXPORT void -plugin_register (void) -{ -"""); -else: - reg_code.write(""" -#include "register.h" -void -register_all_protocols(register_cb cb, gpointer client_data) -{ -"""); - -for symbol in regs['proto_reg']: - if registertype == "plugin" or registertype == "plugin_wtap": - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - else: - line = " {extern void %s (void); if(cb) (*cb)(RA_REGISTER, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol) - reg_code.write(line) - -reg_code.write("}\n") - - -# Make the routine to register all protocol handoffs -if registertype == "plugin" or registertype == "plugin_wtap": - reg_code.write(""" -G_MODULE_EXPORT void -plugin_reg_handoff(void) -{ -"""); -else: - reg_code.write(""" -void -register_all_protocol_handoffs(register_cb cb, gpointer client_data) -{ -"""); - -for symbol in regs['handoff_reg']: - if registertype == "plugin" or registertype == "plugin_wtap": - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - else: - line = " {extern void %s (void); if(cb) (*cb)(RA_HANDOFF, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol) - reg_code.write(line) - -reg_code.write("}\n") - -if registertype == "plugin": - reg_code.write("#endif\n"); -elif registertype == "plugin_wtap": - reg_code.write(""" -G_MODULE_EXPORT void -register_wtap_module(void) -{ -"""); - - for symbol in regs['wtap_register']: - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - reg_code.write(line) - - reg_code.write("}\n"); - reg_code.write("#endif\n"); -else: - reg_code.write(""" -static gulong proto_reg_count(void) -{ -"""); - - line = " return %d;\n" % len(regs['proto_reg']) - reg_code.write(line) - - reg_code.write(""" -} -"""); - reg_code.write(""" -static gulong handoff_reg_count(void) -{ -"""); - - line = " return %d;\n" % len(regs['handoff_reg']) - reg_code.write(line) - - reg_code.write(""" -} -"""); - reg_code.write(""" -gulong register_count(void) -{ -"""); - - line = " return proto_reg_count() + handoff_reg_count();" - reg_code.write(line) - - reg_code.write(""" -}\n -"""); - - -# Close the file -reg_code.close() - -# Remove the old final_file if it exists. -try: - os.stat(final_filename) - os.remove(final_filename) -except OSError: - pass - -# Move from tmp file to final file -os.rename(tmp_filename, final_filename) - - diff --git a/tools/chdr-dissector/moduleinfo.h b/tools/chdr-dissector/moduleinfo.h deleted file mode 100644 index d8f0570c7..000000000 --- a/tools/chdr-dissector/moduleinfo.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef PACKAGE -#undef PACKAGE -#endif -#define PACKAGE "chdr" -#ifdef VERSION -#undef VERSION -#endif -#define VERSION "0.0.0.1" - diff --git a/tools/chdr-dissector/packet-chdr.c b/tools/chdr-dissector/packet-chdr.c deleted file mode 100644 index 079e6bb3b..000000000 --- a/tools/chdr-dissector/packet-chdr.c +++ /dev/null @@ -1,472 +0,0 @@ -/* - * Dissector for UHD CVITA (CHDR) packets - * - * Copyright 2010-2014 Ettus Research LLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -#include "config.h" - -#include <glib.h> -#include <epan/packet.h> -#include <ctype.h> -#include <stdio.h> - -#include "../../host/lib/usrp/x300/x300_fw_common.h" - -#define LOG_HEADER "[UHD CHDR] " - -#ifndef min -#define min(a,b) ((a<b)?a:b) -#endif // min - -const unsigned int CHDR_PORT = X300_VITA_UDP_PORT; - -static int proto_chdr = -1; -static int hf_chdr_hdr = -1; -static int hf_chdr_type = -1; -static int hf_chdr_has_time = -1; -static int hf_chdr_eob = -1; -static int hf_chdr_error = -1; -static int hf_chdr_sequence = -1; -static int hf_chdr_packet_size = -1; -static int hf_chdr_stream_id = -1; -static int hf_chdr_src_dev = -1; -static int hf_chdr_src_ep = -1; -static int hf_chdr_src_blockport = -1; -static int hf_chdr_dst_dev = -1; -static int hf_chdr_dst_ep = -1; -static int hf_chdr_dst_blockport = -1; -static int hf_chdr_timestamp = -1; -static int hf_chdr_payload = -1; -static int hf_chdr_ext_response = -1; -static int hf_chdr_ext_status_code = -1; -static int hf_chdr_ext_seq_num = -1; -static int hf_chdr_cmd = -1; -static int hf_chdr_cmd_address = -1; -static int hf_chdr_cmd_value = -1; - -static const value_string CHDR_PACKET_TYPES[] = { - { 0, "Data" }, - { 1, "Data (End-of-Burst)" }, - { 4, "Flow Control" }, - { 8, "Command" }, - { 12, "Response" }, - { 13, "Error Response" }, -}; - -static const value_string CHDR_PACKET_TYPES_SHORT[] = { - { 0, "data" }, - { 1, "data" }, - { 4, "fc" }, - { 8, "cmd" }, - { 12, "resp" }, - { 13, "resp" }, -}; - -/* the heuristic dissector is called on every packet with payload. - * The warning printed for this should only be printed once. - */ -static int heur_warning_printed = 0; - -/* Subtree handles: set by register_subtree_array */ -static gint ett_chdr = -1; -static gint ett_chdr_header = -1; -static gint ett_chdr_id = -1; -static gint ett_chdr_response = -1; -static gint ett_chdr_cmd = -1; - -/* Forward-declare the dissector functions */ -void proto_register_chdr(void); -void proto_reg_handoff_chdr(void); -static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); - -/* heuristic dissector call. Will always return. */ -static gboolean heur_dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* whatislove) -{ - if(heur_warning_printed < 1){ - printf(LOG_HEADER"heuristic dissector always returns true!\n"); - heur_warning_printed++; - } - dissect_chdr(tvb, pinfo, tree); - return (TRUE); -} - -static void byte_swap(guint8 *bytes, gint len) -{ - guint8 tmp[4]; - - if(len != sizeof(tmp)){ - printf(LOG_HEADER"FATAL! number of bytes don't match 32 bit!\n"); - return; - } - - memcpy(tmp, bytes, sizeof(tmp)); - bytes[0] = tmp[3]; - bytes[1] = tmp[2]; - bytes[2] = tmp[1]; - bytes[3] = tmp[0]; -} - -static unsigned long long get_timestamp(guint8 *bytes, gint len) -{ - unsigned long long ts; - unsigned long long trans; - int it; - - if(len != sizeof(unsigned long long)){ - printf(LOG_HEADER"FATAL! timestamps always consist of 64 bits!\n"); - } - - byte_swap(bytes + 0, 4); - byte_swap(bytes + 4, 4); - - ts = 0; - for(it = 0; it < 8; it++){ - ts = ts << 8; - trans = (guint64) bytes[it]; - ts = ts | trans; - } - - return (ts); -} - -/* The dissector itself */ -static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) -{ - // Here are all the variables - proto_item *item; - proto_item *stream_item; - proto_tree *chdr_tree; - proto_item *header_item; - proto_tree *header_tree; - proto_tree *stream_tree; - proto_item *response_item; - proto_tree *response_tree; - proto_item *cmd_item; - proto_tree *cmd_tree; - gint len; - - gint flag_offset; - guint8 *bytes; - guint8 hdr_bits = 0; - guint8 pkt_type = 0; - gboolean flag_has_time = 0; - gboolean flag_is_data = 0; - gboolean flag_is_fc = 0; - gboolean flag_is_cmd = 0; - gboolean flag_is_resp = 0; - gboolean flag_is_eob = 0; - gboolean flag_is_error = 0; - unsigned long long timestamp; - gboolean is_network; - gint endianness; - gint id_pos_usb[4] = {7, 6, 5, 4}; - gint id_pos_net[4] = {4, 5, 6, 7}; - gint id_pos[4] = {7, 6, 5, 4}; - - if(pinfo->match_uint == CHDR_PORT){ - is_network = TRUE; - flag_offset = 0; - endianness = ENC_BIG_ENDIAN; - memcpy(id_pos, id_pos_net, 4 * sizeof(gint)); - } - else{ // Parsing a USB capture - is_network = FALSE; - flag_offset = 3; - endianness = ENC_LITTLE_ENDIAN; - memcpy(id_pos, id_pos_usb, 4 * sizeof(gint)); - } - - len = tvb_reported_length(tvb); - - col_append_str(pinfo->cinfo, COL_PROTOCOL, "/CHDR"); - /* This throws a warning: */ - /*col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR", tvb_format_text_wsp(tvb, 0, len));*/ - col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR"); - - if (tree){ - int chdr_size = -1; - - if (len >= 4){ - chdr_size = 8; - bytes = tvb_get_string(wmem_packet_scope(), tvb, 0, 4); - hdr_bits = (bytes[flag_offset] & 0xF0) >> 4; - pkt_type = hdr_bits >> 2; - flag_is_data = (pkt_type == 0); - flag_is_fc = (pkt_type == 1); - flag_is_cmd = (pkt_type == 2); - flag_is_resp = (pkt_type == 3); - flag_is_eob = flag_is_data && (hdr_bits & 0x1); - flag_is_error = flag_is_resp && (hdr_bits & 0x1); - flag_has_time = hdr_bits & 0x2; - if (flag_has_time) - chdr_size += 8; // 64-bit timestamp - } - - /* Start with a top-level item to add everything else to */ - item = proto_tree_add_item(tree, proto_chdr, tvb, 0, min(len, chdr_size), ENC_NA); - - if (len >= 4) { - chdr_tree = proto_item_add_subtree(item, ett_chdr); - - /* Header info. First, a top-level header tree item: */ - header_item = proto_tree_add_item(chdr_tree, hf_chdr_hdr, tvb, flag_offset, 1, endianness); - header_tree = proto_item_add_subtree(header_item, ett_chdr_header); - proto_item_append_text(header_item, ", Packet type: %s", - val_to_str(hdr_bits & 0xD, CHDR_PACKET_TYPES, "Unknown (0x%x)") - ); - /* Let us query hdr.type */ - proto_tree_add_string( - header_tree, hf_chdr_type, tvb, flag_offset, 1, - val_to_str(hdr_bits & 0xD, CHDR_PACKET_TYPES_SHORT, "invalid") - ); - /* And other flags */ - proto_tree_add_boolean(header_tree, hf_chdr_has_time, tvb, flag_offset, 1, flag_has_time); - if (flag_is_data) { - proto_tree_add_boolean(header_tree, hf_chdr_eob, tvb, flag_offset, 1, flag_is_eob); - } - if (flag_is_resp) { - proto_tree_add_boolean(header_tree, hf_chdr_error, tvb, flag_offset, 1, flag_is_error); - } - - /* These lines add sequence, packet_size and stream ID */ - proto_tree_add_item(chdr_tree, hf_chdr_sequence, tvb, (is_network ? 0:2), 2, endianness); - proto_tree_add_item(chdr_tree, hf_chdr_packet_size, tvb, (is_network ? 2:0), 2, endianness); - - if (len >= 8){ - /* stream id can be broken down to 4 sections. these are collapsed in a subtree */ - stream_item = proto_tree_add_item(chdr_tree, hf_chdr_stream_id, tvb, 4, 4, endianness); - stream_tree = proto_item_add_subtree(stream_item, ett_chdr_id); - proto_tree_add_item(stream_tree, hf_chdr_src_dev, tvb, id_pos[0], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_src_ep, tvb, id_pos[1], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_dst_dev, tvb, id_pos[2], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_dst_ep, tvb, id_pos[3], 1, ENC_NA); - - /* Block ports (only add them if address points to a device) */ - bytes = tvb_get_string(wmem_packet_scope(), tvb, 0, 8); - if (bytes[id_pos[0]] != 0) { - proto_tree_add_item(stream_tree, hf_chdr_src_blockport, tvb, id_pos[1], 1, ENC_NA); - } - if (bytes[id_pos[2]] != 0) { - proto_tree_add_item(stream_tree, hf_chdr_dst_blockport, tvb, id_pos[3], 1, ENC_NA); - } - - /* Append SID in sid_t hex format */ - proto_item_append_text(stream_item, " (%02X:%02X>%02X:%02X)", - bytes[id_pos[0]], - bytes[id_pos[1]], - bytes[id_pos[2]], - bytes[id_pos[3]] - ); - - /* if has_time flag is present interpret timestamp */ - if ((flag_has_time) && (len >= 16)){ - if (is_network) - item = proto_tree_add_item(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, endianness); - else{ - bytes = (guint8*) tvb_get_string(wmem_packet_scope(), tvb, 8, sizeof(unsigned long long)); - timestamp = get_timestamp(bytes, sizeof(unsigned long long)); - proto_tree_add_uint64(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, timestamp); - } - } - - int remaining_bytes = (len - chdr_size); - int show_raw_payload = (remaining_bytes > 0); - - if (flag_is_cmd && remaining_bytes == 8) { - cmd_item = proto_tree_add_item(chdr_tree, hf_chdr_cmd, tvb, chdr_size, 8, endianness); - cmd_tree = proto_item_add_subtree(cmd_item, ett_chdr_cmd); - proto_tree_add_item(cmd_tree, hf_chdr_cmd_address, tvb, chdr_size, 4, endianness); - proto_tree_add_item(cmd_tree, hf_chdr_cmd_value, tvb, chdr_size + 4, 4, endianness); - } else if (flag_is_resp) { - response_item = proto_tree_add_item(chdr_tree, hf_chdr_ext_response, tvb, chdr_size, 8, endianness); - response_tree = proto_item_add_subtree(response_item, ett_chdr_response); - - proto_tree_add_item(response_tree, hf_chdr_ext_status_code, tvb, chdr_size, 4, endianness); - /* This will show the 12-bits of sequence ID in the last 2 bytes */ - proto_tree_add_item(response_tree, hf_chdr_ext_seq_num, tvb, (chdr_size + 4 + (is_network ? 2 : 0)), 2, endianness); - } else if (show_raw_payload) { - proto_tree_add_item(chdr_tree, hf_chdr_payload, tvb, chdr_size, -1, ENC_NA); - } - } - } - } -} - -void proto_register_chdr(void) -{ - static hf_register_info hf[] = { - { &hf_chdr_hdr, - { "Header bits", "chdr.hdr", - FT_UINT8, BASE_HEX, - NULL, 0xF0, - NULL, HFILL } - }, - { &hf_chdr_type, - { "Packet Type", "chdr.hdr.type", - FT_STRINGZ, BASE_NONE, - NULL, 0x00, - "Packet Type", HFILL } - }, - { &hf_chdr_has_time, - { "Time present", "chdr.hdr.has_time", - FT_BOOLEAN, BASE_NONE, - NULL, 0x20, - NULL, HFILL } - }, - { &hf_chdr_eob, - { "End Of Burst", "chdr.hdr.eob", - FT_BOOLEAN, BASE_NONE, - NULL, 0x10, - NULL, HFILL } - }, - { &hf_chdr_error, - { "Error Flag", "chdr.hdr.error", - FT_BOOLEAN, BASE_NONE, - NULL, 0x10, - NULL, HFILL } - }, - { &hf_chdr_sequence, - { "Sequence ID", "chdr.seq", - FT_UINT16, BASE_DEC, - NULL, 0x0FFF, - NULL, HFILL } - }, - { &hf_chdr_packet_size, - { "Packet size", "chdr.size", - FT_UINT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_stream_id, - { "Stream ID", "chdr.sid", - FT_IPv4, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_src_dev, - { "Source device", "chdr.src_dev", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_src_ep, - { "Source endpoint", "chdr.src_ep", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_src_blockport, - { "Source block port", "chdr.src_bp", - FT_UINT8, BASE_DEC, - NULL, 0xF, - NULL, HFILL } - }, - { &hf_chdr_dst_dev, - { "Destination device", "chdr.dst_dev", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_dst_ep, - { "Destination endpoint", "chdr.dst_ep", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_dst_blockport, - { "Destination block port", "chdr.dst_bp", - FT_UINT8, BASE_DEC, - NULL, 0xF, - NULL, HFILL } - }, - { &hf_chdr_timestamp, - { "Time", "chdr.time", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_payload, - { "Payload", "chdr.payload", - FT_BYTES, BASE_NONE, - NULL, 0x0, - NULL, HFILL - } - }, - { &hf_chdr_ext_response, - { "Response", "chdr.res", - FT_BYTES, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_ext_status_code, - { "Status code", "chdr.res.status", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_ext_seq_num, - { "Response to sequence ID", "chdr.res.seq", - FT_UINT16, BASE_DEC, - NULL, 0x0FFF, - NULL, HFILL } - }, - { &hf_chdr_cmd, - { "Command", "chdr.cmd", - FT_BYTES, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_cmd_address, - { "Register Address", "chdr.cmd.addr", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_cmd_value, - { "Command Value", "chdr.cmd.val", - FT_UINT32, BASE_HEX, - NULL, 0x0, - NULL, HFILL } - }, - }; - - static gint *ett[] = { - &ett_chdr, - &ett_chdr_header, - &ett_chdr_id, - &ett_chdr_response, - &ett_chdr_cmd - }; - - proto_chdr = proto_register_protocol("UHD CHDR", "CHDR", "chdr"); - proto_register_field_array(proto_chdr, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); - register_dissector("chdr", dissect_chdr, proto_chdr); -} - -/* Handler registration */ -void proto_reg_handoff_chdr(void) -{ - /* register heuristic dissector for use with USB */ - heur_dissector_add("usb.bulk", heur_dissect_chdr, proto_chdr); - - /* register dissector for UDP packets */ - static dissector_handle_t chdr_handle; - chdr_handle = create_dissector_handle(dissect_chdr, proto_chdr); - dissector_add_uint("udp.port", CHDR_PORT, chdr_handle); -} diff --git a/tools/chdr-dissector/plugin.rc.in b/tools/chdr-dissector/plugin.rc.in deleted file mode 100644 index f9d714704..000000000 --- a/tools/chdr-dissector/plugin.rc.in +++ /dev/null @@ -1,34 +0,0 @@ -#include "winver.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION @RC_MODULE_VERSION@ - PRODUCTVERSION @RC_VERSION@ - FILEFLAGSMASK 0x0L -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0 -#endif - FILEOS VOS_NT_WINDOWS32 - FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Ettus Research LLC\0" - VALUE "FileDescription", "@PACKAGE@ dissector\0" - VALUE "FileVersion", "@MODULE_VERSION@\0" - VALUE "InternalName", "@PACKAGE@ @MODULE_VERSION@\0" - VALUE "LegalCopyright", "Copyright � 2013 Ettus Research LLC\0" - VALUE "OriginalFilename", "@PLUGIN_NAME@.dll\0" - VALUE "ProductName", "Wireshark\0" - VALUE "ProductVersion", "@VERSION@\0" - VALUE "Comments", "Build with @MSVC_VARIANT@\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/tools/dissectors/.gitignore b/tools/dissectors/.gitignore new file mode 100644 index 000000000..257f20c8c --- /dev/null +++ b/tools/dissectors/.gitignore @@ -0,0 +1,2 @@ +build +moduleinfo.h diff --git a/tools/dissectors/CMakeLists.txt b/tools/dissectors/CMakeLists.txt new file mode 100644 index 000000000..9f63a356a --- /dev/null +++ b/tools/dissectors/CMakeLists.txt @@ -0,0 +1,106 @@ +# Copyright 2010-2013 Ettus Research LLC +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + + +######################################################################## +# Project setup +######################################################################## +cmake_minimum_required(VERSION 2.8) +project(ettus-dissector C) +enable_testing() + +#select the release build type by default to get optimization flags +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") + message(STATUS "Build type not specified: defaulting to release.") +endif(NOT CMAKE_BUILD_TYPE) +set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) + +######################################################################## +# Compiler specific setup +######################################################################## +#if(CMAKE_COMPILER_IS_GNUC AND NOT WIN32) +# #http://gcc.gnu.org/wiki/Visibility +# add_definitions(-fvisibility=visible) +#endif() + +find_package(GLIB2) +if(NOT GLIB2_FOUND) + message(FATAL_ERROR "Glib not found") +endif() + +find_package(Wireshark) +if(NOT WIRESHARK_FOUND) + message(FATAL_ERROR "Wireshark dev package not found") +endif() + + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${GLIB2_INCLUDE_DIRS} + ${WIRESHARK_INCLUDE_DIRS} +) + +set(CMAKE_INSTALL_LIBDIR ~/.wireshark) + +# Set component parameters +set(ETTUS_DISSECTOR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR} CACHE INTERNAL "" FORCE) +set(ETTUS_DISSECTOR_NAME "chdr" CACHE STRING "Select a dissector to build") + +function(generate_ettus_dissector DISSECTOR_NAME) + + set(ETTUS_PLUGIN_SRC ${CMAKE_SOURCE_DIR}/packet-${DISSECTOR_NAME}.c) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/moduleinfo.h.in + ${CMAKE_BINARY_DIR}/moduleinfo.h + ) + + set(PLUGIN_C_GENERATOR ${CMAKE_SOURCE_DIR}/make-dissector-reg.py) + set(PLUGIN_C plugin.c) + + add_custom_command( + OUTPUT ${PLUGIN_C} + DEPENDS ${ETTUS_PLUGIN_SRC} + COMMAND ${PLUGIN_C_GENERATOR} ${CMAKE_SOURCE_DIR} plugin ${ETTUS_PLUGIN_SRC} + COMMENT "Generating ${PLUGIN_C}" + ) + + set(ETTUS_TARGET_NAME "${DISSECTOR_NAME}-plugin") + add_library(${ETTUS_TARGET_NAME} MODULE + ${PLUGIN_C} + moduleinfo.h + ${ETTUS_PLUGIN_SRC} + ) + set_target_properties(${ETTUS_TARGET_NAME} PROPERTIES PREFIX "") + set_target_properties(${ETTUS_TARGET_NAME} PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") + target_link_libraries(${ETTUS_TARGET_NAME} wireshark) + + install(TARGETS ${ETTUS_TARGET_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugins NAMELINK_SKIP + ) + +endfunction(generate_ettus_dissector) + +generate_ettus_dissector("${ETTUS_DISSECTOR_NAME}") + diff --git a/tools/dissectors/cmake/Modules/FindGLIB2.cmake b/tools/dissectors/cmake/Modules/FindGLIB2.cmake new file mode 100644 index 000000000..ae7baddbb --- /dev/null +++ b/tools/dissectors/cmake/Modules/FindGLIB2.cmake @@ -0,0 +1,238 @@ +# +# $Id: FindGLIB2.cmake 34248 2010-09-25 15:38:12Z jmayer $ +# +# - Try to find GLib2 +# Once done this will define +# +# GLIB2_FOUND - system has GLib2 +# GLIB2_INCLUDE_DIRS - the GLib2 include directory +# GLIB2_LIBRARIES - Link these to use GLib2 +# +# HAVE_GLIB_GREGEX_H glib has gregex.h header and +# supports g_regex_match_simple +# +# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org> +# Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com> +# Copyright (c) 2007 Daniel Gollub <gollub@b1-systems.de> +# Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com> +# Copyright (c) 2008 Michael Bell <michael.bell@web.de> +# Copyright (c) 2008-2009 Bjoern Ricks <bjoern.ricks@googlemail.com> +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + + +IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) + # in cache already + SET(GLIB2_FOUND TRUE) +ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) + + INCLUDE(FindPkgConfig) + + ## Glib + IF ( GLIB2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "REQUIRED" ) + ELSE ( GLIB2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "" ) + ENDIF ( GLIB2_FIND_REQUIRED ) + + IF ( GLIB2_MIN_VERSION ) + PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) + ELSE ( GLIB2_MIN_VERSION ) + PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) + ENDIF ( GLIB2_MIN_VERSION ) + IF ( PKG_CONFIG_FOUND ) + IF ( GLIB2_FOUND ) + SET ( GLIB2_CORE_FOUND TRUE ) + ELSE ( GLIB2_FOUND ) + SET ( GLIB2_CORE_FOUND FALSE ) + ENDIF ( GLIB2_FOUND ) + ENDIF ( PKG_CONFIG_FOUND ) + + # Look for glib2 include dir and libraries w/o pkgconfig + IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) + FIND_PATH( + _glibconfig_include_DIR + NAMES + glibconfig.h + PATHS + /opt/gnome/lib64 + /opt/gnome/lib + /opt/lib/ + /opt/local/lib + /sw/lib/ + /usr/lib64 + /usr/lib + /usr/local/include + ${CMAKE_LIBRARY_PATH} + PATH_SUFFIXES + glib-2.0/include + ) + + FIND_PATH( + _glib2_include_DIR + NAMES + glib.h + PATHS + /opt/gnome/include + /opt/local/include + /sw/include + /usr/include + /usr/local/include + PATH_SUFFIXES + glib-2.0 + ) + + #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") + + FIND_LIBRARY( + _glib2_link_DIR + NAMES + glib-2.0 + glib + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/lib + /usr/local/lib + ) + IF ( _glib2_include_DIR AND _glib2_link_DIR ) + SET ( _glib2_FOUND TRUE ) + ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) + + + IF ( _glib2_FOUND ) + SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) + SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) + SET ( GLIB2_CORE_FOUND TRUE ) + ELSE ( _glib2_FOUND ) + SET ( GLIB2_CORE_FOUND FALSE ) + ENDIF ( _glib2_FOUND ) + + # Handle dependencies + # libintl + IF ( NOT LIBINTL_FOUND ) + FIND_PATH(LIBINTL_INCLUDE_DIR + NAMES + libintl.h + PATHS + /opt/gnome/include + /opt/local/include + /sw/include + /usr/include + /usr/local/include + ) + + FIND_LIBRARY(LIBINTL_LIBRARY + NAMES + intl + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/local/lib + /usr/lib + ) + + IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) + SET (LIBINTL_FOUND TRUE) + ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) + ENDIF ( NOT LIBINTL_FOUND ) + + # libiconv + IF ( NOT LIBICONV_FOUND ) + FIND_PATH(LIBICONV_INCLUDE_DIR + NAMES + iconv.h + PATHS + /opt/gnome/include + /opt/local/include + /opt/local/include + /sw/include + /sw/include + /usr/local/include + /usr/include + PATH_SUFFIXES + glib-2.0 + ) + + FIND_LIBRARY(LIBICONV_LIBRARY + NAMES + iconv + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/lib + /usr/local/lib + ) + + IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) + SET (LIBICONV_FOUND TRUE) + ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) + ENDIF ( NOT LIBICONV_FOUND ) + + IF (LIBINTL_FOUND) + SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) + SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) + ENDIF (LIBINTL_FOUND) + + IF (LIBICONV_FOUND) + SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) + SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) + ENDIF (LIBICONV_FOUND) + + ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) + ## + + IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) + SET (GLIB2_FOUND TRUE) + ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) + + IF (GLIB2_FOUND) + IF (NOT GLIB2_FIND_QUIETLY) + MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") + ENDIF (NOT GLIB2_FIND_QUIETLY) + ELSE (GLIB2_FOUND) + IF (GLIB2_FIND_REQUIRED) + MESSAGE (SEND_ERROR "Could not find GLib2") + ENDIF (GLIB2_FIND_REQUIRED) + ENDIF (GLIB2_FOUND) + + # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view + MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) + MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) + MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) + +ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) + +IF ( WIN32 ) + # include libiconv for win32 + IF ( NOT LIBICONV_FOUND ) + FIND_PATH(LIBICONV_INCLUDE_DIR iconv.h PATH_SUFFIXES glib-2.0) + + FIND_LIBRARY(LIBICONV_LIBRARY NAMES iconv) + + IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) + SET (LIBICONV_FOUND TRUE) + ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) + ENDIF ( NOT LIBICONV_FOUND ) + IF (LIBICONV_FOUND) + SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) + SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) + ENDIF (LIBICONV_FOUND) +ENDIF ( WIN32 ) + +IF ( GLIB2_FOUND ) + # Check if system has a newer version of glib + # which supports g_regex_match_simple + INCLUDE( CheckIncludeFiles ) + SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) + CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) + CHECK_INCLUDE_FILES ( glib/gchecksum.h HAVE_GLIB_GCHECKSUM_H ) + # Reset CMAKE_REQUIRED_INCLUDES + SET( CMAKE_REQUIRED_INCLUDES "" ) +ENDIF( GLIB2_FOUND ) diff --git a/tools/dissectors/cmake/Modules/FindWireshark.cmake b/tools/dissectors/cmake/Modules/FindWireshark.cmake new file mode 100644 index 000000000..276201245 --- /dev/null +++ b/tools/dissectors/cmake/Modules/FindWireshark.cmake @@ -0,0 +1,28 @@ +# +# Try to find the wireshark library and its includes +# +# This snippet sets the following variables: +# WIRESHARK_FOUND True if wireshark library got found +# WIRESHARK_INCLUDE_DIRS Location of the wireshark headers +# WIRESHARK_LIBRARIES List of libraries to use wireshark +# +# Copyright (c) 2011 Reinhold Kainhofer <reinhold@kainhofer.com> +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +# wireshark does not install its library with pkg-config information, +# so we need to manually find the libraries and headers + +FIND_PATH( WIRESHARK_INCLUDE_DIRS epan/column.h PATH_SUFFIXES wireshark ) +FIND_LIBRARY( WIRESHARK_LIBRARIES wireshark ) + +# Report results +IF ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) + SET( WIRESHARK_FOUND 1 ) +ELSE ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) + MESSAGE( SEND_ERROR "Could NOT find the wireshark library and headers" ) +ENDIF ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) + diff --git a/tools/dissectors/make-dissector-reg.py b/tools/dissectors/make-dissector-reg.py new file mode 100755 index 000000000..44972909b --- /dev/null +++ b/tools/dissectors/make-dissector-reg.py @@ -0,0 +1,305 @@ +#!/usr/bin/env python +# +# Looks for registration routines in the protocol dissectors, +# and assembles C code to call all the routines. +# +# This is a Python version of the make-reg-dotc shell script. +# Running the shell script on Win32 is very very slow because of +# all the process-launching that goes on --- multiple greps and +# seds for each input file. I wrote this python version so that +# less processes would have to be started. +# +# $Id: make-dissector-reg.py 30447 2009-10-09 20:47:18Z krj $ + +import os +import sys +import re +import pickle +from stat import * + +VERSION_KEY = '_VERSION' +CUR_VERSION = '$Id: make-dissector-reg.py 30447 2009-10-09 20:47:18Z krj $' + +# +# The first argument is the directory in which the source files live. +# +srcdir = sys.argv[1] + +# +# The second argument is either "plugin" or "dissectors"; if it's +# "plugin", we build a plugin.c for a plugin, and if it's +# "dissectors", we build a register.c for libwireshark. +# +registertype = sys.argv[2] +if registertype == "plugin" or registertype == "plugin_wtap": + tmp_filename = "plugin.c-tmp" + final_filename = "plugin.c" + cache_filename = None + preamble = """\ +/* + * Do not modify this file. + * + * It is created automatically by Makefile or Makefile.nmake. + */ +""" +elif registertype == "dissectors": + tmp_filename = "register.c-tmp" + final_filename = "register.c" + cache_filename = "register-cache.pkl" + preamble = """\ +/* + * Do not modify this file. + * + * It is created automatically by the "register.c" target in + * epan/dissectors/Makefile or Makefile.nmake using information in + * epan/dissectors/register-cache.pkl. + * + * You can force this file to be regenerated completely by deleting + * it along with epan/dissectors/register-cache.pkl. + */ +""" +else: + print "Unknown output type '%s'" % registertype + sys.exit(1) + + +# +# All subsequent arguments are the files to scan. +# +files = sys.argv[3:] + +# Create the proper list of filenames +filenames = [] +for file in files: + if os.path.isfile(file): + filenames.append(file) + else: + filenames.append(os.path.join(srcdir, file)) + +if len(filenames) < 1: + print "No files found" + sys.exit(1) + + +# Look through all files, applying the regex to each line. +# If the pattern matches, save the "symbol" section to the +# appropriate array. +regs = { + 'proto_reg': [], + 'handoff_reg': [], + 'wtap_register': [], + } + +# For those that don't know Python, r"" indicates a raw string, +# devoid of Python escapes. +proto_regex0 = r"^(?P<symbol>proto_register_[_A-Za-z0-9]+)\s*\([^;]+$" +proto_regex1 = r"void\s+(?P<symbol>proto_register_[_A-Za-z0-9]+)\s*\([^;]+$" + +handoff_regex0 = r"^(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" +handoff_regex1 = r"void\s+(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" + +wtap_reg_regex0 = r"^(?P<symbol>wtap_register_[_A-Za-z0-9]+)\s*\([^;]+$" +wtap_reg_regex1 = r"void\s+(?P<symbol>wtap_register_[_A-Za-z0-9]+)\s*\([^;]+$" + +# This table drives the pattern-matching and symbol-harvesting +patterns = [ + ( 'proto_reg', re.compile(proto_regex0) ), + ( 'proto_reg', re.compile(proto_regex1) ), + ( 'handoff_reg', re.compile(handoff_regex0) ), + ( 'handoff_reg', re.compile(handoff_regex1) ), + ( 'wtap_register', re.compile(wtap_reg_regex0) ), + ( 'wtap_register', re.compile(wtap_reg_regex1) ), + ] + +# Open our registration symbol cache +cache = None +if cache_filename: + try: + cache_file = open(cache_filename, 'rb') + cache = pickle.load(cache_file) + cache_file.close() + if not cache.has_key(VERSION_KEY) or cache[VERSION_KEY] != CUR_VERSION: + cache = {VERSION_KEY: CUR_VERSION} + except: + cache = {VERSION_KEY: CUR_VERSION} + +# Grep +for filename in filenames: + file = open(filename) + cur_mtime = os.fstat(file.fileno())[ST_MTIME] + if cache and cache.has_key(filename): + cdict = cache[filename] + if cur_mtime == cdict['mtime']: +# print "Pulling %s from cache" % (filename) + regs['proto_reg'].extend(cdict['proto_reg']) + regs['handoff_reg'].extend(cdict['handoff_reg']) + regs['wtap_register'].extend(cdict['wtap_register']) + file.close() + continue + # We don't have a cache entry + if cache is not None: + cache[filename] = { + 'mtime': cur_mtime, + 'proto_reg': [], + 'handoff_reg': [], + 'wtap_register': [], + } +# print "Searching %s" % (filename) + for line in file.readlines(): + for action in patterns: + regex = action[1] + match = regex.search(line) + if match: + symbol = match.group("symbol") + sym_type = action[0] + regs[sym_type].append(symbol) + if cache is not None: +# print "Caching %s for %s: %s" % (sym_type, filename, symbol) + cache[filename][sym_type].append(symbol) + file.close() + +if cache is not None and cache_filename is not None: + cache_file = open(cache_filename, 'wb') + pickle.dump(cache, cache_file) + cache_file.close() + +# Make sure we actually processed something +if len(regs['proto_reg']) < 1: + print "No protocol registrations found" + sys.exit(1) + +# Sort the lists to make them pretty +regs['proto_reg'].sort() +regs['handoff_reg'].sort() +regs['wtap_register'].sort() + +reg_code = open(tmp_filename, "w") + +reg_code.write(preamble) + +# Make the routine to register all protocols +if registertype == "plugin" or registertype == "plugin_wtap": + reg_code.write(""" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <gmodule.h> + +#include "moduleinfo.h" + +#ifndef ENABLE_STATIC +G_MODULE_EXPORT const gchar version[] = VERSION; + +/* Start the functions we need for the plugin stuff */ + +G_MODULE_EXPORT void +plugin_register (void) +{ +"""); +else: + reg_code.write(""" +#include "register.h" +void +register_all_protocols(register_cb cb, gpointer client_data) +{ +"""); + +for symbol in regs['proto_reg']: + if registertype == "plugin" or registertype == "plugin_wtap": + line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) + else: + line = " {extern void %s (void); if(cb) (*cb)(RA_REGISTER, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol) + reg_code.write(line) + +reg_code.write("}\n") + + +# Make the routine to register all protocol handoffs +if registertype == "plugin" or registertype == "plugin_wtap": + reg_code.write(""" +G_MODULE_EXPORT void +plugin_reg_handoff(void) +{ +"""); +else: + reg_code.write(""" +void +register_all_protocol_handoffs(register_cb cb, gpointer client_data) +{ +"""); + +for symbol in regs['handoff_reg']: + if registertype == "plugin" or registertype == "plugin_wtap": + line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) + else: + line = " {extern void %s (void); if(cb) (*cb)(RA_HANDOFF, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol) + reg_code.write(line) + +reg_code.write("}\n") + +if registertype == "plugin": + reg_code.write("#endif\n"); +elif registertype == "plugin_wtap": + reg_code.write(""" +G_MODULE_EXPORT void +register_wtap_module(void) +{ +"""); + + for symbol in regs['wtap_register']: + line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) + reg_code.write(line) + + reg_code.write("}\n"); + reg_code.write("#endif\n"); +else: + reg_code.write(""" +static gulong proto_reg_count(void) +{ +"""); + + line = " return %d;\n" % len(regs['proto_reg']) + reg_code.write(line) + + reg_code.write(""" +} +"""); + reg_code.write(""" +static gulong handoff_reg_count(void) +{ +"""); + + line = " return %d;\n" % len(regs['handoff_reg']) + reg_code.write(line) + + reg_code.write(""" +} +"""); + reg_code.write(""" +gulong register_count(void) +{ +"""); + + line = " return proto_reg_count() + handoff_reg_count();" + reg_code.write(line) + + reg_code.write(""" +}\n +"""); + + +# Close the file +reg_code.close() + +# Remove the old final_file if it exists. +try: + os.stat(final_filename) + os.remove(final_filename) +except OSError: + pass + +# Move from tmp file to final file +os.rename(tmp_filename, final_filename) + + diff --git a/tools/dissectors/moduleinfo.h.in b/tools/dissectors/moduleinfo.h.in new file mode 100644 index 000000000..7910c56a3 --- /dev/null +++ b/tools/dissectors/moduleinfo.h.in @@ -0,0 +1,10 @@ +#ifdef PACKAGE +#undef PACKAGE +#endif +#define PACKAGE "@ETTUS_DISSECTOR_NAME@" + +#ifdef VERSION +#undef VERSION +#endif +#define VERSION "0.0.0.2" + diff --git a/tools/dissectors/packet-chdr.c b/tools/dissectors/packet-chdr.c new file mode 100644 index 000000000..ba85a016f --- /dev/null +++ b/tools/dissectors/packet-chdr.c @@ -0,0 +1,477 @@ +/* + * Dissector for UHD CVITA (CHDR) packets + * + * Copyright 2010-2014 Ettus Research LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "config.h" + +#include <glib.h> +#include <epan/packet.h> +#include <ctype.h> +#include <stdio.h> + +#include "../../host/lib/usrp/x300/x300_fw_common.h" + +#define LOG_HEADER "[UHD CHDR] " + +#ifndef min +#define min(a,b) ((a<b)?a:b) +#endif // min + +const unsigned int CHDR_PORT = X300_VITA_UDP_PORT; + +static int proto_chdr = -1; +static int hf_chdr_hdr = -1; +static int hf_chdr_type = -1; +static int hf_chdr_has_time = -1; +static int hf_chdr_eob = -1; +static int hf_chdr_error = -1; +static int hf_chdr_sequence = -1; +static int hf_chdr_packet_size = -1; +static int hf_chdr_stream_id = -1; +static int hf_chdr_src_dev = -1; +static int hf_chdr_src_ep = -1; +static int hf_chdr_src_blockport = -1; +static int hf_chdr_dst_dev = -1; +static int hf_chdr_dst_ep = -1; +static int hf_chdr_dst_blockport = -1; +static int hf_chdr_timestamp = -1; +static int hf_chdr_payload = -1; +static int hf_chdr_ext_response = -1; +static int hf_chdr_ext_status_code = -1; +static int hf_chdr_ext_seq_num = -1; +static int hf_chdr_cmd = -1; +static int hf_chdr_cmd_address = -1; +static int hf_chdr_cmd_value = -1; + +static const value_string CHDR_PACKET_TYPES[] = { + { 0, "Data" }, + { 1, "Data (End-of-Burst)" }, + { 4, "Flow Control" }, + { 8, "Command" }, + { 12, "Response" }, + { 13, "Error Response" }, +}; + +static const value_string CHDR_PACKET_TYPES_SHORT[] = { + { 0, "data" }, + { 1, "data" }, + { 4, "fc" }, + { 8, "cmd" }, + { 12, "resp" }, + { 13, "resp" }, +}; + +/* the heuristic dissector is called on every packet with payload. + * The warning printed for this should only be printed once. + */ +static int heur_warning_printed = 0; + +/* Subtree handles: set by register_subtree_array */ +static gint ett_chdr = -1; +static gint ett_chdr_header = -1; +static gint ett_chdr_id = -1; +static gint ett_chdr_response = -1; +static gint ett_chdr_cmd = -1; + +/* Forward-declare the dissector functions */ +void proto_register_chdr(void); +void proto_reg_handoff_chdr(void); +static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); + +/* heuristic dissector call. Will always return. */ +static gboolean heur_dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* whatislove) +{ + if(heur_warning_printed < 1){ + printf(LOG_HEADER"heuristic dissector always returns true!\n"); + heur_warning_printed++; + } + dissect_chdr(tvb, pinfo, tree); + return (TRUE); +} + +static void byte_swap(guint8 *bytes, gint len) +{ + guint8 tmp[4]; + + if(len != sizeof(tmp)){ + printf(LOG_HEADER"FATAL! number of bytes don't match 32 bit!\n"); + return; + } + + memcpy(tmp, bytes, sizeof(tmp)); + bytes[0] = tmp[3]; + bytes[1] = tmp[2]; + bytes[2] = tmp[1]; + bytes[3] = tmp[0]; +} + +static unsigned long long get_timestamp(guint8 *bytes, gint len) +{ + unsigned long long ts; + unsigned long long trans; + int it; + + if(len != sizeof(unsigned long long)){ + printf(LOG_HEADER"FATAL! timestamps always consist of 64 bits!\n"); + } + + byte_swap(bytes + 0, 4); + byte_swap(bytes + 4, 4); + + ts = 0; + for(it = 0; it < 8; it++){ + ts = ts << 8; + trans = (guint64) bytes[it]; + ts = ts | trans; + } + + return (ts); +} + +/* The dissector itself */ +static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + // Here are all the variables + proto_item *item; + proto_item *stream_item; + proto_tree *chdr_tree; + proto_item *header_item; + proto_tree *header_tree; + proto_tree *stream_tree; + proto_item *response_item; + proto_tree *response_tree; + proto_item *cmd_item; + proto_tree *cmd_tree; + gint len; + + gint flag_offset; + guint8 *bytes; + guint8 hdr_bits = 0; + guint8 pkt_type = 0; + gboolean flag_has_time = 0; + gboolean flag_is_data = 0; + gboolean flag_is_fc = 0; + gboolean flag_is_cmd = 0; + gboolean flag_is_resp = 0; + gboolean flag_is_eob = 0; + gboolean flag_is_error = 0; + unsigned long long timestamp; + gboolean is_network; + gint endianness; + gint id_pos_usb[4] = {7, 6, 5, 4}; + gint id_pos_net[4] = {4, 5, 6, 7}; + gint id_pos[4] = {7, 6, 5, 4}; + + if(pinfo->match_uint == CHDR_PORT){ + is_network = TRUE; + flag_offset = 0; + endianness = ENC_BIG_ENDIAN; + memcpy(id_pos, id_pos_net, 4 * sizeof(gint)); + } + else{ // Parsing a USB capture + is_network = FALSE; + flag_offset = 3; + endianness = ENC_LITTLE_ENDIAN; + memcpy(id_pos, id_pos_usb, 4 * sizeof(gint)); + } + + len = tvb_reported_length(tvb); + + col_append_str(pinfo->cinfo, COL_PROTOCOL, "/CHDR"); + /* This throws a warning: */ + /*col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR", tvb_format_text_wsp(tvb, 0, len));*/ + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR"); + + if (tree){ + int chdr_size = -1; + + if (len >= 4){ + chdr_size = 8; + bytes = tvb_get_string(wmem_packet_scope(), tvb, 0, 4); + hdr_bits = (bytes[flag_offset] & 0xF0) >> 4; + pkt_type = hdr_bits >> 2; + flag_is_data = (pkt_type == 0); + flag_is_fc = (pkt_type == 1); + flag_is_cmd = (pkt_type == 2); + flag_is_resp = (pkt_type == 3); + flag_is_eob = flag_is_data && (hdr_bits & 0x1); + flag_is_error = flag_is_resp && (hdr_bits & 0x1); + flag_has_time = hdr_bits & 0x2; + if (flag_has_time) + chdr_size += 8; // 64-bit timestamp + } + + /* Start with a top-level item to add everything else to */ + item = proto_tree_add_item(tree, proto_chdr, tvb, 0, min(len, chdr_size), ENC_NA); + + if (len >= 4) { + chdr_tree = proto_item_add_subtree(item, ett_chdr); + + /* Header info. First, a top-level header tree item: */ + header_item = proto_tree_add_item(chdr_tree, hf_chdr_hdr, tvb, flag_offset, 1, endianness); + header_tree = proto_item_add_subtree(header_item, ett_chdr_header); + proto_item_append_text(header_item, ", Packet type: %s", + val_to_str(hdr_bits & 0xD, CHDR_PACKET_TYPES, "Unknown (0x%x)") + ); + /* Let us query hdr.type */ + proto_tree_add_string( + header_tree, hf_chdr_type, tvb, flag_offset, 1, + val_to_str(hdr_bits & 0xD, CHDR_PACKET_TYPES_SHORT, "invalid") + ); + /* And other flags */ + proto_tree_add_boolean(header_tree, hf_chdr_has_time, tvb, flag_offset, 1, flag_has_time); + if (flag_is_data) { + proto_tree_add_boolean(header_tree, hf_chdr_eob, tvb, flag_offset, 1, flag_is_eob); + } + if (flag_is_resp) { + proto_tree_add_boolean(header_tree, hf_chdr_error, tvb, flag_offset, 1, flag_is_error); + } + + /* These lines add sequence, packet_size and stream ID */ + proto_tree_add_item(chdr_tree, hf_chdr_sequence, tvb, (is_network ? 0:2), 2, endianness); + proto_tree_add_item(chdr_tree, hf_chdr_packet_size, tvb, (is_network ? 2:0), 2, endianness); + + if (len >= 8){ + /* stream id can be broken down to 4 sections. these are collapsed in a subtree */ + stream_item = proto_tree_add_item(chdr_tree, hf_chdr_stream_id, tvb, 4, 4, endianness); + stream_tree = proto_item_add_subtree(stream_item, ett_chdr_id); + proto_tree_add_item(stream_tree, hf_chdr_src_dev, tvb, id_pos[0], 1, ENC_NA); + proto_tree_add_item(stream_tree, hf_chdr_src_ep, tvb, id_pos[1], 1, ENC_NA); + proto_tree_add_item(stream_tree, hf_chdr_dst_dev, tvb, id_pos[2], 1, ENC_NA); + proto_tree_add_item(stream_tree, hf_chdr_dst_ep, tvb, id_pos[3], 1, ENC_NA); + + /* Block ports (only add them if address points to a device) */ + bytes = tvb_get_string(wmem_packet_scope(), tvb, 0, 8); + if (bytes[id_pos[0]] != 0) { + proto_tree_add_item(stream_tree, hf_chdr_src_blockport, tvb, id_pos[1], 1, ENC_NA); + } + if (bytes[id_pos[2]] != 0) { + proto_tree_add_item(stream_tree, hf_chdr_dst_blockport, tvb, id_pos[3], 1, ENC_NA); + } + + /* Append SID in sid_t hex format */ + proto_item_append_text(stream_item, " (%02X:%02X>%02X:%02X)", + bytes[id_pos[0]], + bytes[id_pos[1]], + bytes[id_pos[2]], + bytes[id_pos[3]] + ); + + /* if has_time flag is present interpret timestamp */ + if ((flag_has_time) && (len >= 16)){ + if (is_network) + item = proto_tree_add_item(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, endianness); + else{ + bytes = (guint8*) tvb_get_string(wmem_packet_scope(), tvb, 8, sizeof(unsigned long long)); + timestamp = get_timestamp(bytes, sizeof(unsigned long long)); + proto_tree_add_uint64(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, timestamp); + } + } + + int remaining_bytes = (len - chdr_size); + int show_raw_payload = (remaining_bytes > 0); + + if (flag_is_cmd && remaining_bytes == 8) { + cmd_item = proto_tree_add_item(chdr_tree, hf_chdr_cmd, tvb, chdr_size, 8, endianness); + cmd_tree = proto_item_add_subtree(cmd_item, ett_chdr_cmd); + proto_tree_add_item(cmd_tree, hf_chdr_cmd_address, tvb, chdr_size, 4, endianness); + proto_tree_add_item(cmd_tree, hf_chdr_cmd_value, tvb, chdr_size + 4, 4, endianness); + } else if (flag_is_resp) { + response_item = proto_tree_add_item(chdr_tree, hf_chdr_ext_response, tvb, chdr_size, 8, endianness); + response_tree = proto_item_add_subtree(response_item, ett_chdr_response); + + proto_tree_add_item(response_tree, hf_chdr_ext_status_code, tvb, chdr_size, 4, endianness); + /* This will show the 12-bits of sequence ID in the last 2 bytes */ + proto_tree_add_item(response_tree, hf_chdr_ext_seq_num, tvb, (chdr_size + 4 + (is_network ? 2 : 0)), 2, endianness); + } else if (show_raw_payload) { + proto_tree_add_item(chdr_tree, hf_chdr_payload, tvb, chdr_size, -1, ENC_NA); + } + } + } + } +} + +void proto_register_chdr(void) +{ + static hf_register_info hf[] = { + { &hf_chdr_hdr, + { "Header bits", "chdr.hdr", + FT_UINT8, BASE_HEX, + NULL, 0xF0, + NULL, HFILL } + }, + { &hf_chdr_type, + { "Packet Type", "chdr.hdr.type", + FT_STRINGZ, BASE_NONE, + NULL, 0x00, + "Packet Type", HFILL } + }, + { &hf_chdr_has_time, + { "Time present", "chdr.hdr.has_time", + FT_BOOLEAN, BASE_NONE, + NULL, 0x20, + NULL, HFILL } + }, + { &hf_chdr_eob, + { "End Of Burst", "chdr.hdr.eob", + FT_BOOLEAN, BASE_NONE, + NULL, 0x10, + NULL, HFILL } + }, + { &hf_chdr_error, + { "Error Flag", "chdr.hdr.error", + FT_BOOLEAN, BASE_NONE, + NULL, 0x10, + NULL, HFILL } + }, + { &hf_chdr_sequence, + { "Sequence ID", "chdr.seq", + FT_UINT16, BASE_DEC, + NULL, 0x0FFF, + NULL, HFILL } + }, + { &hf_chdr_packet_size, + { "Packet size", "chdr.size", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_stream_id, + { "Stream ID", "chdr.sid", + FT_IPv4, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_src_dev, + { "Source device", "chdr.src_dev", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_src_ep, + { "Source endpoint", "chdr.src_ep", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_src_blockport, + { "Source block port", "chdr.src_bp", + FT_UINT8, BASE_DEC, + NULL, 0xF, + NULL, HFILL } + }, + { &hf_chdr_dst_dev, + { "Destination device", "chdr.dst_dev", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_dst_ep, + { "Destination endpoint", "chdr.dst_ep", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_dst_blockport, + { "Destination block port", "chdr.dst_bp", + FT_UINT8, BASE_DEC, + NULL, 0xF, + NULL, HFILL } + }, + { &hf_chdr_timestamp, + { "Time", "chdr.time", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_payload, + { "Payload", "chdr.payload", + FT_BYTES, BASE_NONE, + NULL, 0x0, + NULL, HFILL + } + }, + { &hf_chdr_ext_response, + { "Response", "chdr.res", + FT_BYTES, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_ext_status_code, + { "Status code", "chdr.res.status", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_ext_seq_num, + { "Response to sequence ID", "chdr.res.seq", + FT_UINT16, BASE_DEC, + NULL, 0x0FFF, + NULL, HFILL } + }, + { &hf_chdr_cmd, + { "Command", "chdr.cmd", + FT_BYTES, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_cmd_address, + { "Register Address", "chdr.cmd.addr", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_chdr_cmd_value, + { "Command Value", "chdr.cmd.val", + FT_UINT32, BASE_HEX, + NULL, 0x0, + NULL, HFILL } + }, + }; + + static gint *ett[] = { + &ett_chdr, + &ett_chdr_header, + &ett_chdr_id, + &ett_chdr_response, + &ett_chdr_cmd + }; + + proto_chdr = proto_register_protocol("UHD CHDR", "CHDR", "chdr"); + proto_register_field_array(proto_chdr, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + register_dissector("chdr", dissect_chdr, proto_chdr); +} + +/* Handler registration */ +void proto_reg_handoff_chdr(void) +{ + /* register heuristic dissector for use with USB */ +#if VERSION_MAJOR == 1 + heur_dissector_add("usb.bulk", heur_dissect_chdr, proto_chdr); +#elif VERSION_MAJOR == 2 + heur_dissector_add("usb.bulk", heur_dissect_chdr, "USB dissector", "usb_bulk", proto_chdr, HEURISTIC_ENABLE); +#else +#error Wireshark version not found or not compatible +#endif + /* register dissector for UDP packets */ + static dissector_handle_t chdr_handle; + chdr_handle = create_dissector_handle(dissect_chdr, proto_chdr); + dissector_add_uint("udp.port", CHDR_PORT, chdr_handle); +} diff --git a/tools/dissectors/packet-octoclock.c b/tools/dissectors/packet-octoclock.c new file mode 100644 index 000000000..453c325d7 --- /dev/null +++ b/tools/dissectors/packet-octoclock.c @@ -0,0 +1,212 @@ +/* + * Dissector for Ettus Octoclock packets + * + * Copyright 2016 Ettus Research + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "config.h" + +#include <glib.h> +#include <epan/packet.h> +#include <ctype.h> +#include <stdio.h> +#include <stddef.h> + +#include "../../host/lib/usrp_clock/octoclock/common.h" + +#define LOG_HEADER "[Octoclock] " +#define size_mem(t,m) sizeof(((t*)0)->m) +#define packet_elem_size(m) (size_mem(octoclock_packet_t,m)) +#define packet_offset(m) (offsetof(octoclock_packet_t, m)) +const unsigned int OCTOCLOCK_PORT = OCTOCLOCK_UDP_CTRL_PORT; + +static int proto_octo = -1; +static int hf_octo_proto_version = -1; +static int hf_octo_proto_sequence = -1; +static int hf_octo_proto_code = -1; +static int hf_octo_proto_poolsize = -1; +static int hf_octo_proto_data = -1; +static int hf_octo_proto_payload = -1; +static int hf_octo_proto_len = -1; +static gint ett_octo = -1; +static const value_string packetcodes[] = { + {1, "OCTOCLOCK_QUERY_CMD"}, + {2, "OCTOCLOCK_QUERY_ACK"}, + {3, "SEND_EEPROM_CMD"}, + {4, "SEND_EEPROM_ACK"}, + {5, "BURN_EEPROM_CMD"}, + {6, "BURN_EEPROM_SUCCESS_ACK"}, + {7, "BURN_EEPROM_FAILURE_ACK"}, + {8, "CLEAR_EEPROM_CMD"}, + {9, "CLEAR_EEPROM_ACK"}, + {10, "SEND_STATE_CMD"}, + {11, "SEND_STATE_ACK"}, + {12, "RESET_CMD"}, + {13, "RESET_ACK"}, + {14, "HOST_SEND_TO_GPSDO_CMD"}, + {15, "HOST_SEND_TO_GPSDO_ACK"}, + {16, "SEND_POOLSIZE_CMD"}, + {17, "SEND_POOLSIZE_ACK"}, + {18, "SEND_CACHE_STATE_CMD"}, + {19, "SEND_CACHE_STATE_ACK"}, + {20, "SEND_GPSDO_CACHE_CMD"}, + {21, "SEND_GPSDO_CACHE_ACK"}, + {22, "PREPARE_FW_BURN_CMD"}, + {23, "FW_BURN_READY_ACK"}, + {24, "FILE_TRANSFER_CMD"}, + {25, "FILE_TRANSFER_ACK"}, + {26, "READ_FW_CMD"}, + {27, "READ_FW_ACK"}, + {28, "FINALIZE_BURNING_CMD"}, + {29, "FINALIZE_BURNING_ACK"}, + { 0, NULL } +}; +/* Forward-declare the dissector functions */ +void proto_register_octo(void); +void proto_reg_handoff_octo(void); +static void dissect_octo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); + +static void dissect_octo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCTO"); + col_clear(pinfo->cinfo, COL_INFO); + proto_item *ti = proto_tree_add_item(tree, proto_octo, tvb, 0, -1, ENC_NA); + proto_tree *octo_tree = proto_item_add_subtree(ti, ett_octo); + proto_tree_add_item(octo_tree, + hf_octo_proto_version, + tvb, + packet_offset(proto_ver), + packet_elem_size(proto_ver), + ENC_LITTLE_ENDIAN); + guint32 rev = tvb_get_letohl(tvb, packet_offset(proto_ver)); + if(rev==3) + { + proto_tree_add_item(octo_tree, + hf_octo_proto_sequence, + tvb, + packet_offset(sequence), + packet_elem_size(sequence), + ENC_LITTLE_ENDIAN); + proto_tree_add_item(octo_tree, + hf_octo_proto_code, + tvb, + packet_offset(code), + packet_elem_size(code), + ENC_LITTLE_ENDIAN); + proto_tree_add_item(octo_tree, + hf_octo_proto_poolsize, + tvb, + packet_offset(poolsize), + packet_elem_size(poolsize), + ENC_LITTLE_ENDIAN); + + //packet_code_t code = (packet_code_t)(tvb_get_guint8(tvb, packet_offset(code))); + + guint16 len = tvb_get_letohs(tvb, packet_offset(len)); + if(len && len <= packet_elem_size(data)) + { + proto_tree_add_item(octo_tree, + hf_octo_proto_payload, + tvb, + packet_offset(data), + len, + ENC_LITTLE_ENDIAN); + } + proto_tree_add_item(octo_tree, + hf_octo_proto_data, + tvb, + packet_offset(data), + packet_elem_size(data), + ENC_LITTLE_ENDIAN); + proto_tree_add_item(octo_tree, + hf_octo_proto_len, + tvb, + packet_offset(len), + packet_elem_size(len), + ENC_LITTLE_ENDIAN); + } +} + + +void proto_register_octo(void) +{ + static hf_register_info hf[] = { + { &hf_octo_proto_version, + { "version", "octo.rev", + FT_UINT32, BASE_DEC, + NULL, 0x0, + "Protocol Revision", HFILL } + }, + { &hf_octo_proto_sequence, + { "sequence number", "octo.seq", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_octo_proto_code, + { "code", "octo.code", + FT_UINT8, BASE_DEC, + VALS(packetcodes), 0x0, + NULL, HFILL } + }, + { &hf_octo_proto_poolsize, + { "poolsize", "octo.poolsize", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_octo_proto_payload, + { "payload", "octo.payload", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_octo_proto_data, + { "data", "octo.data", + FT_BYTES, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_octo_proto_len, + { "length", "octo.len", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + } + }; + //protocol subtree array + static gint *ett[] = { + &ett_octo + }; + proto_octo = proto_register_protocol( + "Octoclock", + "Octoclock", + "octo" + ); + + proto_register_field_array(proto_octo, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + register_dissector("octo", dissect_octo, proto_octo); +} + +void proto_reg_handoff_octo(void) +{ + static dissector_handle_t octo_handle; + octo_handle = create_dissector_handle(dissect_octo, proto_octo); + dissector_add_uint("udp.port", OCTOCLOCK_PORT, octo_handle); + dissector_add_uint("udp.port", OCTOCLOCK_UDP_GPSDO_PORT, octo_handle); +} diff --git a/tools/dissectors/packet-zpu.c b/tools/dissectors/packet-zpu.c new file mode 100644 index 000000000..39507165e --- /dev/null +++ b/tools/dissectors/packet-zpu.c @@ -0,0 +1,242 @@ +/* + * Dissector for ZPU packets (communication with X300 firmware) + * + * Copyright 2013-2014 Ettus Research LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* Format of ZPU packets is defined in x300_fw_commons.h, + * x300_fw_comms_t. + * + * Reminder: + * + * uint32_t flags; (ack, error, peek, poke) + * uint32_t sequence; + * uint32_t addr; + * uint32_t data; + */ + +#include "config.h" + +#include <glib.h> +#include <epan/packet.h> +#include <ctype.h> +#include <stdio.h> +#include <endian.h> + +#include "../../host/lib/usrp/x300/x300_fw_common.h" +#include "zpu_addr_names.h" + +#define LOG_HEADER "[ZPU] " + +#ifndef min +#define min(a,b) ((a<b)?a:b) +#endif // min + +const unsigned int FW_PORT = X300_FW_COMMS_UDP_PORT; + +static int proto_zpu = -1; +static int hf_zpu_flags = -1; +static int hf_zpu_flags_ack = -1; +static int hf_zpu_flags_error = -1; +static int hf_zpu_flags_poke = -1; +static int hf_zpu_flags_peek = -1; +static int hf_zpu_seq = -1; +static int hf_zpu_addr = -1; +static int hf_zpu_data = -1; +static int hf_zpu_shmem_addr = -1; +static int hf_zpu_shmem_addr_name = -1; + +/* Subtree handles: set by register_subtree_array */ +static gint ett_zpu = -1; +static gint ett_zpu_flags = -1; +//static gint ett_zpu_shmem = -1; + +/* Forward-declare the dissector functions */ +void proto_register_zpu(void); +void proto_reg_handoff_zpu(void); +static void dissect_zpu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); + +/* The dissector itself */ +static void dissect_zpu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *item; + proto_tree *zpu_tree; + proto_item *flags_item; + proto_tree *flags_tree; + gint len; + + gboolean is_network; + gint endianness; + + if (pinfo->match_uint == FW_PORT) { + is_network = TRUE; + endianness = ENC_BIG_ENDIAN; + } + else { + is_network = FALSE; + endianness = ENC_LITTLE_ENDIAN; + } + + len = tvb_reported_length(tvb); + + col_append_str(pinfo->cinfo, COL_PROTOCOL, "/ZPU"); + /*col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "ZPU", tvb_format_text_wsp(tvb, 0, len));*/ + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "ZPU"); + + if (tree) + { + item = proto_tree_add_item(tree, proto_zpu, tvb, 0, min(16, len), ENC_NA); + + // Dissect 'flags' + if (len >= 4) + { + zpu_tree = proto_item_add_subtree(item, ett_zpu); + + flags_item = proto_tree_add_item(zpu_tree, hf_zpu_flags, tvb, 0, 4, endianness); + flags_tree = proto_item_add_subtree(flags_item, ett_zpu_flags); + + proto_tree_add_item(flags_tree, hf_zpu_flags_ack, tvb, 0, 4, ENC_NA); + proto_tree_add_item(flags_tree, hf_zpu_flags_error, tvb, 0, 4, ENC_NA); + proto_tree_add_item(flags_tree, hf_zpu_flags_poke, tvb, 0, 4, ENC_NA); + proto_tree_add_item(flags_tree, hf_zpu_flags_peek, tvb, 0, 4, ENC_NA); + + // Dissect 'sequence number' + if (len >= 8) + { + proto_tree_add_item(zpu_tree, hf_zpu_seq, tvb, 4, 4, ENC_NA); + + // Dissect 'address' + if (len >= 12) + { + proto_tree_add_item(zpu_tree, hf_zpu_addr, tvb, 8, 4, ENC_NA); +#if VERSION_MAJOR == 1 + guint8 *bytes = tvb_get_string(tvb, 8, 4); +#elif VERSION_MAJOR == 2 + guint8 *bytes = tvb_get_string(wmem_packet_scope(), tvb, 8, 4); +#else +#error Wireshark version not found or not compatible +#endif + unsigned int addr = 0; + memcpy(&addr, bytes, 4); + /* TODO proper endianness handling */ + addr = (addr >> 24) | ((addr & 0x00FF0000) >> 8) | ((addr & 0x0000FF00) << 8) | ((addr & 0x000000FF) << 24); + /* TODO check the actual size of shmem instead of this constant */ + if (addr >= X300_FW_SHMEM_BASE && addr <= X300_FW_SHMEM_BASE + 0x2000) + { + proto_item *shmem_addr_item = NULL; + + // Convert the address to a register number (32-bit registers == 4-byte registers) + addr -= X300_FW_SHMEM_BASE; + addr /= 4; + + shmem_addr_item = proto_tree_add_uint(zpu_tree, hf_zpu_shmem_addr, tvb, 8, 4, addr); + proto_item_append_text(shmem_addr_item, ", Register name: %s", + val_to_str(addr, X300_SHMEM_NAMES, "Unknown (0x%04x)") + ); + + } + + // Dissect 'data' + if (len >= 16) + { + proto_tree_add_item(zpu_tree, hf_zpu_data, tvb, 12, 4, ENC_NA); + } + } + } + } + } +} + +void proto_register_zpu(void) +{ + static hf_register_info hf[] = { + { &hf_zpu_flags, + { "Flags", "zpu.flags", + FT_UINT32, BASE_HEX, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_zpu_flags_ack, + { "ACK", "zpu.flags.ack", + FT_BOOLEAN, BASE_NONE, + NULL, 0x1, + NULL, HFILL } + }, + { &hf_zpu_flags_error, + { "Error", "zpu.flags.error", + FT_BOOLEAN, BASE_NONE, + NULL, 0x2, + NULL, HFILL } + }, + { &hf_zpu_flags_poke, + { "Poke", "zpu.flags.poke", + FT_BOOLEAN, BASE_NONE, + NULL, 0x4, + NULL, HFILL } + }, + { &hf_zpu_flags_peek, + { "Peek", "zpu.flags.peek", + FT_BOOLEAN, BASE_NONE, + NULL, 0x8, + NULL, HFILL } + }, + { &hf_zpu_seq, + { "Sequence ID", "zpu.seq", + FT_UINT32, BASE_HEX, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_zpu_addr, + { "Address", "zpu.addr", + FT_UINT32, BASE_HEX, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_zpu_shmem_addr, + { "SHMEM section", "zpu.shmem", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_zpu_data, + { "Data", "zpu.data", + FT_UINT32, BASE_HEX, + NULL, 0x0, + NULL, HFILL } + }, + }; + + static gint *ett[] = { + &ett_zpu, + &ett_zpu_flags, + //&ett_zpu_shmem + }; + + proto_zpu = proto_register_protocol("ZPU FW", "ZPU", "zpu"); + proto_register_field_array(proto_zpu, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + register_dissector("zpu", dissect_zpu, proto_zpu); +} + +/* Handler registration */ +void proto_reg_handoff_zpu(void) +{ + /* register dissector for UDP packets */ + static dissector_handle_t zpu_handle; + zpu_handle = create_dissector_handle(dissect_zpu, proto_zpu); + dissector_add_uint("udp.port", FW_PORT, zpu_handle); +} diff --git a/tools/dissectors/plugin.rc.in b/tools/dissectors/plugin.rc.in new file mode 100644 index 000000000..29fcfdc33 --- /dev/null +++ b/tools/dissectors/plugin.rc.in @@ -0,0 +1,34 @@ +#include "winver.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @RC_MODULE_VERSION@ + PRODUCTVERSION @RC_VERSION@ + FILEFLAGSMASK 0x0L +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0 +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Ettus Research (National Instruments)\0" + VALUE "FileDescription", "@PACKAGE@ dissector\0" + VALUE "FileVersion", "@MODULE_VERSION@\0" + VALUE "InternalName", "@PACKAGE@ @MODULE_VERSION@\0" + VALUE "LegalCopyright", "Copyright � 2013 Ettus Research (National Instruments)\0" + VALUE "OriginalFilename", "@PLUGIN_NAME@.dll\0" + VALUE "ProductName", "Wireshark\0" + VALUE "ProductVersion", "@VERSION@\0" + VALUE "Comments", "Build with @MSVC_VARIANT@\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/tools/dissectors/zpu_addr_names.h b/tools/dissectors/zpu_addr_names.h new file mode 100644 index 000000000..ebbf423ed --- /dev/null +++ b/tools/dissectors/zpu_addr_names.h @@ -0,0 +1,38 @@ +/* + * Dissector for ZPU packets (communication with X300 firmware) + * + * Copyright 2013-2014 Ettus Research LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* TODO: autogenerate this file */ + +/* Names of SHMEM registers: */ +static const value_string X300_SHMEM_NAMES[] = { + { 0, "X300_FW_SHMEM_COMPAT_NUM" }, + { 1, "X300_FW_SHMEM_GPSDO_STATUS" }, + { 2, "X300_FW_SHMEM_UART_RX_INDEX" }, + { 3, "X300_FW_SHMEM_UART_TX_INDEX" }, + { 5, "X300_FW_SHMEM_CLAIM_STATUS" }, + { 6, "X300_FW_SHMEM_CLAIM_TIME" }, + { 7, "X300_FW_SHMEM_CLAIM_SRC" }, + { 8, "X300_FW_SHMEM_UART_RX_ADDR" }, + { 9, "X300_FW_SHMEM_UART_TX_ADDR" }, + { 10, "X300_FW_SHMEM_UART_WORDS32" }, + { 11, "X300_FW_SHMEM_ROUTE_MAP_ADDR" }, + { 12, "X300_FW_SHMEM_ROUTE_MAP_LEN" } +}; + diff --git a/tools/octoclock-dissector/.gitignore b/tools/octoclock-dissector/.gitignore deleted file mode 100644 index 0187b3dac..000000000 --- a/tools/octoclock-dissector/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build/ -*~ diff --git a/tools/octoclock-dissector/CMakeLists.txt b/tools/octoclock-dissector/CMakeLists.txt deleted file mode 100644 index 7b2b7ba0f..000000000 --- a/tools/octoclock-dissector/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2010-2016 Ettus Research LLC -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - - -######################################################################## -# Project setup -######################################################################## -cmake_minimum_required(VERSION 2.6) -project(octoclock-dissector C) -set(octoclock-dissector_VERSION_MAJOR 0) -set(octoclock-dissector_VERSION_MINOR 7) -enable_testing() - -#select the release build type by default to get optimization flags -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to release.") -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) - -######################################################################## -# Compiler specific setup -######################################################################## -#if(CMAKE_COMPILER_IS_GNUC AND NOT WIN32) -# #http://gcc.gnu.org/wiki/Visibility -# add_definitions(-fvisibility=visible) -#endif() - -find_package(GLIB2) -if(NOT GLIB2_FOUND) - message(FATAL_ERROR "Glib not found") -endif() - -find_package(Wireshark) -if(NOT WIRESHARK_FOUND) - message(FATAL_ERROR "Wireshark dev package not found") -endif() - - -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${CMAKE_SOURCE_DIR} - ${GLIB2_INCLUDE_DIRS} - ${WIRESHARK_INCLUDE_DIRS} -) - -#link_directories( -# ${Boost_LIBRARY_DIRS} -#) -set(CMAKE_INSTALL_LIBDIR ~/.wireshark) - -# Set component parameters -set(octoclock_DISSECTOR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR} CACHE INTERNAL "" FORCE) - -set(octoclock_PLUGIN_SRC ${CMAKE_SOURCE_DIR}/packet-octoclock.c) - -set(PLUGIN_C_GENERATOR ${CMAKE_SOURCE_DIR}/make-dissector-reg.py) -set(PLUGIN_C plugin.c) - -add_custom_command( - OUTPUT ${PLUGIN_C} - DEPENDS ${octoclock_PLUGIN_SRC} - COMMAND ${PLUGIN_C_GENERATOR} ${CMAKE_SOURCE_DIR} plugin ${octoclock_PLUGIN_SRC} - COMMENT "Generating ${PLUGIN_C}" -) - -add_library(octoclock-plugin MODULE - ${PLUGIN_C} - moduleinfo.h - ${octoclock_PLUGIN_SRC} -) -set_target_properties(octoclock-plugin PROPERTIES PREFIX "") -set_target_properties(octoclock-plugin PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") -target_link_libraries(octoclock-plugin wireshark) - -install(TARGETS octoclock-plugin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugins NAMELINK_SKIP -) diff --git a/tools/octoclock-dissector/cmake/Modules/FindGLIB2.cmake b/tools/octoclock-dissector/cmake/Modules/FindGLIB2.cmake deleted file mode 100644 index ae7baddbb..000000000 --- a/tools/octoclock-dissector/cmake/Modules/FindGLIB2.cmake +++ /dev/null @@ -1,238 +0,0 @@ -# -# $Id: FindGLIB2.cmake 34248 2010-09-25 15:38:12Z jmayer $ -# -# - Try to find GLib2 -# Once done this will define -# -# GLIB2_FOUND - system has GLib2 -# GLIB2_INCLUDE_DIRS - the GLib2 include directory -# GLIB2_LIBRARIES - Link these to use GLib2 -# -# HAVE_GLIB_GREGEX_H glib has gregex.h header and -# supports g_regex_match_simple -# -# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org> -# Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com> -# Copyright (c) 2007 Daniel Gollub <gollub@b1-systems.de> -# Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com> -# Copyright (c) 2008 Michael Bell <michael.bell@web.de> -# Copyright (c) 2008-2009 Bjoern Ricks <bjoern.ricks@googlemail.com> -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - - -IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) - # in cache already - SET(GLIB2_FOUND TRUE) -ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) - - INCLUDE(FindPkgConfig) - - ## Glib - IF ( GLIB2_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "REQUIRED" ) - ELSE ( GLIB2_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "" ) - ENDIF ( GLIB2_FIND_REQUIRED ) - - IF ( GLIB2_MIN_VERSION ) - PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) - ELSE ( GLIB2_MIN_VERSION ) - PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) - ENDIF ( GLIB2_MIN_VERSION ) - IF ( PKG_CONFIG_FOUND ) - IF ( GLIB2_FOUND ) - SET ( GLIB2_CORE_FOUND TRUE ) - ELSE ( GLIB2_FOUND ) - SET ( GLIB2_CORE_FOUND FALSE ) - ENDIF ( GLIB2_FOUND ) - ENDIF ( PKG_CONFIG_FOUND ) - - # Look for glib2 include dir and libraries w/o pkgconfig - IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) - FIND_PATH( - _glibconfig_include_DIR - NAMES - glibconfig.h - PATHS - /opt/gnome/lib64 - /opt/gnome/lib - /opt/lib/ - /opt/local/lib - /sw/lib/ - /usr/lib64 - /usr/lib - /usr/local/include - ${CMAKE_LIBRARY_PATH} - PATH_SUFFIXES - glib-2.0/include - ) - - FIND_PATH( - _glib2_include_DIR - NAMES - glib.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - PATH_SUFFIXES - glib-2.0 - ) - - #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") - - FIND_LIBRARY( - _glib2_link_DIR - NAMES - glib-2.0 - glib - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - IF ( _glib2_include_DIR AND _glib2_link_DIR ) - SET ( _glib2_FOUND TRUE ) - ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) - - - IF ( _glib2_FOUND ) - SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) - SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) - SET ( GLIB2_CORE_FOUND TRUE ) - ELSE ( _glib2_FOUND ) - SET ( GLIB2_CORE_FOUND FALSE ) - ENDIF ( _glib2_FOUND ) - - # Handle dependencies - # libintl - IF ( NOT LIBINTL_FOUND ) - FIND_PATH(LIBINTL_INCLUDE_DIR - NAMES - libintl.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - ) - - FIND_LIBRARY(LIBINTL_LIBRARY - NAMES - intl - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/local/lib - /usr/lib - ) - - IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) - SET (LIBINTL_FOUND TRUE) - ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) - ENDIF ( NOT LIBINTL_FOUND ) - - # libiconv - IF ( NOT LIBICONV_FOUND ) - FIND_PATH(LIBICONV_INCLUDE_DIR - NAMES - iconv.h - PATHS - /opt/gnome/include - /opt/local/include - /opt/local/include - /sw/include - /sw/include - /usr/local/include - /usr/include - PATH_SUFFIXES - glib-2.0 - ) - - FIND_LIBRARY(LIBICONV_LIBRARY - NAMES - iconv - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - - IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - SET (LIBICONV_FOUND TRUE) - ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - ENDIF ( NOT LIBICONV_FOUND ) - - IF (LIBINTL_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) - ENDIF (LIBINTL_FOUND) - - IF (LIBICONV_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) - ENDIF (LIBICONV_FOUND) - - ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) - ## - - IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) - SET (GLIB2_FOUND TRUE) - ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) - - IF (GLIB2_FOUND) - IF (NOT GLIB2_FIND_QUIETLY) - MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") - ENDIF (NOT GLIB2_FIND_QUIETLY) - ELSE (GLIB2_FOUND) - IF (GLIB2_FIND_REQUIRED) - MESSAGE (SEND_ERROR "Could not find GLib2") - ENDIF (GLIB2_FIND_REQUIRED) - ENDIF (GLIB2_FOUND) - - # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view - MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) - MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) - MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) - -ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) - -IF ( WIN32 ) - # include libiconv for win32 - IF ( NOT LIBICONV_FOUND ) - FIND_PATH(LIBICONV_INCLUDE_DIR iconv.h PATH_SUFFIXES glib-2.0) - - FIND_LIBRARY(LIBICONV_LIBRARY NAMES iconv) - - IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - SET (LIBICONV_FOUND TRUE) - ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - ENDIF ( NOT LIBICONV_FOUND ) - IF (LIBICONV_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) - ENDIF (LIBICONV_FOUND) -ENDIF ( WIN32 ) - -IF ( GLIB2_FOUND ) - # Check if system has a newer version of glib - # which supports g_regex_match_simple - INCLUDE( CheckIncludeFiles ) - SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) - CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) - CHECK_INCLUDE_FILES ( glib/gchecksum.h HAVE_GLIB_GCHECKSUM_H ) - # Reset CMAKE_REQUIRED_INCLUDES - SET( CMAKE_REQUIRED_INCLUDES "" ) -ENDIF( GLIB2_FOUND ) diff --git a/tools/octoclock-dissector/cmake/Modules/FindWireshark.cmake b/tools/octoclock-dissector/cmake/Modules/FindWireshark.cmake deleted file mode 100644 index 276201245..000000000 --- a/tools/octoclock-dissector/cmake/Modules/FindWireshark.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# -# Try to find the wireshark library and its includes -# -# This snippet sets the following variables: -# WIRESHARK_FOUND True if wireshark library got found -# WIRESHARK_INCLUDE_DIRS Location of the wireshark headers -# WIRESHARK_LIBRARIES List of libraries to use wireshark -# -# Copyright (c) 2011 Reinhold Kainhofer <reinhold@kainhofer.com> -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - -# wireshark does not install its library with pkg-config information, -# so we need to manually find the libraries and headers - -FIND_PATH( WIRESHARK_INCLUDE_DIRS epan/column.h PATH_SUFFIXES wireshark ) -FIND_LIBRARY( WIRESHARK_LIBRARIES wireshark ) - -# Report results -IF ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - SET( WIRESHARK_FOUND 1 ) -ELSE ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - MESSAGE( SEND_ERROR "Could NOT find the wireshark library and headers" ) -ENDIF ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - diff --git a/tools/octoclock-dissector/make-dissector-reg.py b/tools/octoclock-dissector/make-dissector-reg.py deleted file mode 100755 index 44972909b..000000000 --- a/tools/octoclock-dissector/make-dissector-reg.py +++ /dev/null @@ -1,305 +0,0 @@ -#!/usr/bin/env python -# -# Looks for registration routines in the protocol dissectors, -# and assembles C code to call all the routines. -# -# This is a Python version of the make-reg-dotc shell script. -# Running the shell script on Win32 is very very slow because of -# all the process-launching that goes on --- multiple greps and -# seds for each input file. I wrote this python version so that -# less processes would have to be started. -# -# $Id: make-dissector-reg.py 30447 2009-10-09 20:47:18Z krj $ - -import os -import sys -import re -import pickle -from stat import * - -VERSION_KEY = '_VERSION' -CUR_VERSION = '$Id: make-dissector-reg.py 30447 2009-10-09 20:47:18Z krj $' - -# -# The first argument is the directory in which the source files live. -# -srcdir = sys.argv[1] - -# -# The second argument is either "plugin" or "dissectors"; if it's -# "plugin", we build a plugin.c for a plugin, and if it's -# "dissectors", we build a register.c for libwireshark. -# -registertype = sys.argv[2] -if registertype == "plugin" or registertype == "plugin_wtap": - tmp_filename = "plugin.c-tmp" - final_filename = "plugin.c" - cache_filename = None - preamble = """\ -/* - * Do not modify this file. - * - * It is created automatically by Makefile or Makefile.nmake. - */ -""" -elif registertype == "dissectors": - tmp_filename = "register.c-tmp" - final_filename = "register.c" - cache_filename = "register-cache.pkl" - preamble = """\ -/* - * Do not modify this file. - * - * It is created automatically by the "register.c" target in - * epan/dissectors/Makefile or Makefile.nmake using information in - * epan/dissectors/register-cache.pkl. - * - * You can force this file to be regenerated completely by deleting - * it along with epan/dissectors/register-cache.pkl. - */ -""" -else: - print "Unknown output type '%s'" % registertype - sys.exit(1) - - -# -# All subsequent arguments are the files to scan. -# -files = sys.argv[3:] - -# Create the proper list of filenames -filenames = [] -for file in files: - if os.path.isfile(file): - filenames.append(file) - else: - filenames.append(os.path.join(srcdir, file)) - -if len(filenames) < 1: - print "No files found" - sys.exit(1) - - -# Look through all files, applying the regex to each line. -# If the pattern matches, save the "symbol" section to the -# appropriate array. -regs = { - 'proto_reg': [], - 'handoff_reg': [], - 'wtap_register': [], - } - -# For those that don't know Python, r"" indicates a raw string, -# devoid of Python escapes. -proto_regex0 = r"^(?P<symbol>proto_register_[_A-Za-z0-9]+)\s*\([^;]+$" -proto_regex1 = r"void\s+(?P<symbol>proto_register_[_A-Za-z0-9]+)\s*\([^;]+$" - -handoff_regex0 = r"^(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" -handoff_regex1 = r"void\s+(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" - -wtap_reg_regex0 = r"^(?P<symbol>wtap_register_[_A-Za-z0-9]+)\s*\([^;]+$" -wtap_reg_regex1 = r"void\s+(?P<symbol>wtap_register_[_A-Za-z0-9]+)\s*\([^;]+$" - -# This table drives the pattern-matching and symbol-harvesting -patterns = [ - ( 'proto_reg', re.compile(proto_regex0) ), - ( 'proto_reg', re.compile(proto_regex1) ), - ( 'handoff_reg', re.compile(handoff_regex0) ), - ( 'handoff_reg', re.compile(handoff_regex1) ), - ( 'wtap_register', re.compile(wtap_reg_regex0) ), - ( 'wtap_register', re.compile(wtap_reg_regex1) ), - ] - -# Open our registration symbol cache -cache = None -if cache_filename: - try: - cache_file = open(cache_filename, 'rb') - cache = pickle.load(cache_file) - cache_file.close() - if not cache.has_key(VERSION_KEY) or cache[VERSION_KEY] != CUR_VERSION: - cache = {VERSION_KEY: CUR_VERSION} - except: - cache = {VERSION_KEY: CUR_VERSION} - -# Grep -for filename in filenames: - file = open(filename) - cur_mtime = os.fstat(file.fileno())[ST_MTIME] - if cache and cache.has_key(filename): - cdict = cache[filename] - if cur_mtime == cdict['mtime']: -# print "Pulling %s from cache" % (filename) - regs['proto_reg'].extend(cdict['proto_reg']) - regs['handoff_reg'].extend(cdict['handoff_reg']) - regs['wtap_register'].extend(cdict['wtap_register']) - file.close() - continue - # We don't have a cache entry - if cache is not None: - cache[filename] = { - 'mtime': cur_mtime, - 'proto_reg': [], - 'handoff_reg': [], - 'wtap_register': [], - } -# print "Searching %s" % (filename) - for line in file.readlines(): - for action in patterns: - regex = action[1] - match = regex.search(line) - if match: - symbol = match.group("symbol") - sym_type = action[0] - regs[sym_type].append(symbol) - if cache is not None: -# print "Caching %s for %s: %s" % (sym_type, filename, symbol) - cache[filename][sym_type].append(symbol) - file.close() - -if cache is not None and cache_filename is not None: - cache_file = open(cache_filename, 'wb') - pickle.dump(cache, cache_file) - cache_file.close() - -# Make sure we actually processed something -if len(regs['proto_reg']) < 1: - print "No protocol registrations found" - sys.exit(1) - -# Sort the lists to make them pretty -regs['proto_reg'].sort() -regs['handoff_reg'].sort() -regs['wtap_register'].sort() - -reg_code = open(tmp_filename, "w") - -reg_code.write(preamble) - -# Make the routine to register all protocols -if registertype == "plugin" or registertype == "plugin_wtap": - reg_code.write(""" -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gmodule.h> - -#include "moduleinfo.h" - -#ifndef ENABLE_STATIC -G_MODULE_EXPORT const gchar version[] = VERSION; - -/* Start the functions we need for the plugin stuff */ - -G_MODULE_EXPORT void -plugin_register (void) -{ -"""); -else: - reg_code.write(""" -#include "register.h" -void -register_all_protocols(register_cb cb, gpointer client_data) -{ -"""); - -for symbol in regs['proto_reg']: - if registertype == "plugin" or registertype == "plugin_wtap": - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - else: - line = " {extern void %s (void); if(cb) (*cb)(RA_REGISTER, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol) - reg_code.write(line) - -reg_code.write("}\n") - - -# Make the routine to register all protocol handoffs -if registertype == "plugin" or registertype == "plugin_wtap": - reg_code.write(""" -G_MODULE_EXPORT void -plugin_reg_handoff(void) -{ -"""); -else: - reg_code.write(""" -void -register_all_protocol_handoffs(register_cb cb, gpointer client_data) -{ -"""); - -for symbol in regs['handoff_reg']: - if registertype == "plugin" or registertype == "plugin_wtap": - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - else: - line = " {extern void %s (void); if(cb) (*cb)(RA_HANDOFF, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol) - reg_code.write(line) - -reg_code.write("}\n") - -if registertype == "plugin": - reg_code.write("#endif\n"); -elif registertype == "plugin_wtap": - reg_code.write(""" -G_MODULE_EXPORT void -register_wtap_module(void) -{ -"""); - - for symbol in regs['wtap_register']: - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - reg_code.write(line) - - reg_code.write("}\n"); - reg_code.write("#endif\n"); -else: - reg_code.write(""" -static gulong proto_reg_count(void) -{ -"""); - - line = " return %d;\n" % len(regs['proto_reg']) - reg_code.write(line) - - reg_code.write(""" -} -"""); - reg_code.write(""" -static gulong handoff_reg_count(void) -{ -"""); - - line = " return %d;\n" % len(regs['handoff_reg']) - reg_code.write(line) - - reg_code.write(""" -} -"""); - reg_code.write(""" -gulong register_count(void) -{ -"""); - - line = " return proto_reg_count() + handoff_reg_count();" - reg_code.write(line) - - reg_code.write(""" -}\n -"""); - - -# Close the file -reg_code.close() - -# Remove the old final_file if it exists. -try: - os.stat(final_filename) - os.remove(final_filename) -except OSError: - pass - -# Move from tmp file to final file -os.rename(tmp_filename, final_filename) - - diff --git a/tools/octoclock-dissector/moduleinfo.h b/tools/octoclock-dissector/moduleinfo.h deleted file mode 100644 index 494d0a922..000000000 --- a/tools/octoclock-dissector/moduleinfo.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef PACKAGE -#undef PACKAGE -#endif -#define PACKAGE "octo" -#ifdef VERSION -#undef VERSION -#endif -#define VERSION "0.0.0.1" - diff --git a/tools/octoclock-dissector/packet-octoclock.c b/tools/octoclock-dissector/packet-octoclock.c deleted file mode 100644 index 453c325d7..000000000 --- a/tools/octoclock-dissector/packet-octoclock.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Dissector for Ettus Octoclock packets - * - * Copyright 2016 Ettus Research - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -#include "config.h" - -#include <glib.h> -#include <epan/packet.h> -#include <ctype.h> -#include <stdio.h> -#include <stddef.h> - -#include "../../host/lib/usrp_clock/octoclock/common.h" - -#define LOG_HEADER "[Octoclock] " -#define size_mem(t,m) sizeof(((t*)0)->m) -#define packet_elem_size(m) (size_mem(octoclock_packet_t,m)) -#define packet_offset(m) (offsetof(octoclock_packet_t, m)) -const unsigned int OCTOCLOCK_PORT = OCTOCLOCK_UDP_CTRL_PORT; - -static int proto_octo = -1; -static int hf_octo_proto_version = -1; -static int hf_octo_proto_sequence = -1; -static int hf_octo_proto_code = -1; -static int hf_octo_proto_poolsize = -1; -static int hf_octo_proto_data = -1; -static int hf_octo_proto_payload = -1; -static int hf_octo_proto_len = -1; -static gint ett_octo = -1; -static const value_string packetcodes[] = { - {1, "OCTOCLOCK_QUERY_CMD"}, - {2, "OCTOCLOCK_QUERY_ACK"}, - {3, "SEND_EEPROM_CMD"}, - {4, "SEND_EEPROM_ACK"}, - {5, "BURN_EEPROM_CMD"}, - {6, "BURN_EEPROM_SUCCESS_ACK"}, - {7, "BURN_EEPROM_FAILURE_ACK"}, - {8, "CLEAR_EEPROM_CMD"}, - {9, "CLEAR_EEPROM_ACK"}, - {10, "SEND_STATE_CMD"}, - {11, "SEND_STATE_ACK"}, - {12, "RESET_CMD"}, - {13, "RESET_ACK"}, - {14, "HOST_SEND_TO_GPSDO_CMD"}, - {15, "HOST_SEND_TO_GPSDO_ACK"}, - {16, "SEND_POOLSIZE_CMD"}, - {17, "SEND_POOLSIZE_ACK"}, - {18, "SEND_CACHE_STATE_CMD"}, - {19, "SEND_CACHE_STATE_ACK"}, - {20, "SEND_GPSDO_CACHE_CMD"}, - {21, "SEND_GPSDO_CACHE_ACK"}, - {22, "PREPARE_FW_BURN_CMD"}, - {23, "FW_BURN_READY_ACK"}, - {24, "FILE_TRANSFER_CMD"}, - {25, "FILE_TRANSFER_ACK"}, - {26, "READ_FW_CMD"}, - {27, "READ_FW_ACK"}, - {28, "FINALIZE_BURNING_CMD"}, - {29, "FINALIZE_BURNING_ACK"}, - { 0, NULL } -}; -/* Forward-declare the dissector functions */ -void proto_register_octo(void); -void proto_reg_handoff_octo(void); -static void dissect_octo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); - -static void dissect_octo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) -{ - col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCTO"); - col_clear(pinfo->cinfo, COL_INFO); - proto_item *ti = proto_tree_add_item(tree, proto_octo, tvb, 0, -1, ENC_NA); - proto_tree *octo_tree = proto_item_add_subtree(ti, ett_octo); - proto_tree_add_item(octo_tree, - hf_octo_proto_version, - tvb, - packet_offset(proto_ver), - packet_elem_size(proto_ver), - ENC_LITTLE_ENDIAN); - guint32 rev = tvb_get_letohl(tvb, packet_offset(proto_ver)); - if(rev==3) - { - proto_tree_add_item(octo_tree, - hf_octo_proto_sequence, - tvb, - packet_offset(sequence), - packet_elem_size(sequence), - ENC_LITTLE_ENDIAN); - proto_tree_add_item(octo_tree, - hf_octo_proto_code, - tvb, - packet_offset(code), - packet_elem_size(code), - ENC_LITTLE_ENDIAN); - proto_tree_add_item(octo_tree, - hf_octo_proto_poolsize, - tvb, - packet_offset(poolsize), - packet_elem_size(poolsize), - ENC_LITTLE_ENDIAN); - - //packet_code_t code = (packet_code_t)(tvb_get_guint8(tvb, packet_offset(code))); - - guint16 len = tvb_get_letohs(tvb, packet_offset(len)); - if(len && len <= packet_elem_size(data)) - { - proto_tree_add_item(octo_tree, - hf_octo_proto_payload, - tvb, - packet_offset(data), - len, - ENC_LITTLE_ENDIAN); - } - proto_tree_add_item(octo_tree, - hf_octo_proto_data, - tvb, - packet_offset(data), - packet_elem_size(data), - ENC_LITTLE_ENDIAN); - proto_tree_add_item(octo_tree, - hf_octo_proto_len, - tvb, - packet_offset(len), - packet_elem_size(len), - ENC_LITTLE_ENDIAN); - } -} - - -void proto_register_octo(void) -{ - static hf_register_info hf[] = { - { &hf_octo_proto_version, - { "version", "octo.rev", - FT_UINT32, BASE_DEC, - NULL, 0x0, - "Protocol Revision", HFILL } - }, - { &hf_octo_proto_sequence, - { "sequence number", "octo.seq", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_octo_proto_code, - { "code", "octo.code", - FT_UINT8, BASE_DEC, - VALS(packetcodes), 0x0, - NULL, HFILL } - }, - { &hf_octo_proto_poolsize, - { "poolsize", "octo.poolsize", - FT_UINT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_octo_proto_payload, - { "payload", "octo.payload", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_octo_proto_data, - { "data", "octo.data", - FT_BYTES, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_octo_proto_len, - { "length", "octo.len", - FT_UINT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - } - }; - //protocol subtree array - static gint *ett[] = { - &ett_octo - }; - proto_octo = proto_register_protocol( - "Octoclock", - "Octoclock", - "octo" - ); - - proto_register_field_array(proto_octo, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); - register_dissector("octo", dissect_octo, proto_octo); -} - -void proto_reg_handoff_octo(void) -{ - static dissector_handle_t octo_handle; - octo_handle = create_dissector_handle(dissect_octo, proto_octo); - dissector_add_uint("udp.port", OCTOCLOCK_PORT, octo_handle); - dissector_add_uint("udp.port", OCTOCLOCK_UDP_GPSDO_PORT, octo_handle); -} diff --git a/tools/octoclock-dissector/plugin.rc.in b/tools/octoclock-dissector/plugin.rc.in deleted file mode 100644 index 7fde51b64..000000000 --- a/tools/octoclock-dissector/plugin.rc.in +++ /dev/null @@ -1,34 +0,0 @@ -#include "winver.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION @RC_MODULE_VERSION@ - PRODUCTVERSION @RC_VERSION@ - FILEFLAGSMASK 0x0L -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0 -#endif - FILEOS VOS_NT_WINDOWS32 - FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Ettus Research\0" - VALUE "FileDescription", "@PACKAGE@ dissector\0" - VALUE "FileVersion", "@MODULE_VERSION@\0" - VALUE "InternalName", "@PACKAGE@ @MODULE_VERSION@\0" - VALUE "LegalCopyright", "Copyright � 2016 Ettus Research\0" - VALUE "OriginalFilename", "@PLUGIN_NAME@.dll\0" - VALUE "ProductName", "Wireshark\0" - VALUE "ProductVersion", "@VERSION@\0" - VALUE "Comments", "Build with @MSVC_VARIANT@\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/tools/zpu-dissector/.gitignore b/tools/zpu-dissector/.gitignore deleted file mode 100644 index 0187b3dac..000000000 --- a/tools/zpu-dissector/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build/ -*~ diff --git a/tools/zpu-dissector/CMakeLists.txt b/tools/zpu-dissector/CMakeLists.txt deleted file mode 100644 index af5554010..000000000 --- a/tools/zpu-dissector/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2010-2013 Ettus Research LLC -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - - -######################################################################## -# Project setup -######################################################################## -cmake_minimum_required(VERSION 2.6) -project(zpu-dissector C) -set(zpu-dissector_VERSION_MAJOR 0) -set(zpu-dissector_VERSION_MINOR 0) -enable_testing() - -#select the release build type by default to get optimization flags -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to release.") -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) - -######################################################################## -# Compiler specific setup -######################################################################## -#if(CMAKE_COMPILER_IS_GNUC AND NOT WIN32) -# #http://gcc.gnu.org/wiki/Visibility -# add_definitions(-fvisibility=visible) -#endif() - -find_package(GLIB2) -if(NOT GLIB2_FOUND) - message(FATAL_ERROR "Glib not found") -endif() - -find_package(Wireshark) -if(NOT WIRESHARK_FOUND) - message(FATAL_ERROR "Wireshark dev package not found") -endif() - - -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${CMAKE_SOURCE_DIR} - ${GLIB2_INCLUDE_DIRS} - ${WIRESHARK_INCLUDE_DIRS} -) - -#link_directories( -# ${Boost_LIBRARY_DIRS} -#) -set(CMAKE_INSTALL_LIBDIR ~/.wireshark) - -# Set component parameters -set(ZPU_DISSECTOR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR} CACHE INTERNAL "" FORCE) - -set(ZPU_PLUGIN_SRC ${CMAKE_SOURCE_DIR}/packet-zpu.c) - -set(PLUGIN_C_GENERATOR ${CMAKE_SOURCE_DIR}/make-dissector-reg.py) -set(PLUGIN_C plugin.c) - -add_custom_command( - OUTPUT ${PLUGIN_C} - DEPENDS ${ZPU_PLUGIN_SRC} - COMMAND ${PLUGIN_C_GENERATOR} ${CMAKE_SOURCE_DIR} plugin ${ZPU_PLUGIN_SRC} - COMMENT "Generating ${PLUGIN_C}" -) - -add_library(zpu-plugin MODULE - ${PLUGIN_C} - moduleinfo.h - ${ZPU_PLUGIN_SRC} -) -set_target_properties(zpu-plugin PROPERTIES PREFIX "") -set_target_properties(zpu-plugin PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") -target_link_libraries(zpu-plugin wireshark) - -install(TARGETS zpu-plugin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugins NAMELINK_SKIP -) diff --git a/tools/zpu-dissector/cmake b/tools/zpu-dissector/cmake deleted file mode 120000 index ec7b5e3b5..000000000 --- a/tools/zpu-dissector/cmake +++ /dev/null @@ -1 +0,0 @@ -../chdr-dissector/cmake \ No newline at end of file diff --git a/tools/zpu-dissector/make-dissector-reg.py b/tools/zpu-dissector/make-dissector-reg.py deleted file mode 120000 index cad30999e..000000000 --- a/tools/zpu-dissector/make-dissector-reg.py +++ /dev/null @@ -1 +0,0 @@ -../chdr-dissector/make-dissector-reg.py \ No newline at end of file diff --git a/tools/zpu-dissector/moduleinfo.h b/tools/zpu-dissector/moduleinfo.h deleted file mode 100644 index af1b41d34..000000000 --- a/tools/zpu-dissector/moduleinfo.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef PACKAGE -#undef PACKAGE -#endif -#define PACKAGE "zpu" -#ifdef VERSION -#undef VERSION -#endif -#define VERSION "0.0.0.1" - diff --git a/tools/zpu-dissector/packet-zpu.c b/tools/zpu-dissector/packet-zpu.c deleted file mode 100644 index b6192c275..000000000 --- a/tools/zpu-dissector/packet-zpu.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Dissector for ZPU packets (communication with X300 firmware) - * - * Copyright 2013-2014 Ettus Research LLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/* Format of ZPU packets is defined in x300_fw_commons.h, - * x300_fw_comms_t. - * - * Reminder: - * - * uint32_t flags; (ack, error, peek, poke) - * uint32_t sequence; - * uint32_t addr; - * uint32_t data; - */ - -#include "config.h" - -#include <glib.h> -#include <epan/packet.h> -#include <ctype.h> -#include <stdio.h> -#include <endian.h> - -#include "../../host/lib/usrp/x300/x300_fw_common.h" -#include "zpu_addr_names.h" - -#define LOG_HEADER "[ZPU] " - -#ifndef min -#define min(a,b) ((a<b)?a:b) -#endif // min - -const unsigned int FW_PORT = X300_FW_COMMS_UDP_PORT; - -static int proto_zpu = -1; -static int hf_zpu_flags = -1; -static int hf_zpu_flags_ack = -1; -static int hf_zpu_flags_error = -1; -static int hf_zpu_flags_poke = -1; -static int hf_zpu_flags_peek = -1; -static int hf_zpu_seq = -1; -static int hf_zpu_addr = -1; -static int hf_zpu_data = -1; -static int hf_zpu_shmem_addr = -1; -static int hf_zpu_shmem_addr_name = -1; - -/* Subtree handles: set by register_subtree_array */ -static gint ett_zpu = -1; -static gint ett_zpu_flags = -1; -//static gint ett_zpu_shmem = -1; - -/* Forward-declare the dissector functions */ -void proto_register_zpu(void); -void proto_reg_handoff_zpu(void); -static void dissect_zpu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); - -/* The dissector itself */ -static void dissect_zpu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) -{ - proto_item *item; - proto_tree *zpu_tree; - proto_item *flags_item; - proto_tree *flags_tree; - gint len; - - gboolean is_network; - gint endianness; - - if (pinfo->match_uint == FW_PORT) { - is_network = TRUE; - endianness = ENC_BIG_ENDIAN; - } - else { - is_network = FALSE; - endianness = ENC_LITTLE_ENDIAN; - } - - len = tvb_reported_length(tvb); - - col_append_str(pinfo->cinfo, COL_PROTOCOL, "/ZPU"); - /*col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "ZPU", tvb_format_text_wsp(tvb, 0, len));*/ - col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "ZPU"); - - if (tree) - { - item = proto_tree_add_item(tree, proto_zpu, tvb, 0, min(16, len), ENC_NA); - - // Dissect 'flags' - if (len >= 4) - { - zpu_tree = proto_item_add_subtree(item, ett_zpu); - - flags_item = proto_tree_add_item(zpu_tree, hf_zpu_flags, tvb, 0, 4, endianness); - flags_tree = proto_item_add_subtree(flags_item, ett_zpu_flags); - - proto_tree_add_item(flags_tree, hf_zpu_flags_ack, tvb, 0, 4, ENC_NA); - proto_tree_add_item(flags_tree, hf_zpu_flags_error, tvb, 0, 4, ENC_NA); - proto_tree_add_item(flags_tree, hf_zpu_flags_poke, tvb, 0, 4, ENC_NA); - proto_tree_add_item(flags_tree, hf_zpu_flags_peek, tvb, 0, 4, ENC_NA); - - // Dissect 'sequence number' - if (len >= 8) - { - proto_tree_add_item(zpu_tree, hf_zpu_seq, tvb, 4, 4, ENC_NA); - - // Dissect 'address' - if (len >= 12) - { - proto_tree_add_item(zpu_tree, hf_zpu_addr, tvb, 8, 4, ENC_NA); - - guint8 *bytes = tvb_get_string(tvb, 8, 4); - unsigned int addr = 0; - memcpy(&addr, bytes, 4); - /* TODO proper endianness handling */ - addr = (addr >> 24) | ((addr & 0x00FF0000) >> 8) | ((addr & 0x0000FF00) << 8) | ((addr & 0x000000FF) << 24); - /* TODO check the actual size of shmem instead of this constant */ - if (addr >= X300_FW_SHMEM_BASE && addr <= X300_FW_SHMEM_BASE + 0x2000) - { - proto_item *shmem_addr_item = NULL; - - // Convert the address to a register number (32-bit registers == 4-byte registers) - addr -= X300_FW_SHMEM_BASE; - addr /= 4; - - shmem_addr_item = proto_tree_add_uint(zpu_tree, hf_zpu_shmem_addr, tvb, 8, 4, addr); - proto_item_append_text(shmem_addr_item, ", Register name: %s", - val_to_str(addr, X300_SHMEM_NAMES, "Unknown (0x%04x)") - ); - - } - - // Dissect 'data' - if (len >= 16) - { - proto_tree_add_item(zpu_tree, hf_zpu_data, tvb, 12, 4, ENC_NA); - } - } - } - } - } -} - -void proto_register_zpu(void) -{ - static hf_register_info hf[] = { - { &hf_zpu_flags, - { "Flags", "zpu.flags", - FT_UINT32, BASE_HEX, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_zpu_flags_ack, - { "ACK", "zpu.flags.ack", - FT_BOOLEAN, BASE_NONE, - NULL, 0x1, - NULL, HFILL } - }, - { &hf_zpu_flags_error, - { "Error", "zpu.flags.error", - FT_BOOLEAN, BASE_NONE, - NULL, 0x2, - NULL, HFILL } - }, - { &hf_zpu_flags_poke, - { "Poke", "zpu.flags.poke", - FT_BOOLEAN, BASE_NONE, - NULL, 0x4, - NULL, HFILL } - }, - { &hf_zpu_flags_peek, - { "Peek", "zpu.flags.peek", - FT_BOOLEAN, BASE_NONE, - NULL, 0x8, - NULL, HFILL } - }, - { &hf_zpu_seq, - { "Sequence ID", "zpu.seq", - FT_UINT32, BASE_HEX, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_zpu_addr, - { "Address", "zpu.addr", - FT_UINT32, BASE_HEX, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_zpu_shmem_addr, - { "SHMEM section", "zpu.shmem", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_zpu_data, - { "Data", "zpu.data", - FT_UINT32, BASE_HEX, - NULL, 0x0, - NULL, HFILL } - }, - }; - - static gint *ett[] = { - &ett_zpu, - &ett_zpu_flags, - //&ett_zpu_shmem - }; - - proto_zpu = proto_register_protocol("ZPU FW", "ZPU", "zpu"); - proto_register_field_array(proto_zpu, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); - register_dissector("zpu", dissect_zpu, proto_zpu); -} - -/* Handler registration */ -void proto_reg_handoff_zpu(void) -{ - /* register dissector for UDP packets */ - static dissector_handle_t zpu_handle; - zpu_handle = create_dissector_handle(dissect_zpu, proto_zpu); - dissector_add_uint("udp.port", FW_PORT, zpu_handle); -} diff --git a/tools/zpu-dissector/plugin.rc.in b/tools/zpu-dissector/plugin.rc.in deleted file mode 100644 index f9d714704..000000000 --- a/tools/zpu-dissector/plugin.rc.in +++ /dev/null @@ -1,34 +0,0 @@ -#include "winver.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION @RC_MODULE_VERSION@ - PRODUCTVERSION @RC_VERSION@ - FILEFLAGSMASK 0x0L -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0 -#endif - FILEOS VOS_NT_WINDOWS32 - FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Ettus Research LLC\0" - VALUE "FileDescription", "@PACKAGE@ dissector\0" - VALUE "FileVersion", "@MODULE_VERSION@\0" - VALUE "InternalName", "@PACKAGE@ @MODULE_VERSION@\0" - VALUE "LegalCopyright", "Copyright � 2013 Ettus Research LLC\0" - VALUE "OriginalFilename", "@PLUGIN_NAME@.dll\0" - VALUE "ProductName", "Wireshark\0" - VALUE "ProductVersion", "@VERSION@\0" - VALUE "Comments", "Build with @MSVC_VARIANT@\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/tools/zpu-dissector/zpu_addr_names.h b/tools/zpu-dissector/zpu_addr_names.h deleted file mode 100644 index ebbf423ed..000000000 --- a/tools/zpu-dissector/zpu_addr_names.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Dissector for ZPU packets (communication with X300 firmware) - * - * Copyright 2013-2014 Ettus Research LLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/* TODO: autogenerate this file */ - -/* Names of SHMEM registers: */ -static const value_string X300_SHMEM_NAMES[] = { - { 0, "X300_FW_SHMEM_COMPAT_NUM" }, - { 1, "X300_FW_SHMEM_GPSDO_STATUS" }, - { 2, "X300_FW_SHMEM_UART_RX_INDEX" }, - { 3, "X300_FW_SHMEM_UART_TX_INDEX" }, - { 5, "X300_FW_SHMEM_CLAIM_STATUS" }, - { 6, "X300_FW_SHMEM_CLAIM_TIME" }, - { 7, "X300_FW_SHMEM_CLAIM_SRC" }, - { 8, "X300_FW_SHMEM_UART_RX_ADDR" }, - { 9, "X300_FW_SHMEM_UART_TX_ADDR" }, - { 10, "X300_FW_SHMEM_UART_WORDS32" }, - { 11, "X300_FW_SHMEM_ROUTE_MAP_ADDR" }, - { 12, "X300_FW_SHMEM_ROUTE_MAP_LEN" } -}; - -- cgit v1.2.3 From 192ad7e01ac20efe23a14d0fe22a6fb745f8c4cf Mon Sep 17 00:00:00 2001 From: Derek Kozel <derek.kozel@ettus.com> Date: Fri, 26 Aug 2016 17:27:52 -0700 Subject: TwinRX: Fixed missing and redundant writes to FE settings TwinRX's Nyquist expert now writes the frontend correction settings on every tune to a new frequency. This guarantees phase alignment when timed commands are used and introduces minimal overhead. --- host/lib/usrp/dboard/twinrx/twinrx_experts.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/host/lib/usrp/dboard/twinrx/twinrx_experts.hpp b/host/lib/usrp/dboard/twinrx/twinrx_experts.hpp index f2601a09b..1617c9c80 100644 --- a/host/lib/usrp/dboard/twinrx/twinrx_experts.hpp +++ b/host/lib/usrp/dboard/twinrx/twinrx_experts.hpp @@ -266,12 +266,16 @@ public: : experts::worker_node_t(prepend_ch("twinrx_nyquist_expert", ch)), _channel (ch), _codec_conn (ch=="0"?"II":"QQ"), //Ch->ADC Port mapping + _lo1_freq_d (db, prepend_ch("los/LO1/freq/desired", ch)), + _lo2_freq_d (db, prepend_ch("los/LO2/freq/desired", ch)), _if_freq_d (db, prepend_ch("if_freq/desired", ch)), _lo1_inj_side (db, prepend_ch("ch/LO1/inj_side", ch)), _lo2_inj_side (db, prepend_ch("ch/LO2/inj_side", ch)), _if_freq_c (db, prepend_ch("if_freq/coerced", ch)), _db_iface (db_iface) { + bind_accessor(_lo1_freq_d); + bind_accessor(_lo2_freq_d); bind_accessor(_if_freq_d); bind_accessor(_lo1_inj_side); bind_accessor(_lo2_inj_side); @@ -284,6 +288,8 @@ private: //Inputs const std::string _channel; const std::string _codec_conn; + experts::data_reader_t<double> _lo1_freq_d; + experts::data_reader_t<double> _lo2_freq_d; experts::data_reader_t<double> _if_freq_d; experts::data_reader_t<lo_inj_side_t> _lo1_inj_side; experts::data_reader_t<lo_inj_side_t> _lo2_inj_side; -- cgit v1.2.3 From a9bfadd3253b57a15191a00baea2e57e1c56fac9 Mon Sep 17 00:00:00 2001 From: Sugandha Gupta <sugandha.gupta@ettus.com> Date: Wed, 17 Aug 2016 15:38:07 -0700 Subject: uhd: error on setting large recv_frame_size fixed #1212 --- host/lib/usrp/x300/x300_impl.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index ce81d5f1f..c545c6461 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -458,10 +458,12 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) } if ((mb.recv_args.has_key("recv_frame_size")) - && (req_max_frame_size.recv_frame_size < _max_frame_sizes.recv_frame_size)) { + && (req_max_frame_size.recv_frame_size > _max_frame_sizes.recv_frame_size)) { UHD_MSG(warning) << boost::format("You requested a receive frame size of (%lu) but your NIC's max frame size is (%lu).") - % req_max_frame_size.recv_frame_size << _max_frame_sizes.recv_frame_size << std::endl + % req_max_frame_size.recv_frame_size + % _max_frame_sizes.recv_frame_size + << std::endl << boost::format("Please verify your NIC's MTU setting using '%s' or set the recv_frame_size argument appropriately.") % mtu_tool << std::endl << "UHD will use the auto-detected max frame size for this connection." @@ -469,10 +471,12 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) } if ((mb.recv_args.has_key("send_frame_size")) - && (req_max_frame_size.send_frame_size < _max_frame_sizes.send_frame_size)) { + && (req_max_frame_size.send_frame_size > _max_frame_sizes.send_frame_size)) { UHD_MSG(warning) << boost::format("You requested a send frame size of (%lu) but your NIC's max frame size is (%lu).") - % req_max_frame_size.send_frame_size << _max_frame_sizes.send_frame_size << std::endl + % req_max_frame_size.send_frame_size + % _max_frame_sizes.send_frame_size + << std::endl << boost::format("Please verify your NIC's MTU setting using '%s' or set the send_frame_size argument appropriately.") % mtu_tool << std::endl << "UHD will use the auto-detected max frame size for this connection." @@ -1588,10 +1592,11 @@ x300_impl::frame_size_t x300_impl::determine_max_frame_size(const std::string &a if (!(uhd::ntohx<boost::uint32_t>(request->flags) & X300_MTU_DETECT_ECHO_REPLY)) throw uhd::not_implemented_error("Holler protocol not implemented"); + //Reducing range of (min,max) by setting max value to 10gig max_frame_size as larger sizes are not supported size_t min_recv_frame_size = sizeof(x300_mtu_t); - size_t max_recv_frame_size = user_frame_size.recv_frame_size; + size_t max_recv_frame_size = std::min(user_frame_size.recv_frame_size, X300_10GE_DATA_FRAME_MAX_SIZE) & size_t(~3); size_t min_send_frame_size = sizeof(x300_mtu_t); - size_t max_send_frame_size = user_frame_size.send_frame_size; + size_t max_send_frame_size = std::min(user_frame_size.send_frame_size, X300_10GE_DATA_FRAME_MAX_SIZE) & size_t(~3); UHD_MSG(status) << "Determining maximum frame size... "; while (min_recv_frame_size < max_recv_frame_size) -- cgit v1.2.3 From 15173a8b72e7c297920c8c982b5d7621b9d81e6d Mon Sep 17 00:00:00 2001 From: Derek Kozel <derek.kozel@ettus.com> Date: Tue, 23 Aug 2016 14:56:02 -0700 Subject: examples: Added TX and RX channels args in benchmark_rate --- host/examples/benchmark_rate.cpp | 53 ++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index b024c3a20..1ea754ef2 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -268,7 +268,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string rx_otw, tx_otw; std::string rx_cpu, tx_cpu; std::string mode, ref, pps; - std::string channel_list; + std::string channel_list, rx_channel_list, tx_channel_list; bool random_nsamps = false; atomic_bool burst_timer_elapsed(false); @@ -291,6 +291,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("mode", po::value<std::string>(&mode), "DEPRECATED - use \"ref\" and \"pps\" instead (none, mimo)") ("random", "Run with random values of samples in send() and recv() to stress-test the I/O.") ("channels", po::value<std::string>(&channel_list)->default_value("0"), "which channel(s) to use (specify \"0\", \"1\", \"0,1\", etc)") + ("rx_channels", po::value<std::string>(&rx_channel_list), "which RX channel(s) to use (specify \"0\", \"1\", \"0,1\", etc)") + ("tx_channels", po::value<std::string>(&tx_channel_list), "which TX channel(s) to use (specify \"0\", \"1\", \"0,1\", etc)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -394,20 +396,45 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } } - //detect which channels to use + //check that the device has sufficient RX and TX channels available std::vector<std::string> channel_strings; - std::vector<size_t> channel_nums; - boost::split(channel_strings, channel_list, boost::is_any_of("\"',")); - for(size_t ch = 0; ch < channel_strings.size(); ch++){ - size_t chan = boost::lexical_cast<int>(channel_strings[ch]); - if(chan >= usrp->get_tx_num_channels() or chan >= usrp->get_rx_num_channels()){ - throw std::runtime_error("Invalid channel(s) specified."); + std::vector<size_t> rx_channel_nums; + if (vm.count("rx_rate")) { + if (!vm.count("rx_channels")) { + rx_channel_list = channel_list; + } + + boost::split(channel_strings, rx_channel_list, boost::is_any_of("\"',")); + for (size_t ch = 0; ch < channel_strings.size(); ch++) { + size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + if (chan >= usrp->get_rx_num_channels()) { + throw std::runtime_error("Invalid channel(s) specified."); + } else { + rx_channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + } + } + } + + std::vector<size_t> tx_channel_nums; + if (vm.count("tx_rate")) { + if (!vm.count("tx_channels")) { + tx_channel_list = channel_list; + } + + boost::split(channel_strings, tx_channel_list, boost::is_any_of("\"',")); + for (size_t ch = 0; ch < channel_strings.size(); ch++) { + size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + if (chan >= usrp->get_tx_num_channels()) { + throw std::runtime_error("Invalid channel(s) specified."); + } else { + tx_channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + } } - else channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); } std::cout << boost::format("Setting device timestamp to 0...") << std::endl; - if (pps == "mimo" or ref == "mimo" or channel_nums.size() == 1) { + bool sync_channels = (pps == "mimo" or ref == "mimo" or (rx_channel_nums.size() <= 1 and tx_channel_nums.size() <= 1)); + if (!sync_channels) { usrp->set_time_now(0.0); } else { usrp->set_time_unknown_pps(uhd::time_spec_t(0.0)); @@ -418,7 +445,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_rx_rate(rx_rate); //create a receive streamer uhd::stream_args_t stream_args(rx_cpu, rx_otw); - stream_args.channels = channel_nums; + stream_args.channels = rx_channel_nums; uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); thread_group.create_thread(boost::bind(&benchmark_rx_rate, usrp, rx_cpu, rx_stream, random_nsamps, boost::ref(burst_timer_elapsed))); } @@ -428,7 +455,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_tx_rate(tx_rate); //create a transmit streamer uhd::stream_args_t stream_args(tx_cpu, tx_otw); - stream_args.channels = channel_nums; + stream_args.channels = tx_channel_nums; uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); thread_group.create_thread(boost::bind(&benchmark_tx_rate, usrp, tx_cpu, tx_stream, boost::ref(burst_timer_elapsed), random_nsamps)); thread_group.create_thread(boost::bind(&benchmark_tx_rate_async_helper, tx_stream, boost::ref(burst_timer_elapsed))); @@ -439,7 +466,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ const long usecs = long((duration - secs)*1e6); boost::this_thread::sleep(boost::posix_time::seconds(secs) + boost::posix_time::microseconds(usecs) - + boost::posix_time::milliseconds( (channel_nums.size() == 1) ? 0 : (INIT_DELAY * 1000)) + + boost::posix_time::milliseconds( (rx_channel_nums.size() <= 1 and tx_channel_nums.size() <= 1) ? 0 : (INIT_DELAY * 1000)) ); //interrupt and join the threads -- cgit v1.2.3 From 3c119b1a7f2ba4c6eb86dd15697ee53f0cadde4c Mon Sep 17 00:00:00 2001 From: Martin Braun <martin.braun@ettus.com> Date: Tue, 30 Aug 2016 10:23:06 -0700 Subject: tools: Added README for the dissectors --- tools/dissectors/README.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tools/dissectors/README.txt diff --git a/tools/dissectors/README.txt b/tools/dissectors/README.txt new file mode 100644 index 000000000..5119fbb1b --- /dev/null +++ b/tools/dissectors/README.txt @@ -0,0 +1,24 @@ +# Installing the Ettus Wireshark dissectors + + +1. Make sure you have the Wireshark 'dev' files available. On some + distributions, this requires a separate package (e.g. on Ubuntu, + you will need to install the wireshark-dev package) +2. Run these commands inside this directory: + + $ mkdir build + $ cd build + $ cmake .. + $ make && make install + + This will build and install the CHDR dissector. + +3. To build and install the other dissectors, re-run the commands + like so: + + $ cmake .. -DETTUS_DISSECTOR_NAME=zpu + $ make && make install + + Replace "zpu" with the name of the dissector you wish to install + (e.g. "octoclock"). + -- cgit v1.2.3 From 670eeda6e4c9ff2ab81f4e387bce49ea4dc79dcc Mon Sep 17 00:00:00 2001 From: Martin Braun <martin.braun@ettus.com> Date: Tue, 30 Aug 2016 15:04:31 -0700 Subject: debian: Fixed artifact removal in upload_debs.sh --- tools/debs/upload_debs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/debs/upload_debs.sh b/tools/debs/upload_debs.sh index 831eeb248..4cdb2f173 100755 --- a/tools/debs/upload_debs.sh +++ b/tools/debs/upload_debs.sh @@ -144,6 +144,6 @@ then if [ "$response" = "yes" ] then cd .. - rm -r ${UHD_TOP_LEVEL}/debian uhd-${VERSION} uhd_${VERSION}.orig.tar.xz uhd*dsc uhd*changes uhd*debian.tar.xz uhd*_source.build uhd*.upload + rm -r ${UHD_TOP_LEVEL}/debian uhd-${VERSION} uhd_${VERSION}.orig.tar.xz uhd*dsc uhd*changes uhd*debian.tar.* uhd*_source.build uhd*.upload fi fi -- cgit v1.2.3