diff options
Diffstat (limited to 'gr-blocks')
67 files changed, 72 insertions, 3340 deletions
diff --git a/gr-blocks/examples/msg_passing/strobe.grc b/gr-blocks/examples/msg_passing/strobe.grc index e5208713ef..6f599dff88 100644 --- a/gr-blocks/examples/msg_passing/strobe.grc +++ b/gr-blocks/examples/msg_passing/strobe.grc @@ -83,8 +83,8 @@ blocks: coordinate: [56, 180.0] rotation: 0 state: enabled -- name: blocks_pdu_to_tagged_stream_0 - id: blocks_pdu_to_tagged_stream +- name: pdu_pdu_to_tagged_stream_1 + id: pdu_pdu_to_tagged_stream parameters: affinity: '' alias: '' @@ -97,8 +97,8 @@ blocks: coordinate: [272, 188.0] rotation: 0 state: enabled -- name: blocks_tagged_stream_to_pdu_0 - id: blocks_tagged_stream_to_pdu +- name: pdu_tagged_stream_to_pdu_0 + id: pdu_tagged_stream_to_pdu parameters: affinity: '' alias: '' @@ -113,11 +113,11 @@ blocks: state: enabled connections: -- [blocks_copy_0, '0', blocks_tagged_stream_to_pdu_0, '0'] +- [blocks_copy_0, '0', pdu_tagged_stream_to_pdu_0, '0'] - [blocks_message_strobe_0, strobe, blocks_message_debug_0, print] -- [blocks_message_strobe_0_0, strobe, blocks_pdu_to_tagged_stream_0, pdus] -- [blocks_pdu_to_tagged_stream_0, '0', blocks_copy_0, '0'] -- [blocks_tagged_stream_to_pdu_0, pdus, blocks_message_debug_0, print_pdu] +- [blocks_message_strobe_0_0, strobe, pdu_pdu_to_tagged_stream_1, pdus] +- [pdu_pdu_to_tagged_stream_1, '0', blocks_copy_0, '0'] +- [pdu_tagged_stream_to_pdu_0, pdus, blocks_message_debug_0, print_pdu] metadata: file_format: 1 diff --git a/gr-blocks/grc/blocks.tree.yml b/gr-blocks/grc/blocks.tree.yml index c6a67cf39f..6e36974084 100644 --- a/gr-blocks/grc/blocks.tree.yml +++ b/gr-blocks/grc/blocks.tree.yml @@ -24,7 +24,6 @@ - blocks_vector_sink_x - blocks_tag_debug - blocks_message_debug - - blocks_random_pdu - blocks_message_strobe - blocks_message_strobe_random - blocks_tags_strobe @@ -87,13 +86,7 @@ - blocks_message_strobe - blocks_message_strobe_random - blocks_message_debug - - blocks_pdu_filter - - blocks_pdu_remove - - blocks_pdu_set - - blocks_pdu_to_tagged_stream - blocks_tagged_stream_multiply_length - - blocks_tagged_stream_to_pdu - - blocks_random_pdu - blocks_var_to_msg - blocks_msgpair_to_var - blocks_msg_meta_to_pair @@ -114,9 +107,6 @@ - Modulators: - blocks_vco_f - blocks_vco_c -- Networking Tools: - - blocks_tuntap_pdu - - blocks_socket_pdu - Peak Detectors: - blocks_burst_tagger - blocks_peak_detector_xb diff --git a/gr-blocks/grc/blocks_pdu_filter.block.yml b/gr-blocks/grc/blocks_pdu_filter.block.yml deleted file mode 100644 index e2138c5118..0000000000 --- a/gr-blocks/grc/blocks_pdu_filter.block.yml +++ /dev/null @@ -1,41 +0,0 @@ -id: blocks_pdu_filter -label: PDU Filter -flags: [ python ] - -parameters: -- id: k - label: Key - dtype: raw - default: pmt.intern("key") -- id: v - label: Value - dtype: raw - default: pmt.intern("value") -- id: invert - label: Invert Filter - dtype: bool - default: 'False' - options: ['False', 'True'] - option_labels: ['No', 'Yes'] - -inputs: -- domain: message - id: pdus - optional: true - -outputs: -- domain: message - id: pdus - optional: true - -templates: - imports: |- - from gnuradio import blocks - import pmt - make: blocks.pdu_filter(${k}, ${v}, ${invert}) - callbacks: - - set_key(${k}) - - set_val(${v}) - - set_inversion(${invert}) - -file_format: 1 diff --git a/gr-blocks/grc/blocks_pdu_remove.block.yml b/gr-blocks/grc/blocks_pdu_remove.block.yml deleted file mode 100644 index 225d57005e..0000000000 --- a/gr-blocks/grc/blocks_pdu_remove.block.yml +++ /dev/null @@ -1,29 +0,0 @@ -id: blocks_pdu_remove -label: PDU Remove -flags: [ python ] - -parameters: -- id: k - label: Key - dtype: raw - default: pmt.intern("key") - -inputs: -- domain: message - id: pdus - optional: true - -outputs: -- domain: message - id: pdus - optional: true - -templates: - imports: |- - from gnuradio import blocks - import pmt - make: blocks.pdu_remove(${k}) - callbacks: - - set_key(${k}) - -file_format: 1 diff --git a/gr-blocks/grc/blocks_pdu_set.block.yml b/gr-blocks/grc/blocks_pdu_set.block.yml deleted file mode 100644 index 7d90be3dad..0000000000 --- a/gr-blocks/grc/blocks_pdu_set.block.yml +++ /dev/null @@ -1,34 +0,0 @@ -id: blocks_pdu_set -label: PDU Set -flags: [ python ] - -parameters: -- id: k - label: Key - dtype: raw - default: pmt.intern("key") -- id: v - label: Value - dtype: raw - default: pmt.intern("value") - -inputs: -- domain: message - id: pdus - optional: true - -outputs: -- domain: message - id: pdus - optional: true - -templates: - imports: |- - from gnuradio import blocks - import pmt - make: blocks.pdu_set(${k}, ${v}) - callbacks: - - set_key(${k}) - - set_val(${v}) - -file_format: 1 diff --git a/gr-blocks/grc/blocks_pdu_to_tagged_stream.block.yml b/gr-blocks/grc/blocks_pdu_to_tagged_stream.block.yml deleted file mode 100644 index ae7271f767..0000000000 --- a/gr-blocks/grc/blocks_pdu_to_tagged_stream.block.yml +++ /dev/null @@ -1,37 +0,0 @@ -id: blocks_pdu_to_tagged_stream -label: PDU to Tagged Stream -flags: [ python, cpp ] - -parameters: -- id: type - label: Item Type - dtype: enum - options: [byte, complex, float] - option_attributes: - tv: [blocks.byte_t, blocks.complex_t, blocks.float_t] - hide: part -- id: tag - label: Length tag name - dtype: string - default: packet_len - -inputs: -- domain: message - id: pdus - -outputs: -- domain: stream - dtype: ${ type } - -templates: - imports: from gnuradio import blocks - make: blocks.pdu_to_tagged_stream(${type.tv}, ${tag}) - -cpp_templates: - includes: ['#include <gnuradio/blocks/pdu_to_tagged_stream.h>'] - declarations: 'blocks::pdu_to_tagged_stream::sptr ${id};' - make: 'this->${id} = blocks::pdu_to_tagged_stream::make(${type.tv}, ${tag});' - translations: - blocks.: 'blocks::' - -file_format: 1 diff --git a/gr-blocks/grc/blocks_random_pdu.block.yml b/gr-blocks/grc/blocks_random_pdu.block.yml deleted file mode 100644 index 540c144192..0000000000 --- a/gr-blocks/grc/blocks_random_pdu.block.yml +++ /dev/null @@ -1,39 +0,0 @@ -id: blocks_random_pdu -label: Random PDU Generator -flags: [ python ] - -parameters: -- id: minsize - label: Min Bytes - dtype: int - default: '50' -- id: maxsize - label: Max Bytes - dtype: int - default: '2000' -- id: mask - label: Byte Mask - dtype: int - default: '0xFF' -- id: length_modulo - label: Length Modulo - dtype: int - default: '2' - -inputs: -- domain: message - id: generate - optional: true - -outputs: -- domain: message - id: pdus - optional: true - -templates: - imports: |- - from gnuradio import blocks - import pmt - make: blocks.random_pdu(${minsize}, ${maxsize}, ${mask}, ${length_modulo}) - -file_format: 1 diff --git a/gr-blocks/grc/blocks_socket_pdu.block.yml b/gr-blocks/grc/blocks_socket_pdu.block.yml deleted file mode 100644 index 74108accb5..0000000000 --- a/gr-blocks/grc/blocks_socket_pdu.block.yml +++ /dev/null @@ -1,56 +0,0 @@ -id: blocks_socket_pdu -label: Socket PDU -flags: [ python, cpp ] - -parameters: -- id: type - label: Type - dtype: enum - default: TCP_SERVER - options: ["TCP_SERVER", "TCP_CLIENT", "UDP_SERVER", "UDP_CLIENT"] - option_labels: [TCP Server, TCP Client, UDP Server, UDP Client] -- id: host - label: Host - dtype: string -- id: port - label: Port - dtype: string - default: '52001' -- id: mtu - label: MTU - dtype: int - default: '10000' -- id: tcp_no_delay - label: TCP No Delay - dtype: enum - default: 'False' - options: ['True', 'False'] - option_labels: [Enabled, Disabled] - hide: ${ (( 'part' if (str(tcp_no_delay) == 'False') else 'none') if ((type == 'TCP_CLIENT') or (type == 'TCP_SERVER')) else 'all') } - -inputs: -- domain: message - id: pdus - optional: true - -outputs: -- domain: message - id: pdus - optional: true - -templates: - imports: from gnuradio import blocks - make: blocks.socket_pdu(${repr(type)}, ${host}, ${port}, ${mtu}, ${tcp_no_delay}) - -cpp_templates: - includes: ['#include <gnuradio/blocks/socket_pdu.h>'] - declarations: 'blocks::socket_pdu::sptr ${id};' - make: 'this->${id} = blocks::socket_pdu::make("${type}", ${host}, ${port}, ${mtu}, ${tcp_no_delay});' - translations: - 'True': 'true' - 'False': 'false' - -documentation: |- - For server modes, leave Host blank to bind to all interfaces (equivalent to 0.0.0.0). - -file_format: 1 diff --git a/gr-blocks/grc/blocks_tagged_stream_to_pdu.block.yml b/gr-blocks/grc/blocks_tagged_stream_to_pdu.block.yml deleted file mode 100644 index 54fafdeec1..0000000000 --- a/gr-blocks/grc/blocks_tagged_stream_to_pdu.block.yml +++ /dev/null @@ -1,36 +0,0 @@ -id: blocks_tagged_stream_to_pdu -label: Tagged Stream to PDU -flags: [ python ] - -parameters: -- id: type - label: Item Type - dtype: enum - options: [byte, complex, float] - option_attributes: - tv: [blocks.byte_t, blocks.complex_t, blocks.float_t] - hide: part -- id: tag - label: Length tag name - dtype: string - default: packet_len - -inputs: -- domain: stream - dtype: ${ type } - -outputs: -- domain: message - id: pdus - optional: true - -templates: - imports: from gnuradio import blocks - make: blocks.tagged_stream_to_pdu(${type.tv}, ${tag}) - -cpp_templates: - includes: ['#include <gnuradio/blocks/tagged_stream_to_pdu.h>'] - declarations: 'blocks::tagged_stream_to_pdu::sptr ${id};' - make: 'this->${id} = blocks::tagged_stream_to_pdu::make(${type.tv}, ${tag});' - -file_format: 1 diff --git a/gr-blocks/grc/blocks_tuntap_pdu.block.yml b/gr-blocks/grc/blocks_tuntap_pdu.block.yml deleted file mode 100644 index 2ab124eb02..0000000000 --- a/gr-blocks/grc/blocks_tuntap_pdu.block.yml +++ /dev/null @@ -1,43 +0,0 @@ -id: blocks_tuntap_pdu -label: TUNTAP PDU -flags: [ python, cpp ] - -parameters: -- id: ifn - label: Interface Name - dtype: string - default: tap0 -- id: mtu - label: MTU - dtype: int - default: '10000' -- id: istunflag - label: Flag - dtype: enum - default: 'False' - options: ['True', 'False'] - option_labels: [TUN(IP Packet), TAP(Ethernet Frame)] - -inputs: -- domain: message - id: pdus - optional: true - -outputs: -- domain: message - id: pdus - optional: true - -templates: - imports: from gnuradio import blocks - make: blocks.tuntap_pdu(${ifn}, ${mtu}, ${istunflag}) - -cpp_templates: - includes: ['#include <gnuradio/blocks/tuntap_pdu.h>'] - declarations: 'blocks::tuntap_pdu::sptr ${id};' - make: 'this->${id} = blocks::tuntap_pdu::make(${ifn}, ${mtu}, ${istunflag});' - translations: - 'True': 'true' - 'False': 'false' - -file_format: 1 diff --git a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt index 9f88792221..cadc355f7a 100644 --- a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt +++ b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt @@ -112,13 +112,7 @@ install(FILES or_blk.h pack_k_bits_bb.h patterned_interleaver.h - pdu.h - pdu_filter.h - pdu_set.h - pdu_remove.h - pdu_to_tagged_stream.h peak_detector2_fb.h - random_pdu.h plateau_detector_fb.h probe_rate.h regenerate_bb.h @@ -130,7 +124,6 @@ install(FILES short_to_char.h short_to_float.h skiphead.h - socket_pdu.h stream_demux.h stream_mux.h stream_to_streams.h @@ -146,14 +139,12 @@ install(FILES tagged_stream_align.h tagged_stream_mux.h tagged_stream_multiply_length.h - tagged_stream_to_pdu.h tags_strobe.h tcp_server_sink.h test_tag_variable_rate_ff.h threshold_ff.h throttle.h transcendental.h - tuntap_pdu.h uchar_to_float.h udp_sink.h udp_source.h diff --git a/gr-blocks/include/gnuradio/blocks/pdu.h b/gr-blocks/include/gnuradio/blocks/pdu.h deleted file mode 100644 index 5a54c9afe0..0000000000 --- a/gr-blocks/include/gnuradio/blocks/pdu.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_PDU_H -#define INCLUDED_BLOCKS_PDU_H - -#include <gnuradio/blocks/api.h> -#include <gnuradio/gr_complex.h> -#include <pmt/pmt.h> - - -namespace gr { -namespace blocks { -namespace pdu { -enum vector_type { byte_t, float_t, complex_t }; - -BLOCKS_API const pmt::pmt_t pdu_port_id(); -BLOCKS_API size_t itemsize(vector_type type); -BLOCKS_API bool type_matches(vector_type type, pmt::pmt_t v); -BLOCKS_API pmt::pmt_t make_pdu_vector(vector_type type, const uint8_t* buf, size_t items); -BLOCKS_API vector_type type_from_pmt(pmt::pmt_t vector); - -} /* namespace pdu */ -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_PDU_H */ diff --git a/gr-blocks/include/gnuradio/blocks/pdu_filter.h b/gr-blocks/include/gnuradio/blocks/pdu_filter.h deleted file mode 100644 index db43fc914e..0000000000 --- a/gr-blocks/include/gnuradio/blocks/pdu_filter.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_PDU_FILTER_H -#define INCLUDED_BLOCKS_PDU_FILTER_H - -#include <gnuradio/block.h> -#include <gnuradio/blocks/api.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Propagates only pdus containing k=>v in meta - * \ingroup message_tools_blk - * \ingroup debug_tools_blk - */ -class BLOCKS_API pdu_filter : virtual public block -{ -public: - // gr::blocks::pdu_filter::sptr - typedef std::shared_ptr<pdu_filter> sptr; - - /*! - * \brief Construct a PDU filter - */ - static sptr make(pmt::pmt_t k, pmt::pmt_t v, bool invert = false); - virtual void set_key(pmt::pmt_t key) = 0; - virtual void set_val(pmt::pmt_t val) = 0; - virtual void set_inversion(bool invert) = 0; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_PDU_FILTER_H */ diff --git a/gr-blocks/include/gnuradio/blocks/pdu_remove.h b/gr-blocks/include/gnuradio/blocks/pdu_remove.h deleted file mode 100644 index 266d917486..0000000000 --- a/gr-blocks/include/gnuradio/blocks/pdu_remove.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_PDU_REMOVE_H -#define INCLUDED_BLOCKS_PDU_REMOVE_H - -#include <gnuradio/block.h> -#include <gnuradio/blocks/api.h> - -namespace gr { -namespace blocks { - -/*! - * \brief remove key k in pdu's meta field and pass on - * \ingroup message_tools_blk - * \ingroup debug_tools_blk - */ -class BLOCKS_API pdu_remove : virtual public block -{ -public: - // gr::blocks::pdu_remove::sptr - typedef std::shared_ptr<pdu_remove> sptr; - - /*! - * \brief Construct a PDU meta remove block - */ - static sptr make(pmt::pmt_t k); - virtual void set_key(pmt::pmt_t key) = 0; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_PDU_REMOVE_H */ diff --git a/gr-blocks/include/gnuradio/blocks/pdu_set.h b/gr-blocks/include/gnuradio/blocks/pdu_set.h deleted file mode 100644 index fad755a9dc..0000000000 --- a/gr-blocks/include/gnuradio/blocks/pdu_set.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_PDU_SET_H -#define INCLUDED_BLOCKS_PDU_SET_H - -#include <gnuradio/block.h> -#include <gnuradio/blocks/api.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Set k=>v in pdu's meta field and pass on - * \ingroup message_tools_blk - * \ingroup debug_tools_blk - */ -class BLOCKS_API pdu_set : virtual public block -{ -public: - // gr::blocks::pdu_set::sptr - typedef std::shared_ptr<pdu_set> sptr; - - /*! - * \brief Construct a PDU meta set block - */ - static sptr make(pmt::pmt_t k, pmt::pmt_t v); - virtual void set_key(pmt::pmt_t key) = 0; - virtual void set_val(pmt::pmt_t val) = 0; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_PDU_SET_H */ diff --git a/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h b/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h deleted file mode 100644 index ec364a4248..0000000000 --- a/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H -#define INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H - -#include <gnuradio/blocks/api.h> -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/tagged_stream_block.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Turns received PDUs into a tagged stream of items - * \ingroup message_tools_blk - */ -class BLOCKS_API pdu_to_tagged_stream : virtual public tagged_stream_block -{ -public: - // gr::blocks::pdu_to_tagged_stream::sptr - typedef std::shared_ptr<pdu_to_tagged_stream> sptr; - - /*! - * \brief Construct a pdu_to_tagged_stream block - * \param type PDU type of pdu::vector_type - * \param lengthtagname The name of the tag that specifies how long the packet is. - * Defaults to 'packet_len'. - */ - static sptr make(pdu::vector_type type, - const std::string& lengthtagname = "packet_len"); -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H */ diff --git a/gr-blocks/include/gnuradio/blocks/random_pdu.h b/gr-blocks/include/gnuradio/blocks/random_pdu.h deleted file mode 100644 index 7c57d1de6c..0000000000 --- a/gr-blocks/include/gnuradio/blocks/random_pdu.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_RANDOM_PDU_H -#define INCLUDED_BLOCKS_RANDOM_PDU_H - -#include <gnuradio/block.h> -#include <gnuradio/blocks/api.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Sends a random PDU at intervals - * \ingroup message_tools_blk - * \ingroup debug_tools_blk - */ -class BLOCKS_API random_pdu : virtual public block -{ -public: - // gr::blocks::random_pdu::sptr - typedef std::shared_ptr<random_pdu> sptr; - - /*! - * \brief Construct a random PDU generator - */ - static sptr - make(int mintime, int maxtime, unsigned char byte_mask = 0xFF, int length_modulo = 1); -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_RANDOM_PDU_H */ diff --git a/gr-blocks/include/gnuradio/blocks/socket_pdu.h b/gr-blocks/include/gnuradio/blocks/socket_pdu.h deleted file mode 100644 index 50841a5237..0000000000 --- a/gr-blocks/include/gnuradio/blocks/socket_pdu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_SOCKET_PDU_H -#define INCLUDED_BLOCKS_SOCKET_PDU_H - -#include <gnuradio/block.h> -#include <gnuradio/blocks/api.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Creates socket interface and translates traffic to PDUs - * \ingroup networking_tools_blk - */ -class BLOCKS_API socket_pdu : virtual public block -{ -public: - // gr::blocks::socket_pdu::sptr - typedef std::shared_ptr<socket_pdu> sptr; - - /*! - * \brief Construct a SOCKET PDU interface - * \param type "TCP_SERVER", "TCP_CLIENT", "UDP_SERVER", or "UDP_CLIENT" - * \param addr network address to use - * \param port network port to use - * \param MTU maximum transmission unit - * \param tcp_no_delay TCP No Delay option (set to True to disable Nagle algorithm) - */ - static sptr make(std::string type, - std::string addr, - std::string port, - int MTU = 10000, - bool tcp_no_delay = false); -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_SOCKET_PDU_H */ diff --git a/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h b/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h deleted file mode 100644 index 74c7b74773..0000000000 --- a/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013,2014 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H -#define INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H - -#include <gnuradio/blocks/api.h> -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/tagged_stream_block.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Turns received stream data and tags into PDUs and sends - * them through a message port. - * \ingroup message_tools_blk - * - * The sent message is a PMT-pair (created by pmt::cons()). The - * first element is a dictionary containing all the tags. The - * second is a vector containing the actual data. - */ -class BLOCKS_API tagged_stream_to_pdu : virtual public tagged_stream_block -{ -public: - // gr::blocks::tagged_stream_to_pdu::sptr - typedef std::shared_ptr<tagged_stream_to_pdu> sptr; - - /*! - * \brief Construct a tagged_stream_to_pdu block - * \param type PDU type of pdu::vector_type - * \param lengthtagname The name of the tag that specifies - * how long the packet is. - */ - static sptr make(pdu::vector_type type, - const std::string& lengthtagname = "packet_len"); -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H */ diff --git a/gr-blocks/include/gnuradio/blocks/tuntap_pdu.h b/gr-blocks/include/gnuradio/blocks/tuntap_pdu.h deleted file mode 100644 index 90424d928d..0000000000 --- a/gr-blocks/include/gnuradio/blocks/tuntap_pdu.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_TUNTAP_PDU_H -#define INCLUDED_BLOCKS_TUNTAP_PDU_H - -#include <gnuradio/block.h> -#include <gnuradio/blocks/api.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Creates TUNTAP interface and translates traffic to PDUs - * \ingroup networking_tools_blk - */ -class BLOCKS_API tuntap_pdu : virtual public block -{ -public: - // gr::blocks::tuntap_pdu::sptr - typedef std::shared_ptr<tuntap_pdu> sptr; - - /*! - * \brief Construct a TUNTAP PDU interface - * \param dev Device name to create - * \param MTU Maximum Transmission Unit size - * \param istunflag Flag to indicate TUN or Tap - */ - static sptr make(std::string dev, int MTU = 10000, bool istunflag = false); -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_H */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index bfe3eaa91e..d9dd44692c 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -115,14 +115,8 @@ set(BLOCKS_SOURCES null_source_impl.cc pack_k_bits_bb_impl.cc patterned_interleaver_impl.cc - pdu.cc tag_debug_impl.cc - pdu_filter_impl.cc - pdu_set_impl.cc - pdu_remove_impl.cc - pdu_to_tagged_stream_impl.cc peak_detector2_fb_impl.cc - random_pdu_impl.cc plateau_detector_fb_impl.cc probe_rate_impl.cc regenerate_bb_impl.cc @@ -134,10 +128,8 @@ set(BLOCKS_SOURCES short_to_char_impl.cc short_to_float_impl.cc skiphead_impl.cc - socket_pdu_impl.cc stream_demux_impl.cc stream_mux_impl.cc - stream_pdu_base.cc stream_to_streams_impl.cc stream_to_tagged_stream_impl.cc stream_to_vector_impl.cc @@ -146,16 +138,13 @@ set(BLOCKS_SOURCES stretch_ff_impl.cc tag_share_impl.cc tagged_file_sink_impl.cc - tagged_stream_to_pdu_impl.cc tagged_stream_multiply_length_impl.cc tags_strobe_impl.cc test_tag_variable_rate_ff_impl.cc threshold_ff_impl.cc throttle_impl.cc transcendental_impl.cc - tcp_connection.cc tcp_server_sink_impl.cc - tuntap_pdu_impl.cc tag_gate_impl.cc tagged_stream_align_impl.cc tagged_stream_mux_impl.cc diff --git a/gr-blocks/lib/pdu.cc b/gr-blocks/lib/pdu.cc deleted file mode 100644 index ec44a10e57..0000000000 --- a/gr-blocks/lib/pdu.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gnuradio/blocks/pdu.h> - -namespace gr { -namespace blocks { -namespace pdu { - -const pmt::pmt_t pdu_port_id() -{ - static const pmt::pmt_t pdu_port_id = pmt::mp("pdus"); - return pdu_port_id; -} - -size_t itemsize(vector_type type) -{ - switch (type) { - case byte_t: - return sizeof(char); - case float_t: - return sizeof(float); - case complex_t: - return sizeof(gr_complex); - default: - throw std::runtime_error("bad PDU type"); - } -} - -bool type_matches(vector_type type, pmt::pmt_t v) -{ - switch (type) { - case byte_t: - return pmt::is_u8vector(v); - case float_t: - return pmt::is_f32vector(v); - case complex_t: - return pmt::is_c32vector(v); - default: - throw std::runtime_error("bad PDU type"); - } -} - -pmt::pmt_t make_pdu_vector(vector_type type, const uint8_t* buf, size_t items) -{ - switch (type) { - case byte_t: - return pmt::init_u8vector(items, buf); - case float_t: - return pmt::init_f32vector(items, (const float*)buf); - case complex_t: - return pmt::init_c32vector(items, (const gr_complex*)buf); - default: - throw std::runtime_error("bad PDU type"); - } -} - -vector_type type_from_pmt(pmt::pmt_t vector) -{ - if (pmt::is_u8vector(vector)) - return byte_t; - if (pmt::is_f32vector(vector)) - return float_t; - if (pmt::is_c32vector(vector)) - return complex_t; - throw std::runtime_error("bad PDU type"); -} - -} /* namespace pdu */ -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_filter_impl.cc b/gr-blocks/lib/pdu_filter_impl.cc deleted file mode 100644 index 686e7b678d..0000000000 --- a/gr-blocks/lib/pdu_filter_impl.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "pdu_filter_impl.h" -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/io_signature.h> - -namespace gr { -namespace blocks { - -pdu_filter::sptr pdu_filter::make(pmt::pmt_t k, pmt::pmt_t v, bool invert) -{ - return gnuradio::make_block_sptr<pdu_filter_impl>(k, v, invert); -} - -pdu_filter_impl::pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert) - : block("pdu_filter", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)), - d_k(k), - d_v(v), - d_invert(invert) -{ - message_port_register_out(pdu::pdu_port_id()); - message_port_register_in(pdu::pdu_port_id()); - set_msg_handler(pdu::pdu_port_id(), - [this](pmt::pmt_t msg) { this->handle_msg(msg); }); -} - -void pdu_filter_impl::handle_msg(pmt::pmt_t pdu) -{ - pmt::pmt_t meta = pmt::car(pdu); - bool output = d_invert; - - // check base type - // key exists - // value matches - if (pmt::is_dict(meta) && dict_has_key(meta, d_k) && - pmt::eqv(pmt::dict_ref(meta, d_k, pmt::PMT_NIL), d_v)) { - output = !d_invert; - } - - // if all tests pass, propagate the pdu - if (output) { - message_port_pub(pdu::pdu_port_id(), pdu); - } -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_filter_impl.h b/gr-blocks/lib/pdu_filter_impl.h deleted file mode 100644 index 7d3d9e7acd..0000000000 --- a/gr-blocks/lib/pdu_filter_impl.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_PDU_FILTER_IMPL_H -#define INCLUDED_BLOCKS_PDU_FILTER_IMPL_H - -#include <gnuradio/blocks/pdu_filter.h> - -namespace gr { -namespace blocks { - -class pdu_filter_impl : public pdu_filter -{ -private: - pmt::pmt_t d_k; - pmt::pmt_t d_v; - bool d_invert; - -public: - pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert); - void handle_msg(pmt::pmt_t msg); - void set_key(pmt::pmt_t key) override { d_k = key; }; - void set_val(pmt::pmt_t val) override { d_v = val; }; - void set_inversion(bool invert) override { d_invert = invert; }; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_PDU_FILTER_IMPL_H */ diff --git a/gr-blocks/lib/pdu_remove_impl.cc b/gr-blocks/lib/pdu_remove_impl.cc deleted file mode 100644 index ded25b6d49..0000000000 --- a/gr-blocks/lib/pdu_remove_impl.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "pdu_remove_impl.h" -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/io_signature.h> - -namespace gr { -namespace blocks { - -pdu_remove::sptr pdu_remove::make(pmt::pmt_t k) -{ - return gnuradio::make_block_sptr<pdu_remove_impl>(k); -} - -pdu_remove_impl::pdu_remove_impl(pmt::pmt_t k) - : block("pdu_remove", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)), - d_k(k) -{ - message_port_register_out(pdu::pdu_port_id()); - message_port_register_in(pdu::pdu_port_id()); - set_msg_handler(pdu::pdu_port_id(), - [this](pmt::pmt_t msg) { this->handle_msg(msg); }); -} - -void pdu_remove_impl::handle_msg(pmt::pmt_t pdu) -{ - // add the field and publish - pmt::pmt_t meta = pmt::car(pdu); - if (pmt::is_null(meta)) { - meta = pmt::make_dict(); - } else if (!pmt::is_dict(meta)) { - throw std::runtime_error("pdu_remove received non PDU input"); - } - meta = pmt::dict_delete(meta, d_k); - message_port_pub(pdu::pdu_port_id(), pmt::cons(meta, pmt::cdr(pdu))); -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_remove_impl.h b/gr-blocks/lib/pdu_remove_impl.h deleted file mode 100644 index 74c77d6e45..0000000000 --- a/gr-blocks/lib/pdu_remove_impl.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_PDU_REMOVE_IMPL_H -#define INCLUDED_BLOCKS_PDU_REMOVE_IMPL_H - -#include <gnuradio/blocks/pdu_remove.h> - -namespace gr { -namespace blocks { - -class pdu_remove_impl : public pdu_remove -{ -private: - pmt::pmt_t d_k; - -public: - pdu_remove_impl(pmt::pmt_t k); - void handle_msg(pmt::pmt_t msg); - void set_key(pmt::pmt_t key) override { d_k = key; }; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_PDU_REMOVE_IMPL_H */ diff --git a/gr-blocks/lib/pdu_set_impl.cc b/gr-blocks/lib/pdu_set_impl.cc deleted file mode 100644 index 70a8487720..0000000000 --- a/gr-blocks/lib/pdu_set_impl.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "pdu_set_impl.h" -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/io_signature.h> - -namespace gr { -namespace blocks { - -pdu_set::sptr pdu_set::make(pmt::pmt_t k, pmt::pmt_t v) -{ - return gnuradio::make_block_sptr<pdu_set_impl>(k, v); -} - -pdu_set_impl::pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v) - : block("pdu_set", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)), - d_k(k), - d_v(v) -{ - message_port_register_out(pdu::pdu_port_id()); - message_port_register_in(pdu::pdu_port_id()); - set_msg_handler(pdu::pdu_port_id(), - [this](pmt::pmt_t msg) { this->handle_msg(msg); }); -} - -void pdu_set_impl::handle_msg(pmt::pmt_t pdu) -{ - // add the field and publish - pmt::pmt_t meta = pmt::car(pdu); - if (pmt::is_null(meta)) { - meta = pmt::make_dict(); - } else if (!pmt::is_dict(meta)) { - throw std::runtime_error("pdu_set received non PDU input"); - } - meta = pmt::dict_add(meta, d_k, d_v); - message_port_pub(pdu::pdu_port_id(), pmt::cons(meta, pmt::cdr(pdu))); -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_set_impl.h b/gr-blocks/lib/pdu_set_impl.h deleted file mode 100644 index fbfae9dd03..0000000000 --- a/gr-blocks/lib/pdu_set_impl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_PDU_SET_IMPL_H -#define INCLUDED_BLOCKS_PDU_SET_IMPL_H - -#include <gnuradio/blocks/pdu_set.h> - -namespace gr { -namespace blocks { - -class pdu_set_impl : public pdu_set -{ -private: - pmt::pmt_t d_k; - pmt::pmt_t d_v; - -public: - pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v); - void handle_msg(pmt::pmt_t msg); - void set_key(pmt::pmt_t key) override { d_k = key; }; - void set_val(pmt::pmt_t val) override { d_v = val; }; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_PDU_SET_IMPL_H */ diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc deleted file mode 100644 index 26b86bee83..0000000000 --- a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "pdu_to_tagged_stream_impl.h" -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/io_signature.h> - -namespace gr { -namespace blocks { - -pdu_to_tagged_stream::sptr pdu_to_tagged_stream::make(pdu::vector_type type, - const std::string& tsb_tag_key) -{ - return gnuradio::make_block_sptr<pdu_to_tagged_stream_impl>(type, tsb_tag_key); -} - -pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type, - const std::string& tsb_tag_key) - : tagged_stream_block("pdu_to_tagged_stream", - io_signature::make(0, 0, 0), - io_signature::make(1, 1, pdu::itemsize(type)), - tsb_tag_key), - d_itemsize(pdu::itemsize(type)), - d_curr_len(0) -{ - message_port_register_in(pdu::pdu_port_id()); -} - -int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int&) -{ - if (d_curr_len == 0) { - pmt::pmt_t msg(delete_head_nowait(pdu::pdu_port_id())); - if (msg.get() == NULL) { - return 0; - } - - if (!pmt::is_pair(msg)) - throw std::runtime_error("received a malformed pdu message"); - - d_curr_meta = pmt::car(msg); - d_curr_vect = pmt::cdr(msg); - // do not assume the length of PMT is in items (e.g.: from socket_pdu) - d_curr_len = pmt::blob_length(d_curr_vect) / d_itemsize; - } - - return d_curr_len; -} - -int pdu_to_tagged_stream_impl::work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) -{ - uint8_t* out = (uint8_t*)output_items[0]; - - if (d_curr_len == 0) { - return 0; - } - - // work() should only be called if the current PDU fits entirely - // into the output buffer. - assert(noutput_items >= 0 && (unsigned int)noutput_items >= d_curr_len); - - // Copy vector output - size_t nout = d_curr_len; - size_t io(0); - const uint8_t* ptr = (const uint8_t*)uniform_vector_elements(d_curr_vect, io); - memcpy(out, ptr, d_curr_len * d_itemsize); - - // Copy tags - if (!pmt::eq(d_curr_meta, pmt::PMT_NIL)) { - pmt::pmt_t klist(pmt::dict_keys(d_curr_meta)); - for (size_t i = 0; i < pmt::length(klist); i++) { - pmt::pmt_t k(pmt::nth(i, klist)); - pmt::pmt_t v(pmt::dict_ref(d_curr_meta, k, pmt::PMT_NIL)); - add_item_tag(0, nitems_written(0), k, v, alias_pmt()); - } - } - - // Reset state - d_curr_len = 0; - - return nout; -} /* work() */ - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.h b/gr-blocks/lib/pdu_to_tagged_stream_impl.h deleted file mode 100644 index 0a389fb040..0000000000 --- a/gr-blocks/lib/pdu_to_tagged_stream_impl.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H -#define INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H - -#include <gnuradio/blocks/pdu_to_tagged_stream.h> - -namespace gr { -namespace blocks { - -class BLOCKS_API pdu_to_tagged_stream_impl : public pdu_to_tagged_stream -{ - const size_t d_itemsize; - pmt::pmt_t d_curr_meta; - pmt::pmt_t d_curr_vect; - size_t d_curr_len; - -public: - pdu_to_tagged_stream_impl(pdu::vector_type type, - const std::string& lengthtagname = "packet_len"); - - int calculate_output_stream_length(const gr_vector_int& ninput_items) override; - - int work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) override; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H */ diff --git a/gr-blocks/lib/random_pdu_impl.cc b/gr-blocks/lib/random_pdu_impl.cc deleted file mode 100644 index 2a8e1eb7f5..0000000000 --- a/gr-blocks/lib/random_pdu_impl.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "random_pdu_impl.h" -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/io_signature.h> - -namespace gr { -namespace blocks { - -random_pdu::sptr -random_pdu::make(int min_items, int max_items, unsigned char byte_mask, int length_modulo) -{ - return gnuradio::make_block_sptr<random_pdu_impl>( - min_items, max_items, byte_mask, length_modulo); -} - -random_pdu_impl::random_pdu_impl(int min_items, - int max_items, - unsigned char byte_mask, - int length_modulo) - : block("random_pdu", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)), - d_urange(min_items, max_items), - d_brange(0, 255), - d_mask(byte_mask), - d_length_modulo(length_modulo) -{ - message_port_register_out(pdu::pdu_port_id()); - message_port_register_in(pmt::mp("generate")); - set_msg_handler(pmt::mp("generate"), - [this](pmt::pmt_t msg) { this->generate_pdu(msg); }); - if (length_modulo < 1) - throw std::runtime_error("length_module must be >= 1"); - if (max_items < length_modulo) - throw std::runtime_error("max_items must be >= to length_modulo"); -} - -bool random_pdu_impl::start() -{ - output_random(); - return true; -} - -void random_pdu_impl::output_random() -{ - // pick a random vector length - int len = d_urange(d_rng); - len = std::max(d_length_modulo, len - len % d_length_modulo); - - // fill it with random bytes - std::vector<unsigned char> vec(len); - for (int i = 0; i < len; i++) - vec[i] = ((unsigned char)d_brange(d_rng)) & d_mask; - - // send the vector - pmt::pmt_t vecpmt(pmt::make_blob(&vec[0], len)); - pmt::pmt_t pdu(pmt::cons(pmt::PMT_NIL, vecpmt)); - - message_port_pub(pdu::pdu_port_id(), pdu); -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/random_pdu_impl.h b/gr-blocks/lib/random_pdu_impl.h deleted file mode 100644 index 7f0b87c90c..0000000000 --- a/gr-blocks/lib/random_pdu_impl.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_RANDOM_PDU_IMPL_H -#define INCLUDED_BLOCKS_RANDOM_PDU_IMPL_H - -#include <gnuradio/blocks/random_pdu.h> -#include <boost/generator_iterator.hpp> - -#include <random> - -namespace gr { -namespace blocks { - -class random_pdu_impl : public random_pdu -{ -private: - std::mt19937 d_rng; - std::uniform_int_distribution<> d_urange; - std::uniform_int_distribution<> d_brange; - const unsigned char d_mask; - const int d_length_modulo; - -public: - random_pdu_impl(int min_items, - int max_items, - unsigned char byte_mask, - int length_modulo); - - bool start() override; - void output_random(); - void generate_pdu(pmt::pmt_t msg) { output_random(); } - void generate_pdu() { output_random(); } -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_RANDOM_PDU_IMPL_H */ diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc deleted file mode 100644 index f30e944d7b..0000000000 --- a/gr-blocks/lib/socket_pdu_impl.cc +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013,2019 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "socket_pdu_impl.h" -#include "tcp_connection.h" -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/io_signature.h> - -namespace gr { -namespace blocks { - -socket_pdu::sptr socket_pdu::make(std::string type, - std::string addr, - std::string port, - int MTU /*= 10000*/, - bool tcp_no_delay /*= false*/) -{ - return gnuradio::make_block_sptr<socket_pdu_impl>( - type, addr, port, MTU, tcp_no_delay); -} - -socket_pdu_impl::socket_pdu_impl(std::string type, - std::string addr, - std::string port, - int MTU /*= 10000*/, - bool tcp_no_delay /*= false*/) - : block("socket_pdu", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)), - d_tcp_no_delay(tcp_no_delay) -{ - d_rxbuf.resize(MTU); - - message_port_register_in(pdu::pdu_port_id()); - message_port_register_out(pdu::pdu_port_id()); - - if ((type == "TCP_SERVER") && - ((addr.empty()) || (addr == "0.0.0.0"))) { // Bind on all interfaces - int port_num = atoi(port.c_str()); - if (port_num == 0) - throw std::invalid_argument( - "gr::blocks:socket_pdu: invalid port for TCP_SERVER"); - d_tcp_endpoint = - boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port_num); - } else if ((type == "TCP_SERVER") || (type == "TCP_CLIENT")) { - boost::asio::ip::tcp::resolver resolver(d_io_service); - boost::asio::ip::tcp::resolver::query query( - boost::asio::ip::tcp::v4(), - addr, - port, - boost::asio::ip::resolver_query_base::passive); - d_tcp_endpoint = *resolver.resolve(query); - } else if ((type == "UDP_SERVER") && - ((addr.empty()) || (addr == "0.0.0.0"))) { // Bind on all interfaces - int port_num = atoi(port.c_str()); - if (port_num == 0) - throw std::invalid_argument( - "gr::blocks:socket_pdu: invalid port for UDP_SERVER"); - d_udp_endpoint = - boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), port_num); - } else if ((type == "UDP_SERVER") || (type == "UDP_CLIENT")) { - boost::asio::ip::udp::resolver resolver(d_io_service); - boost::asio::ip::udp::resolver::query query( - boost::asio::ip::udp::v4(), - addr, - port, - boost::asio::ip::resolver_query_base::passive); - - if (type == "UDP_SERVER") - d_udp_endpoint = *resolver.resolve(query); - else - d_udp_endpoint_other = *resolver.resolve(query); - } - - if (type == "TCP_SERVER") { - d_acceptor_tcp = std::make_shared<boost::asio::ip::tcp::acceptor>(d_io_service, - d_tcp_endpoint); - d_acceptor_tcp->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); - - start_tcp_accept(); - - set_msg_handler(pdu::pdu_port_id(), - [this](pmt::pmt_t msg) { this->tcp_server_send(msg); }); - } else if (type == "TCP_CLIENT") { - boost::system::error_code error = boost::asio::error::host_not_found; - d_tcp_socket = std::make_shared<boost::asio::ip::tcp::socket>(d_io_service); - d_tcp_socket->connect(d_tcp_endpoint, error); - if (error) - throw boost::system::system_error(error); - d_tcp_socket->set_option(boost::asio::ip::tcp::no_delay(d_tcp_no_delay)); - - set_msg_handler(pdu::pdu_port_id(), - [this](pmt::pmt_t msg) { this->tcp_client_send(msg); }); - - d_tcp_socket->async_read_some( - boost::asio::buffer(d_rxbuf), - boost::bind(&socket_pdu_impl::handle_tcp_read, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - } else if (type == "UDP_SERVER") { - d_udp_socket = - std::make_shared<boost::asio::ip::udp::socket>(d_io_service, d_udp_endpoint); - d_udp_socket->async_receive_from( - boost::asio::buffer(d_rxbuf), - d_udp_endpoint_other, - boost::bind(&socket_pdu_impl::handle_udp_read, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - - set_msg_handler(pdu::pdu_port_id(), - [this](pmt::pmt_t msg) { this->udp_send(msg); }); - } else if (type == "UDP_CLIENT") { - d_udp_socket = - std::make_shared<boost::asio::ip::udp::socket>(d_io_service, d_udp_endpoint); - d_udp_socket->async_receive_from( - boost::asio::buffer(d_rxbuf), - d_udp_endpoint_other, - boost::bind(&socket_pdu_impl::handle_udp_read, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - - set_msg_handler(pdu::pdu_port_id(), - [this](pmt::pmt_t msg) { this->udp_send(msg); }); - } else - throw std::runtime_error("gr::blocks:socket_pdu: unknown socket type"); - - d_thread = gr::thread::thread(boost::bind(&socket_pdu_impl::run_io_service, this)); - d_started = true; -} - -socket_pdu_impl::~socket_pdu_impl() { stop(); } - -bool socket_pdu_impl::stop() -{ - if (d_started) { - d_io_service.stop(); - d_thread.interrupt(); - d_thread.join(); - } - d_started = false; - return true; -} - -void socket_pdu_impl::handle_tcp_read(const boost::system::error_code& error, - size_t bytes_transferred) -{ - if (!error) { - pmt::pmt_t vector = - pmt::init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]); - pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector); - message_port_pub(pdu::pdu_port_id(), pdu); - - d_tcp_socket->async_read_some( - boost::asio::buffer(d_rxbuf), - boost::bind(&socket_pdu_impl::handle_tcp_read, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - } else - throw boost::system::system_error(error); -} - -void socket_pdu_impl::start_tcp_accept() -{ -#if (BOOST_VERSION >= 107000) - tcp_connection::sptr new_connection = - tcp_connection::make(d_io_service, d_rxbuf.size(), d_tcp_no_delay); -#else - tcp_connection::sptr new_connection = tcp_connection::make( - d_acceptor_tcp->get_io_service(), d_rxbuf.size(), d_tcp_no_delay); -#endif - - d_acceptor_tcp->async_accept(new_connection->socket(), - boost::bind(&socket_pdu_impl::handle_tcp_accept, - this, - new_connection, - boost::asio::placeholders::error)); -} - -void socket_pdu_impl::tcp_server_send(pmt::pmt_t msg) -{ - pmt::pmt_t vector = pmt::cdr(msg); - for (size_t i = 0; i < d_tcp_connections.size(); i++) - d_tcp_connections[i]->send(vector); -} - -void socket_pdu_impl::handle_tcp_accept(tcp_connection::sptr new_connection, - const boost::system::error_code& error) -{ - if (!error) { - // Garbage collect closed sockets - std::vector<tcp_connection::sptr>::iterator it = d_tcp_connections.begin(); - while (it != d_tcp_connections.end()) { - if (!(**it).socket().is_open()) - it = d_tcp_connections.erase(it); - else - ++it; - } - - new_connection->start(this); - d_tcp_connections.push_back(new_connection); - start_tcp_accept(); - } else - std::cout << error << std::endl; -} - -void socket_pdu_impl::tcp_client_send(pmt::pmt_t msg) -{ - pmt::pmt_t vector = pmt::cdr(msg); - size_t len = pmt::blob_length(vector); - size_t offset = 0; - std::vector<char> txbuf(std::min(len, d_rxbuf.size())); - while (offset < len) { - size_t send_len = std::min((len - offset), txbuf.size()); - memcpy(&txbuf[0], pmt::uniform_vector_elements(vector, offset), send_len); - offset += send_len; - d_tcp_socket->send(boost::asio::buffer(txbuf, send_len)); - } -} - -void socket_pdu_impl::udp_send(pmt::pmt_t msg) -{ - if (d_udp_endpoint_other.address().to_string() == "0.0.0.0") - return; - - pmt::pmt_t vector = pmt::cdr(msg); - size_t len = pmt::blob_length(vector); - size_t offset = 0; - std::vector<char> txbuf(std::min(len, d_rxbuf.size())); - while (offset < len) { - size_t send_len = std::min((len - offset), txbuf.size()); - memcpy(&txbuf[0], pmt::uniform_vector_elements(vector, offset), send_len); - offset += send_len; - d_udp_socket->send_to(boost::asio::buffer(txbuf, send_len), d_udp_endpoint_other); - } -} - -void socket_pdu_impl::handle_udp_read(const boost::system::error_code& error, - size_t bytes_transferred) -{ - if (!error) { - pmt::pmt_t vector = - pmt::init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]); - pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector); - - message_port_pub(pdu::pdu_port_id(), pdu); - - d_udp_socket->async_receive_from( - boost::asio::buffer(d_rxbuf), - d_udp_endpoint_other, - boost::bind(&socket_pdu_impl::handle_udp_read, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - } -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/socket_pdu_impl.h b/gr-blocks/lib/socket_pdu_impl.h deleted file mode 100644 index d885c665c4..0000000000 --- a/gr-blocks/lib/socket_pdu_impl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H -#define INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H - -#include "tcp_connection.h" -#include <gnuradio/blocks/socket_pdu.h> - -namespace gr { -namespace blocks { - -class socket_pdu_impl : public socket_pdu -{ -private: - boost::asio::io_service d_io_service; - std::vector<char> d_rxbuf; - void run_io_service() { d_io_service.run(); } - gr::thread::thread d_thread; - bool d_started; - - // TCP specific - boost::asio::ip::tcp::endpoint d_tcp_endpoint; - std::vector<tcp_connection::sptr> d_tcp_connections; - void handle_tcp_read(const boost::system::error_code& error, - size_t bytes_transferred); - const bool d_tcp_no_delay; - - // TCP server specific - std::shared_ptr<boost::asio::ip::tcp::acceptor> d_acceptor_tcp; - void start_tcp_accept(); - void tcp_server_send(pmt::pmt_t msg); - void handle_tcp_accept(tcp_connection::sptr new_connection, - const boost::system::error_code& error); - - // TCP client specific - std::shared_ptr<boost::asio::ip::tcp::socket> d_tcp_socket; - void tcp_client_send(pmt::pmt_t msg); - - // UDP specific - boost::asio::ip::udp::endpoint d_udp_endpoint; - boost::asio::ip::udp::endpoint d_udp_endpoint_other; - std::shared_ptr<boost::asio::ip::udp::socket> d_udp_socket; - void handle_udp_read(const boost::system::error_code& error, - size_t bytes_transferred); - void udp_send(pmt::pmt_t msg); - -public: - socket_pdu_impl(std::string type, - std::string addr, - std::string port, - int MTU = 10000, - bool tcp_no_delay = false); - ~socket_pdu_impl() override; - bool stop() override; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H */ diff --git a/gr-blocks/lib/stream_pdu_base.cc b/gr-blocks/lib/stream_pdu_base.cc deleted file mode 100644 index 97e99e8886..0000000000 --- a/gr-blocks/lib/stream_pdu_base.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef HAVE_IO_H -#include <io.h> -#endif - -#ifdef HAVE_WINDOWS_H -#include <winsock2.h> -#endif - -#include "stream_pdu_base.h" -#include <gnuradio/basic_block.h> -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/logger.h> -#include <boost/format.hpp> - -static const long timeout_us = 100 * 1000; // 100ms - -namespace gr { -namespace blocks { - -stream_pdu_base::stream_pdu_base(int MTU) : d_fd(-1), d_started(false), d_finished(false) -{ - gr::configure_default_loggers(d_pdu_logger, d_pdu_debug_logger, "stream_pdu_base"); - // reserve space for rx buffer - d_rxbuf.resize(MTU, 0); -} - -stream_pdu_base::~stream_pdu_base() { stop_rxthread(); } - -void stream_pdu_base::start_rxthread(basic_block* blk, pmt::pmt_t port) -{ - d_blk = blk; - d_port = port; - d_thread = gr::thread::thread(std::bind(&stream_pdu_base::run, this)); - d_started = true; -} - -void stream_pdu_base::stop_rxthread() -{ - d_finished = true; - - if (d_started) { - d_thread.interrupt(); - d_thread.join(); - } -} - -void stream_pdu_base::run() -{ - while (!d_finished) { - if (!wait_ready()) - continue; - - const int result = read(d_fd, &d_rxbuf[0], d_rxbuf.size()); - if (result <= 0) - throw std::runtime_error("stream_pdu_base, bad socket read!"); - - pmt::pmt_t vector = pmt::init_u8vector(result, &d_rxbuf[0]); - pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector); - - d_blk->message_port_pub(d_port, pdu); - } -} - -bool stream_pdu_base::wait_ready() -{ - // setup timeval for timeout - timeval tv; - tv.tv_sec = 0; - tv.tv_usec = timeout_us; - - // setup rset for timeout - fd_set rset; - FD_ZERO(&rset); - FD_SET(d_fd, &rset); - - // call select with timeout on receive socket - return ::select(d_fd + 1, &rset, NULL, NULL, &tv) > 0; -} - -void stream_pdu_base::send(pmt::pmt_t msg) -{ - pmt::pmt_t vector = pmt::cdr(msg); - size_t offset(0); - size_t itemsize(pdu::itemsize(pdu::type_from_pmt(vector))); - int len(pmt::length(vector) * itemsize); - - const int rv = write(d_fd, pmt::uniform_vector_elements(vector, offset), len); - if (rv != len) { - static auto msg = boost::format( - "stream_pdu_base::send(pdu) write failed! (d_fd=%d, len=%d, rv=%d)"); - GR_LOG_WARN(d_pdu_logger, msg % d_fd % len % rv); - } -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/stream_pdu_base.h b/gr-blocks/lib/stream_pdu_base.h deleted file mode 100644 index 9ca1f32043..0000000000 --- a/gr-blocks/lib/stream_pdu_base.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_STREAM_PDU_BASE_H -#define INCLUDED_STREAM_PDU_BASE_H - -#include <gnuradio/basic_block.h> -#include <gnuradio/logger.h> -#include <gnuradio/thread/thread.h> -#include <pmt/pmt.h> - -class basic_block; - -namespace gr { -namespace blocks { - -class stream_pdu_base -{ -public: - stream_pdu_base(int MTU = 10000); - ~stream_pdu_base(); - -protected: - int d_fd; - bool d_started; - bool d_finished; - std::vector<uint8_t> d_rxbuf; - gr::thread::thread d_thread; - - pmt::pmt_t d_port; - basic_block* d_blk; - - void run(); - void send(pmt::pmt_t msg); - bool wait_ready(); - void start_rxthread(basic_block* blk, pmt::pmt_t rxport); - void stop_rxthread(); - - gr::logger_ptr d_pdu_logger, d_pdu_debug_logger; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_STREAM_PDU_BASE_H */ diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc deleted file mode 100644 index 2ca5e8e68f..0000000000 --- a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "tagged_stream_to_pdu_impl.h" -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/io_signature.h> - -namespace gr { -namespace blocks { - -tagged_stream_to_pdu::sptr tagged_stream_to_pdu::make(pdu::vector_type type, - const std::string& lengthtagname) -{ - return gnuradio::make_block_sptr<tagged_stream_to_pdu_impl>(type, lengthtagname); -} - -tagged_stream_to_pdu_impl::tagged_stream_to_pdu_impl(pdu::vector_type type, - const std::string& lengthtagname) - : tagged_stream_block("tagged_stream_to_pdu", - io_signature::make(1, 1, pdu::itemsize(type)), - io_signature::make(0, 0, 0), - lengthtagname), - d_type(type), - d_pdu_meta(pmt::PMT_NIL), - d_pdu_vector(pmt::PMT_NIL) -{ - message_port_register_out(pdu::pdu_port_id()); -} - -int tagged_stream_to_pdu_impl::work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) -{ - const uint8_t* in = (const uint8_t*)input_items[0]; - - // Grab tags, throw them into dict - get_tags_in_range(d_tags, 0, nitems_read(0), nitems_read(0) + ninput_items[0]); - d_pdu_meta = pmt::make_dict(); - for (const auto& tag : d_tags) { - d_pdu_meta = dict_add(d_pdu_meta, tag.key, tag.value); - } - - // Grab data, throw into vector - d_pdu_vector = pdu::make_pdu_vector(d_type, in, ninput_items[0]); - - // Send msg - pmt::pmt_t msg = pmt::cons(d_pdu_meta, d_pdu_vector); - message_port_pub(pdu::pdu_port_id(), msg); - - return ninput_items[0]; -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.h b/gr-blocks/lib/tagged_stream_to_pdu_impl.h deleted file mode 100644 index 954a710200..0000000000 --- a/gr-blocks/lib/tagged_stream_to_pdu_impl.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_TAGGED_STREAM_TO_PDU_IMPL_H -#define INCLUDED_TAGGED_STREAM_TO_PDU_IMPL_H - -#include <gnuradio/blocks/tagged_stream_to_pdu.h> - -namespace gr { -namespace blocks { - -class BLOCKS_API tagged_stream_to_pdu_impl : public tagged_stream_to_pdu -{ - const pdu::vector_type d_type; - pmt::pmt_t d_pdu_meta; - pmt::pmt_t d_pdu_vector; - std::vector<tag_t> d_tags; - -public: - tagged_stream_to_pdu_impl(pdu::vector_type type, const std::string& lengthtagname); - - int work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) override; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc deleted file mode 100644 index 76f42614e9..0000000000 --- a/gr-blocks/lib/tcp_connection.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "tcp_connection.h" -#include <gnuradio/basic_block.h> -#include <gnuradio/blocks/pdu.h> - -namespace gr { -namespace blocks { - -tcp_connection::sptr tcp_connection::make(boost::asio::io_service& io_service, - int MTU /*= 10000*/, - bool no_delay /*=false*/) -{ - return sptr(new tcp_connection(io_service, MTU, no_delay)); -} - -tcp_connection::tcp_connection(boost::asio::io_service& io_service, - int MTU /*= 10000*/, - bool no_delay /*=false*/) - : d_socket(io_service), d_buf(MTU), d_block(NULL), d_no_delay(no_delay) -{ - try { - d_socket.set_option(boost::asio::ip::tcp::no_delay(no_delay)); - } catch (...) { - // Silently ignore failure (socket might be current in accept stage) and try again - // in 'start' - } -} - -void tcp_connection::send(pmt::pmt_t vector) -{ - size_t len = pmt::blob_length(vector); - - // Asio async_write() requires the buffer to remain valid until the handler is called. - auto txbuf = std::make_shared<std::vector<char>>(len); - - size_t temp = 0; - memcpy(txbuf->data(), pmt::uniform_vector_elements(vector, temp), len); - - size_t offset = 0; - while (offset < len) { - // Limit the size of each write() to the MTU. - // FIXME: Note that this has the effect of breaking a large PDU into several - // smaller PDUs, each containing <= MTU bytes. Is this the desired behavior? - size_t send_len = std::min((len - offset), d_buf.size()); - boost::asio::async_write( - d_socket, - boost::asio::buffer(txbuf->data() + offset, send_len), - [txbuf](const boost::system::error_code& error, size_t bytes_transferred) {}); - offset += send_len; - } -} - -void tcp_connection::start(gr::basic_block* block) -{ - d_block = block; - d_socket.set_option(boost::asio::ip::tcp::no_delay(d_no_delay)); - d_socket.async_read_some(boost::asio::buffer(d_buf), - boost::bind(&tcp_connection::handle_read, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); -} - -void tcp_connection::handle_read(const boost::system::error_code& error, - size_t bytes_transferred) -{ - if (!error) { - if (d_block) { - pmt::pmt_t vector = - pmt::init_u8vector(bytes_transferred, (const uint8_t*)&d_buf[0]); - pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector); - - d_block->message_port_pub(pdu::pdu_port_id(), pdu); - } - - d_socket.async_read_some( - boost::asio::buffer(d_buf), - boost::bind(&tcp_connection::handle_read, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); - } else { - d_socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both); - d_socket.close(); - } -} -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/tcp_connection.h b/gr-blocks/lib/tcp_connection.h deleted file mode 100644 index f97f8a605b..0000000000 --- a/gr-blocks/lib/tcp_connection.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_TCP_CONNECTION_H -#define INCLUDED_TCP_CONNECTION_H - -#include <pmt/pmt.h> -#include <boost/array.hpp> -#include <boost/asio.hpp> -#include <memory> - -namespace gr { - -class basic_block; - -namespace blocks { - -class tcp_connection -{ -private: - boost::asio::ip::tcp::socket d_socket; - std::vector<char> d_buf; - basic_block* d_block; - bool d_no_delay; - - tcp_connection(boost::asio::io_service& io_service, - int MTU = 10000, - bool no_delay = false); - - void handle_read(const boost::system::error_code& error, size_t bytes_transferred); - -public: - typedef std::shared_ptr<tcp_connection> sptr; - - static sptr - make(boost::asio::io_service& io_service, int MTU = 10000, bool no_delay = false); - - boost::asio::ip::tcp::socket& socket() { return d_socket; }; - - void start(gr::basic_block* block); - void send(pmt::pmt_t vector); -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_TCP_CONNECTION_H */ diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc deleted file mode 100644 index 048c33c392..0000000000 --- a/gr-blocks/lib/tuntap_pdu_impl.cc +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "tuntap_pdu_impl.h" -#include <gnuradio/blocks/pdu.h> -#include <gnuradio/io_signature.h> -#include <boost/format.hpp> - -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> - -#if (defined(linux) || defined(__linux) || defined(__linux__)) -#include <arpa/inet.h> -#include <linux/if.h> -#include <sys/ioctl.h> -#endif - -namespace gr { -namespace blocks { - -tuntap_pdu::sptr tuntap_pdu::make(std::string dev, int MTU, bool istunflag) -{ -#if (defined(linux) || defined(__linux) || defined(__linux__)) - return gnuradio::make_block_sptr<tuntap_pdu_impl>(dev, MTU, istunflag); -#else - throw std::runtime_error("tuntap_pdu not implemented on this platform"); -#endif -} - -#if (defined(linux) || defined(__linux) || defined(__linux__)) -tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU, bool istunflag) - : block("tuntap_pdu", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)), - stream_pdu_base(istunflag ? MTU : MTU + 14), - d_dev(dev), - d_istunflag(istunflag) -{ - // make the tuntap - char dev_cstr[IFNAMSIZ]; - memset(dev_cstr, 0x00, IFNAMSIZ); - strncpy(dev_cstr, dev.c_str(), IFNAMSIZ); - dev_cstr[IFNAMSIZ - 1] = '\0'; - - bool istun = d_istunflag; - if (istun) { - d_fd = tun_alloc(dev_cstr, (IFF_TUN | IFF_NO_PI)); - } else { - d_fd = tun_alloc(dev_cstr, (IFF_TAP | IFF_NO_PI)); - } - - if (d_fd <= 0) - throw std::runtime_error( - "gr::tuntap_pdu::make: tun_alloc failed (are you running as root?)"); - - int err = set_mtu(dev_cstr, MTU); - if (err < 0) { - std::ostringstream msg; - msg << boost::format("failed to set MTU to %d. You should use ifconfig to set " - "the MTU. E.g., `$ sudo ifconfig %s mtu %d`") % - MTU % dev % MTU; - GR_LOG_ERROR(d_logger, msg.str()); - } - - - std::cout << boost::format("Allocated virtual ethernet interface: %s\n" - "You must now use ifconfig to set its IP address. E.g.,\n" - " $ sudo ifconfig %s 192.168.200.1\n" - "Be sure to use a different address in the same subnet " - "for each machine.\n") % - dev % dev - << std::endl; - - // set up output message port - message_port_register_out(pdu::pdu_port_id()); - start_rxthread(this, pdu::pdu_port_id()); - - // set up input message port - message_port_register_in(pdu::pdu_port_id()); - set_msg_handler(pdu::pdu_port_id(), [this](pmt::pmt_t msg) { this->send(msg); }); -} - -int tuntap_pdu_impl::tun_alloc(char* dev, int flags) -{ - struct ifreq ifr; - int fd, err; - const char* clonedev = "/dev/net/tun"; - - /* Arguments taken by the function: - * - * char *dev: the name of an interface (or '\0'). MUST have enough - * space to hold the interface name if '\0' is passed - * int flags: interface flags (eg, IFF_TUN etc.) - */ - - /* open the clone device */ - if ((fd = open(clonedev, O_RDWR)) < 0) - return fd; - - /* preparation of the struct ifr, of type "struct ifreq" */ - memset(&ifr, 0, sizeof(ifr)); - - ifr.ifr_flags = flags; /* IFF_TUN or IFF_TAP, plus maybe IFF_NO_PI */ - - /* if a device name was specified, put it in the structure; otherwise, - * the kernel will try to allocate the "next" device of the - * specified type - */ - if (*dev) - strncpy(ifr.ifr_name, dev, IFNAMSIZ - 1); - - /* try to create the device */ - if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0) { - close(fd); - return err; - } - - /* if the operation was successful, write back the name of the - * interface to the variable "dev", so the caller can know - * it. Note that the caller MUST reserve space in *dev (see calling - * code below) - */ - strcpy(dev, ifr.ifr_name); - - /* this is the special file descriptor that the caller will use to talk - * with the virtual interface - */ - return fd; -} - -int tuntap_pdu_impl::set_mtu(const char* dev, int MTU) -{ - struct ifreq ifr; - int sfd, err; - - /* MTU must be set by passing a socket fd to ioctl; - * create an arbitrary socket for this purpose - */ - if ((sfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - return sfd; - - /* preparation of the struct ifr, of type "struct ifreq" */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, dev, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ - 1] = '\0'; - ifr.ifr_addr.sa_family = AF_INET; /* address family */ - ifr.ifr_mtu = MTU; - - /* try to set MTU */ - if ((err = ioctl(sfd, SIOCSIFMTU, (void*)&ifr)) < 0) { - close(sfd); - return err; - } - - close(sfd); - return MTU; -} -#endif - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/tuntap_pdu_impl.h b/gr-blocks/lib/tuntap_pdu_impl.h deleted file mode 100644 index 86149443f9..0000000000 --- a/gr-blocks/lib/tuntap_pdu_impl.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H -#define INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H - -#include "stream_pdu_base.h" -#include <gnuradio/blocks/tuntap_pdu.h> - -#if (defined(linux) || defined(__linux) || defined(__linux__)) -#include <linux/if_tun.h> -#endif - -namespace gr { -namespace blocks { - -class tuntap_pdu_impl : public tuntap_pdu, public stream_pdu_base -{ -#if (defined(linux) || defined(__linux) || defined(__linux__)) -private: - const std::string d_dev; - const bool d_istunflag; - int tun_alloc(char* dev, int flags); - int set_mtu(const char* dev, int MTU); - -public: - tuntap_pdu_impl(std::string dev, int MTU, bool istunflag); -#endif -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H */ diff --git a/gr-blocks/python/blocks/CMakeLists.txt b/gr-blocks/python/blocks/CMakeLists.txt index ab1176c765..25ae7755d5 100644 --- a/gr-blocks/python/blocks/CMakeLists.txt +++ b/gr-blocks/python/blocks/CMakeLists.txt @@ -16,6 +16,7 @@ GR_PYTHON_INSTALL( msg_pair_to_var.py msg_meta_to_pair.py var_to_msg.py + pdu_compatibility.py # REMOVE IN 3.11 DESTINATION ${GR_PYTHON_DIR}/gnuradio/blocks ) diff --git a/gr-blocks/python/blocks/__init__.py b/gr-blocks/python/blocks/__init__.py index 270c26fd1a..337380d819 100644 --- a/gr-blocks/python/blocks/__init__.py +++ b/gr-blocks/python/blocks/__init__.py @@ -35,3 +35,6 @@ multiply_vcc = multiply_cc multiply_vff = multiply_ff multiply_vii = multiply_ii multiply_vss = multiply_ss + +# Compatibility layer for transition to gr-pdu. Scheduled for removal in 3.11. +from .pdu_compatibility import * diff --git a/gr-blocks/python/blocks/bindings/CMakeLists.txt b/gr-blocks/python/blocks/bindings/CMakeLists.txt index 257afe0119..28e9c22537 100644 --- a/gr-blocks/python/blocks/bindings/CMakeLists.txt +++ b/gr-blocks/python/blocks/bindings/CMakeLists.txt @@ -104,11 +104,6 @@ list(APPEND blocks_python_files pack_k_bits_bb_python.cc packed_to_unpacked_python.cc patterned_interleaver_python.cc - pdu_python.cc - pdu_filter_python.cc - pdu_remove_python.cc - pdu_set_python.cc - pdu_to_tagged_stream_python.cc peak_detector_python.cc peak_detector2_fb_python.cc phase_shift_python.cc @@ -116,7 +111,6 @@ list(APPEND blocks_python_files probe_rate_python.cc probe_signal_python.cc probe_signal_v_python.cc - random_pdu_python.cc regenerate_bb_python.cc repack_bits_bb_python.cc repeat_python.cc @@ -129,7 +123,6 @@ list(APPEND blocks_python_files short_to_char_python.cc short_to_float_python.cc skiphead_python.cc - socket_pdu_python.cc stream_demux_python.cc stream_mux_python.cc stream_to_streams_python.cc @@ -146,7 +139,6 @@ list(APPEND blocks_python_files tagged_stream_align_python.cc tagged_stream_multiply_length_python.cc tagged_stream_mux_python.cc - tagged_stream_to_pdu_python.cc tags_strobe_python.cc tcp_server_sink_python.cc test_tag_variable_rate_ff_python.cc @@ -154,7 +146,6 @@ list(APPEND blocks_python_files throttle_python.cc transcendental_python.cc tsb_vector_sink_python.cc - tuntap_pdu_python.cc uchar_to_float_python.cc udp_sink_python.cc udp_source_python.cc diff --git a/gr-blocks/python/blocks/bindings/docstrings/pdu_filter_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/pdu_filter_pydoc_template.h deleted file mode 100644 index a4e9d0d06b..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/pdu_filter_pydoc_template.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_pdu_filter = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_filter_pdu_filter_0 = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_filter_pdu_filter_1 = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_filter_make = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_filter_set_key = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_filter_set_val = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_filter_set_inversion = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/pdu_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/pdu_pydoc_template.h deleted file mode 100644 index 8f16734a4c..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/pdu_pydoc_template.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_pdu_pdu_port_id = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_itemsize = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_type_matches = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_make_pdu_vector = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_type_from_pmt = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/pdu_remove_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/pdu_remove_pydoc_template.h deleted file mode 100644 index 62b512fde5..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/pdu_remove_pydoc_template.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_pdu_remove = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_remove_pdu_remove_0 = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_remove_pdu_remove_1 = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_remove_make = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_remove_set_key = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/pdu_set_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/pdu_set_pydoc_template.h deleted file mode 100644 index cbe2a27503..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/pdu_set_pydoc_template.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_pdu_set = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_set_pdu_set_0 = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_set_pdu_set_1 = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_set_make = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_set_set_key = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_set_set_val = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/pdu_to_tagged_stream_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/pdu_to_tagged_stream_pydoc_template.h deleted file mode 100644 index 2ab003a60b..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/pdu_to_tagged_stream_pydoc_template.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_pdu_to_tagged_stream = R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_to_tagged_stream_pdu_to_tagged_stream = - R"doc()doc"; - - -static const char* __doc_gr_blocks_pdu_to_tagged_stream_make = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/random_pdu_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/random_pdu_pydoc_template.h deleted file mode 100644 index b5a4e94ae2..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/random_pdu_pydoc_template.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_random_pdu = R"doc()doc"; - - -static const char* __doc_gr_blocks_random_pdu_random_pdu = R"doc()doc"; - - -static const char* __doc_gr_blocks_random_pdu_make = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/socket_pdu_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/socket_pdu_pydoc_template.h deleted file mode 100644 index 07aa3eb239..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/socket_pdu_pydoc_template.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_socket_pdu = R"doc()doc"; - - -static const char* __doc_gr_blocks_socket_pdu_socket_pdu = R"doc()doc"; - - -static const char* __doc_gr_blocks_socket_pdu_make = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/tagged_stream_to_pdu_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/tagged_stream_to_pdu_pydoc_template.h deleted file mode 100644 index 76d15951ba..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/tagged_stream_to_pdu_pydoc_template.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_tagged_stream_to_pdu = R"doc()doc"; - - -static const char* __doc_gr_blocks_tagged_stream_to_pdu_tagged_stream_to_pdu = - R"doc()doc"; - - -static const char* __doc_gr_blocks_tagged_stream_to_pdu_make = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/tuntap_pdu_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/tuntap_pdu_pydoc_template.h deleted file mode 100644 index eea7349e62..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/tuntap_pdu_pydoc_template.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_tuntap_pdu = R"doc()doc"; - - -static const char* __doc_gr_blocks_tuntap_pdu_tuntap_pdu = R"doc()doc"; - - -static const char* __doc_gr_blocks_tuntap_pdu_make = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/pdu_filter_python.cc b/gr-blocks/python/blocks/bindings/pdu_filter_python.cc deleted file mode 100644 index 7c805c016d..0000000000 --- a/gr-blocks/python/blocks/bindings/pdu_filter_python.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(pdu_filter.h) */ -/* BINDTOOL_HEADER_FILE_HASH(73336eabe264d9670a63e914e96742b1) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/pdu_filter.h> -// pydoc.h is automatically generated in the build directory -#include <pdu_filter_pydoc.h> - -void bind_pdu_filter(py::module& m) -{ - - using pdu_filter = ::gr::blocks::pdu_filter; - - - py::class_<pdu_filter, gr::block, gr::basic_block, std::shared_ptr<pdu_filter>>( - m, "pdu_filter", D(pdu_filter)) - - .def(py::init(&pdu_filter::make), - py::arg("k"), - py::arg("v"), - py::arg("invert") = false, - D(pdu_filter, make)) - - - .def("set_key", &pdu_filter::set_key, py::arg("key"), D(pdu_filter, set_key)) - - - .def("set_val", &pdu_filter::set_val, py::arg("val"), D(pdu_filter, set_val)) - - - .def("set_inversion", - &pdu_filter::set_inversion, - py::arg("invert"), - D(pdu_filter, set_inversion)) - - ; -} diff --git a/gr-blocks/python/blocks/bindings/pdu_python.cc b/gr-blocks/python/blocks/bindings/pdu_python.cc deleted file mode 100644 index 89cd8a11a4..0000000000 --- a/gr-blocks/python/blocks/bindings/pdu_python.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(pdu.h) */ -/* BINDTOOL_HEADER_FILE_HASH(8c678dd50c4df86cbc74dc58b1b5010d) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/pdu.h> -// pydoc.h is automatically generated in the build directory -#include <pdu_pydoc.h> - -void bind_pdu(py::module& m) -{ - - - py::module m_pdu = m.def_submodule("pdu"); - - // TODO - clean up pdu subnamespace -- should these enums go under pdu, or under - // blocks? - py::enum_<::gr::blocks::pdu::vector_type>(m, "vector_type") - .value("byte_t", ::gr::blocks::pdu::byte_t) // 0 - .value("float_t", ::gr::blocks::pdu::float_t) // 1 - .value("complex_t", ::gr::blocks::pdu::complex_t) // 2 - .export_values(); - - py::implicitly_convertible<int, ::gr::blocks::pdu::vector_type>(); - - m_pdu.def("pdu_port_id", &::gr::blocks::pdu::pdu_port_id, D(pdu, pdu_port_id)); - - - m_pdu.def( - "itemsize", &::gr::blocks::pdu::itemsize, py::arg("type"), D(pdu, itemsize)); - - - m_pdu.def("type_matches", - &::gr::blocks::pdu::type_matches, - py::arg("type"), - py::arg("v"), - D(pdu, type_matches)); - - - m_pdu.def("make_pdu_vector", - &::gr::blocks::pdu::make_pdu_vector, - py::arg("type"), - py::arg("buf"), - py::arg("items"), - D(pdu, make_pdu_vector)); - - - m_pdu.def("type_from_pmt", - &::gr::blocks::pdu::type_from_pmt, - py::arg("vector"), - D(pdu, type_from_pmt)); -} diff --git a/gr-blocks/python/blocks/bindings/pdu_remove_python.cc b/gr-blocks/python/blocks/bindings/pdu_remove_python.cc deleted file mode 100644 index be6524e216..0000000000 --- a/gr-blocks/python/blocks/bindings/pdu_remove_python.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(pdu_remove.h) */ -/* BINDTOOL_HEADER_FILE_HASH(62afe4d010e89d91f3276e3299231a4f) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/pdu_remove.h> -// pydoc.h is automatically generated in the build directory -#include <pdu_remove_pydoc.h> - -void bind_pdu_remove(py::module& m) -{ - - using pdu_remove = ::gr::blocks::pdu_remove; - - - py::class_<pdu_remove, gr::block, gr::basic_block, std::shared_ptr<pdu_remove>>( - m, "pdu_remove", D(pdu_remove)) - - .def(py::init(&pdu_remove::make), py::arg("k"), D(pdu_remove, make)) - - - .def("set_key", &pdu_remove::set_key, py::arg("key"), D(pdu_remove, set_key)) - - ; -} diff --git a/gr-blocks/python/blocks/bindings/pdu_set_python.cc b/gr-blocks/python/blocks/bindings/pdu_set_python.cc deleted file mode 100644 index 3fa4c1d12f..0000000000 --- a/gr-blocks/python/blocks/bindings/pdu_set_python.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(pdu_set.h) */ -/* BINDTOOL_HEADER_FILE_HASH(4716b531c993ca09cb8cdad1100e317a) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/pdu_set.h> -// pydoc.h is automatically generated in the build directory -#include <pdu_set_pydoc.h> - -void bind_pdu_set(py::module& m) -{ - - using pdu_set = ::gr::blocks::pdu_set; - - - py::class_<pdu_set, gr::block, gr::basic_block, std::shared_ptr<pdu_set>>( - m, "pdu_set", D(pdu_set)) - - .def(py::init(&pdu_set::make), py::arg("k"), py::arg("v"), D(pdu_set, make)) - - - .def("set_key", &pdu_set::set_key, py::arg("key"), D(pdu_set, set_key)) - - - .def("set_val", &pdu_set::set_val, py::arg("val"), D(pdu_set, set_val)) - - ; -} diff --git a/gr-blocks/python/blocks/bindings/pdu_to_tagged_stream_python.cc b/gr-blocks/python/blocks/bindings/pdu_to_tagged_stream_python.cc deleted file mode 100644 index 51ec743f26..0000000000 --- a/gr-blocks/python/blocks/bindings/pdu_to_tagged_stream_python.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(pdu_to_tagged_stream.h) */ -/* BINDTOOL_HEADER_FILE_HASH(122377a925d85481a5dd9f86e75e909b) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/pdu_to_tagged_stream.h> -// pydoc.h is automatically generated in the build directory -#include <pdu_to_tagged_stream_pydoc.h> - -void bind_pdu_to_tagged_stream(py::module& m) -{ - - using pdu_to_tagged_stream = ::gr::blocks::pdu_to_tagged_stream; - - - py::class_<pdu_to_tagged_stream, - gr::tagged_stream_block, - gr::block, - gr::basic_block, - std::shared_ptr<pdu_to_tagged_stream>>( - m, "pdu_to_tagged_stream", D(pdu_to_tagged_stream)) - - .def(py::init(&pdu_to_tagged_stream::make), - py::arg("type"), - py::arg("lengthtagname") = "packet_len", - D(pdu_to_tagged_stream, make)) - - - ; - - - py::module m_pdu = m.def_submodule("pdu"); -} diff --git a/gr-blocks/python/blocks/bindings/python_bindings.cc b/gr-blocks/python/blocks/bindings/python_bindings.cc index 155ce38b19..a9435c7107 100644 --- a/gr-blocks/python/blocks/bindings/python_bindings.cc +++ b/gr-blocks/python/blocks/bindings/python_bindings.cc @@ -108,11 +108,6 @@ void bind_or_blk(py::module&); void bind_pack_k_bits_bb(py::module&); void bind_packed_to_unpacked(py::module&); void bind_patterned_interleaver(py::module&); -void bind_pdu(py::module&); -void bind_pdu_filter(py::module&); -void bind_pdu_remove(py::module&); -void bind_pdu_set(py::module&); -void bind_pdu_to_tagged_stream(py::module&); void bind_peak_detector(py::module&); void bind_peak_detector2_fb(py::module&); void bind_phase_shift(py::module&); @@ -120,7 +115,6 @@ void bind_plateau_detector_fb(py::module&); void bind_probe_rate(py::module&); void bind_probe_signal(py::module&); void bind_probe_signal_v(py::module&); -void bind_random_pdu(py::module&); void bind_regenerate_bb(py::module&); void bind_repack_bits_bb(py::module&); void bind_repeat(py::module&); @@ -133,7 +127,6 @@ void bind_selector(py::module&); void bind_short_to_char(py::module&); void bind_short_to_float(py::module&); void bind_skiphead(py::module&); -void bind_socket_pdu(py::module&); void bind_stream_demux(py::module&); void bind_stream_mux(py::module&); void bind_stream_to_streams(py::module&); @@ -150,7 +143,6 @@ void bind_tagged_file_sink(py::module&); void bind_tagged_stream_align(py::module&); void bind_tagged_stream_multiply_length(py::module&); void bind_tagged_stream_mux(py::module&); -void bind_tagged_stream_to_pdu(py::module&); void bind_tags_strobe(py::module&); void bind_tcp_server_sink(py::module&); void bind_test_tag_variable_rate_ff(py::module&); @@ -158,7 +150,6 @@ void bind_threshold_ff(py::module&); void bind_throttle(py::module&); void bind_transcendental(py::module&); void bind_tsb_vector_sink(py::module&); -void bind_tuntap_pdu(py::module&); void bind_uchar_to_float(py::module&); void bind_udp_sink(py::module&); void bind_udp_source(py::module&); @@ -292,18 +283,12 @@ PYBIND11_MODULE(blocks_python, m) bind_pack_k_bits_bb(m); bind_packed_to_unpacked(m); bind_patterned_interleaver(m); - bind_pdu(m); - bind_pdu_filter(m); - bind_pdu_remove(m); - bind_pdu_set(m); - bind_pdu_to_tagged_stream(m); bind_peak_detector(m); bind_peak_detector2_fb(m); bind_plateau_detector_fb(m); bind_probe_rate(m); bind_probe_signal(m); bind_probe_signal_v(m); - bind_random_pdu(m); bind_regenerate_bb(m); bind_repack_bits_bb(m); bind_repeat(m); @@ -316,7 +301,6 @@ PYBIND11_MODULE(blocks_python, m) bind_short_to_char(m); bind_short_to_float(m); bind_skiphead(m); - bind_socket_pdu(m); bind_stream_demux(m); bind_stream_mux(m); bind_stream_to_streams(m); @@ -333,7 +317,6 @@ PYBIND11_MODULE(blocks_python, m) bind_tagged_stream_align(m); bind_tagged_stream_multiply_length(m); bind_tagged_stream_mux(m); - bind_tagged_stream_to_pdu(m); bind_tags_strobe(m); bind_tcp_server_sink(m); bind_test_tag_variable_rate_ff(m); @@ -341,7 +324,6 @@ PYBIND11_MODULE(blocks_python, m) bind_throttle(m); bind_transcendental(m); bind_tsb_vector_sink(m); - bind_tuntap_pdu(m); bind_uchar_to_float(m); bind_udp_sink(m); bind_udp_source(m); diff --git a/gr-blocks/python/blocks/bindings/random_pdu_python.cc b/gr-blocks/python/blocks/bindings/random_pdu_python.cc deleted file mode 100644 index 430f466b1f..0000000000 --- a/gr-blocks/python/blocks/bindings/random_pdu_python.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(random_pdu.h) */ -/* BINDTOOL_HEADER_FILE_HASH(31da08cfe8a287467bf91fd51612180f) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/random_pdu.h> -// pydoc.h is automatically generated in the build directory -#include <random_pdu_pydoc.h> - -void bind_random_pdu(py::module& m) -{ - - using random_pdu = ::gr::blocks::random_pdu; - - - py::class_<random_pdu, gr::block, gr::basic_block, std::shared_ptr<random_pdu>>( - m, "random_pdu", D(random_pdu)) - - .def(py::init(&random_pdu::make), - py::arg("mintime"), - py::arg("maxtime"), - py::arg("byte_mask") = 255, - py::arg("length_modulo") = 1, - D(random_pdu, make)) - - - ; -} diff --git a/gr-blocks/python/blocks/bindings/socket_pdu_python.cc b/gr-blocks/python/blocks/bindings/socket_pdu_python.cc deleted file mode 100644 index 138567bd5e..0000000000 --- a/gr-blocks/python/blocks/bindings/socket_pdu_python.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(socket_pdu.h) */ -/* BINDTOOL_HEADER_FILE_HASH(22b717395ed280a5f4f9ac0bd31d2986) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/socket_pdu.h> -// pydoc.h is automatically generated in the build directory -#include <socket_pdu_pydoc.h> - -void bind_socket_pdu(py::module& m) -{ - - using socket_pdu = ::gr::blocks::socket_pdu; - - - py::class_<socket_pdu, gr::block, gr::basic_block, std::shared_ptr<socket_pdu>>( - m, "socket_pdu", D(socket_pdu)) - - .def(py::init(&socket_pdu::make), - py::arg("type"), - py::arg("addr"), - py::arg("port"), - py::arg("MTU") = 10000, - py::arg("tcp_no_delay") = false, - D(socket_pdu, make)) - - - ; -} diff --git a/gr-blocks/python/blocks/bindings/tagged_stream_to_pdu_python.cc b/gr-blocks/python/blocks/bindings/tagged_stream_to_pdu_python.cc deleted file mode 100644 index 80146c36f7..0000000000 --- a/gr-blocks/python/blocks/bindings/tagged_stream_to_pdu_python.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(tagged_stream_to_pdu.h) */ -/* BINDTOOL_HEADER_FILE_HASH(b521afb9e6e75ef2df0909cebf85166e) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/tagged_stream_to_pdu.h> -// pydoc.h is automatically generated in the build directory -#include <tagged_stream_to_pdu_pydoc.h> - -void bind_tagged_stream_to_pdu(py::module& m) -{ - - using tagged_stream_to_pdu = ::gr::blocks::tagged_stream_to_pdu; - - - py::class_<tagged_stream_to_pdu, - gr::tagged_stream_block, - gr::block, - gr::basic_block, - std::shared_ptr<tagged_stream_to_pdu>>( - m, "tagged_stream_to_pdu", D(tagged_stream_to_pdu)) - - .def(py::init(&tagged_stream_to_pdu::make), - py::arg("type"), - py::arg("lengthtagname") = "packet_len", - D(tagged_stream_to_pdu, make)) - - - ; - - - py::module m_pdu = m.def_submodule("pdu"); -} diff --git a/gr-blocks/python/blocks/bindings/tuntap_pdu_python.cc b/gr-blocks/python/blocks/bindings/tuntap_pdu_python.cc deleted file mode 100644 index 376bfc0527..0000000000 --- a/gr-blocks/python/blocks/bindings/tuntap_pdu_python.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(tuntap_pdu.h) */ -/* BINDTOOL_HEADER_FILE_HASH(b56c8af7086f7d50d4d768ab5e99b839) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/tuntap_pdu.h> -// pydoc.h is automatically generated in the build directory -#include <tuntap_pdu_pydoc.h> - -void bind_tuntap_pdu(py::module& m) -{ - - using tuntap_pdu = ::gr::blocks::tuntap_pdu; - - - py::class_<tuntap_pdu, gr::block, gr::basic_block, std::shared_ptr<tuntap_pdu>>( - m, "tuntap_pdu", D(tuntap_pdu)) - - .def(py::init(&tuntap_pdu::make), - py::arg("dev"), - py::arg("MTU") = 10000, - py::arg("istunflag") = false, - D(tuntap_pdu, make)) - - - ; -} diff --git a/gr-blocks/python/blocks/pdu_compatibility.py b/gr-blocks/python/blocks/pdu_compatibility.py new file mode 100644 index 0000000000..3d6af5f548 --- /dev/null +++ b/gr-blocks/python/blocks/pdu_compatibility.py @@ -0,0 +1,60 @@ +# +# Copyright 2021 Jacob Gilbert +# +# This file is part of GNU Radio +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# + +''' +Compatibility layer for transition to gr-pdu. Scheduled for removal in 3.11. +''' + + +from gnuradio import gr, network, pdu + +######## PDU BLOCKS MOVED TO GR-PDU ######## + +class pdu_filter(pdu.pdu_filter): + def __init__(self, *args, **kwargs): + gr.log.warn('`pdu_filter` has moved to gr-pdu and will be removed from gr-blocks soon. Please update to use pdu.pdu_filter()') + pdu.pdu_filter.__init__(self, *args, **kwargs) + +class pdu_remove(pdu.pdu_remove): + def __init__(self, *args, **kwargs): + gr.log.warn('`pdu_remove` has moved to gr-pdu and will be removed from gr-blocks soon. Please update to use pdu.pdu_remove()') + pdu.pdu_remove.__init__(self, *args, **kwargs) + +class pdu_set(pdu.pdu_set): + def __init__(self, *args, **kwargs): + gr.log.warn('`pdu_set` has moved to gr-pdu and will be removed from gr-blocks soon. Please update to use pdu.pdu_set()') + pdu.pdu_set.__init__(self, *args, **kwargs) + +class pdu_to_tagged_stream(pdu.pdu_to_tagged_stream): + def __init__(self, *args, **kwargs): + gr.log.warn('`pdu_to_tagged_stream` has moved to gr-pdu and will be removed from gr-blocks soon. Please update to use pdu.pdu_to_tagged_stream()') + pdu.pdu_to_tagged_stream.__init__(self, *args, **kwargs) + +class random_pdu(pdu.random_pdu): + def __init__(self, *args, **kwargs): + gr.log.warn('`random_pdu` has moved to gr-pdu and will be removed from gr-blocks soon. Please update to use pdu.random_pdu()') + pdu.random_pdu.__init__(self, *args, **kwargs) + +class tagged_stream_to_pdu(pdu.tagged_stream_to_pdu): + def __init__(self, *args, **kwargs): + gr.log.warn('`tagged_stream_to_pdu` has moved to gr-pdu and will be removed from gr-blocks soon. Please update to use pdu.tagged_stream_to_pdu()') + pdu.tagged_stream_to_pdu.__init__(self, *args, **kwargs) + + +######## PDU BLOCKS MOVED TO GR-NETWORK ######## + +class socket_pdu(network.socket_pdu): + def __init__(self, *args, **kwargs): + gr.log.warn('`socket_pdu` has moved to gr-network and will be removed from gr-blocks soon. Please update to use network.socket_pdu()') + network.socket_pdu.__init__(self, *args, **kwargs) + +class tuntap_pdu(network.tuntap_pdu): + def __init__(self, *args, **kwargs): + gr.log.warn('`tuntap_pdu` has moved to gr-network and will be removed from gr-blocks soon. Please update to use network.tuntap_pdu()') + network.tuntap_pdu.__init__(self, *args, **kwargs) diff --git a/gr-blocks/python/blocks/qa_pdu.py b/gr-blocks/python/blocks/qa_pdu.py deleted file mode 100644 index e3d0aad8e2..0000000000 --- a/gr-blocks/python/blocks/qa_pdu.py +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# SPDX-License-Identifier: GPL-3.0-or-later -# -# - - -import time - -from gnuradio import gr, gr_unittest, blocks -import pmt - - -class test_pdu(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_000(self): - # Just run some data through and make sure it doesn't puke. - src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - - src = blocks.pdu_to_tagged_stream(blocks.byte_t) - snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t) - snk2 = blocks.vector_sink_b() - snk = blocks.tag_debug(1, "test") - snk.set_display(False) - - dbg = blocks.message_debug() - - # Test that the right number of ports exist. - pi = snk3.message_ports_in() - po = snk3.message_ports_out() - # system port is defined automatically - self.assertEqual(pmt.length(pi), 1) - self.assertEqual(pmt.length(po), 1) - - self.tb.connect(src, snk) - self.tb.connect(src, snk2) - self.tb.connect(src, snk3) - self.tb.msg_connect(snk3, "pdus", dbg, "store") - - # make our reference and message pmts - port = pmt.intern("pdus") - msg = pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(16, 0xFF)) - - # post the message - src.to_basic_block()._post(port, msg) - src.to_basic_block()._post( - pmt.intern("system"), pmt.cons( - pmt.intern("done"), pmt.from_long(1))) - - self.tb.start() - self.tb.wait() - - # Get the vector of data from the vector sink - result_data = snk2.data() - - # Get the vector of data from the message sink - # Convert the message PMT as a pair into its vector - result_msg = dbg.get_message(0) - msg_vec = pmt.cdr(result_msg) - # pmt.print(msg_vec) - - # Convert the PMT vector into a Python list - msg_data = [] - for i in range(16): - msg_data.append(pmt.u8vector_ref(msg_vec, i)) - - actual_data = 16 * [0xFF, ] - self.assertEqual(actual_data, list(result_data)) - self.assertEqual(actual_data, msg_data) - - def test_001(self): - # Test the overflow buffer in pdu_to_tagged_stream - src_data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] - src = blocks.pdu_to_tagged_stream(blocks.float_t) - snk = blocks.vector_sink_f() - - self.tb.connect(src, snk) - port = pmt.intern("pdus") - - msg = pmt.cons(pmt.PMT_NIL, pmt.init_f32vector(10, src_data)) - src.to_basic_block()._post(port, msg) - src.to_basic_block()._post( - pmt.intern("system"), pmt.cons( - pmt.intern("done"), pmt.from_long(1))) - - self.tb.start() - self.tb.wait() - - self.assertEqual(src_data, list(snk.data())) - - def test_002_tags_plus_data(self): - packet_len = 16 - src_data = list(range(packet_len)) - tag1 = gr.tag_t() - tag1.offset = 0 - tag1.key = pmt.string_to_symbol('spam') - tag1.value = pmt.from_long(23) - tag2 = gr.tag_t() - tag2.offset = 10 # Must be < packet_len - tag2.key = pmt.string_to_symbol('eggs') - tag2.value = pmt.from_long(42) - src = blocks.vector_source_f(src_data, tags=(tag1, tag2)) - s2ts = blocks.stream_to_tagged_stream( - gr.sizeof_float, - vlen=1, - packet_len=packet_len, - len_tag_key="packet_len") - ts2pdu = blocks.tagged_stream_to_pdu(blocks.float_t, "packet_len") - dbg = blocks.message_debug() - self.tb.connect(src, s2ts, ts2pdu) - self.tb.msg_connect(ts2pdu, "pdus", dbg, "store") - self.tb.start() - self.tb.wait() - result_msg = dbg.get_message(0) - metadata = pmt.to_python(pmt.car(result_msg)) - vector = pmt.f32vector_elements(pmt.cdr(result_msg)) - self.assertEqual(metadata, {'eggs': 42, 'spam': 23}) - self.assertFloatTuplesAlmostEqual(tuple(vector), src_data) - - -if __name__ == '__main__': - gr_unittest.run(test_pdu) diff --git a/gr-blocks/python/blocks/qa_socket_pdu.py b/gr-blocks/python/blocks/qa_socket_pdu.py deleted file mode 100644 index 16e118dafb..0000000000 --- a/gr-blocks/python/blocks/qa_socket_pdu.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# SPDX-License-Identifier: GPL-3.0-or-later -# -# - - -from gnuradio import gr, gr_unittest, blocks -import random -import pmt -import time - - -class qa_socket_pdu (gr_unittest.TestCase): - - def setUp(self): - random.seed(0) - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_001(self): - # Test that blocks can be created and destroyed without hanging - port = str(random.Random().randint(0, 30000) + 10000) - self.pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", port) - self.pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port) - self.pdu_send = None - self.pdu_recv = None - - def test_002(self): - # Send a PDU through a pair of UDP sockets - port = str(random.Random().randint(0, 30000) + 10000) - srcdata = (0x64, 0x6f, 0x67, 0x65) - data = pmt.init_u8vector(srcdata.__len__(), srcdata) - pdu_msg = pmt.cons(pmt.PMT_NIL, data) - - self.pdu_source = blocks.message_strobe(pdu_msg, 500) - self.pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port) - self.pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", port) - - self.dbg = blocks.message_debug() - - self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus") - self.tb.msg_connect(self.pdu_recv, "pdus", self.dbg, "store") - - self.tb.start() - time.sleep(1) - self.tb.stop() - self.tb.wait() - self.pdu_send = None - self.pdu_recv = None - - received = self.dbg.get_message(0) - received_data = pmt.cdr(received) - msg_data = [] - for i in range(4): - msg_data.append(pmt.u8vector_ref(received_data, i)) - self.assertEqual(srcdata, tuple(msg_data)) - - def test_003(self): - # Test that block stops when interacting with streaming interface - port = str(random.Random().randint(0, 30000) + 10000) - srcdata = ( - 0x73, - 0x75, - 0x63, - 0x68, - 0x74, - 0x65, - 0x73, - 0x74, - 0x76, - 0x65, - 0x72, - 0x79, - 0x70, - 0x61, - 0x73, - 0x73) - tag_dict = {"offset": 0} - tag_dict["key"] = pmt.intern("len") - tag_dict["value"] = pmt.from_long(8) - tag1 = gr.python_to_tag(tag_dict) - tag_dict["offset"] = 8 - tag2 = gr.python_to_tag(tag_dict) - tags = [tag1, tag2] - - src = blocks.vector_source_b(srcdata, False, 1, tags) - ts_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "len") - pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", "4141") - #pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port) - pdu_to_ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "len") - head = blocks.head(gr.sizeof_char, 10) - sink = blocks.vector_sink_b(1) - - self.tb.connect(src, ts_to_pdu) - self.tb.msg_connect(ts_to_pdu, "pdus", pdu_send, "pdus") - # a UDP socket connects pdu_send to pdu_recv - # TODO: test that the recv socket can be destroyed from downstream - # that signals DONE. Also that we get the PDUs we sent - #self.tb.msg_connect(pdu_recv, "pdus", pdu_to_ts, "pdus") - #self.tb.connect(pdu_to_ts, head, sink) - self.tb.run() - - def test_004(self): - # Test that the TCP server can stream PDUs <= the MTU size. - port = str(random.Random().randint(0, 30000) + 10000) - mtu = 10000 - srcdata = tuple(x % 256 for x in range(mtu)) - data = pmt.init_u8vector(srcdata.__len__(), srcdata) - pdu_msg = pmt.cons(pmt.PMT_NIL, data) - - self.pdu_source = blocks.message_strobe(pdu_msg, 500) - self.pdu_send = blocks.socket_pdu("TCP_SERVER", "localhost", port, mtu) - self.pdu_recv = blocks.socket_pdu("TCP_CLIENT", "localhost", port, mtu) - self.pdu_sink = blocks.message_debug() - - self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus") - self.tb.msg_connect(self.pdu_recv, "pdus", self.pdu_sink, "store") - - self.tb.start() - time.sleep(1) - self.tb.stop() - self.tb.wait() - - received = self.pdu_sink.get_message(0) - received_data = pmt.cdr(received) - msg_data = [] - for i in range(mtu): - msg_data.append(pmt.u8vector_ref(received_data, i)) - self.assertEqual(srcdata, tuple(msg_data)) - - -if __name__ == '__main__': - gr_unittest.run(qa_socket_pdu) |