diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2017-07-21 10:59:51 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-07-22 12:43:16 +0700 |
commit | 04536ab41ca48051dfcc895279769424a1131c5e (patch) | |
tree | 947d20fe5b9b87c003b30d63604e8d6bc7cbe9ef /lib/flow_control/burst_timeslot_filter_impl.cc | |
parent | 6ee2c165d94bbe0f34f827dbecb3190d47ba649a (diff) |
flow_control: implement pass / drop filtering policies
This change introduces a set of three modes for flow control
filters, one of which is default behavor and two extra modes
else described below:
- FILTER_POLICY_PASS_ALL
- FILTER_POLICY_DROP_ALL
Both modes are opposite, and make a filter either unconditionally
pass or drop all the data one gets to the input. They would be
usable for some external usage.
Diffstat (limited to 'lib/flow_control/burst_timeslot_filter_impl.cc')
-rw-r--r-- | lib/flow_control/burst_timeslot_filter_impl.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/flow_control/burst_timeslot_filter_impl.cc b/lib/flow_control/burst_timeslot_filter_impl.cc index 20306d1..c93bc60 100644 --- a/lib/flow_control/burst_timeslot_filter_impl.cc +++ b/lib/flow_control/burst_timeslot_filter_impl.cc @@ -48,7 +48,8 @@ namespace gr { : gr::block("burst_timeslot_filter", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), - d_timeslot(timeslot) + d_timeslot(timeslot), + d_filter_policy(FILTER_POLICY_DEFAULT) { message_port_register_in(pmt::mp("in")); message_port_register_out(pmt::mp("out")); @@ -63,6 +64,14 @@ namespace gr { void burst_timeslot_filter_impl::process_burst(pmt::pmt_t msg) { + if (d_filter_policy == FILTER_POLICY_DROP_ALL) + return; + + if (d_filter_policy == FILTER_POLICY_PASS_ALL) { + message_port_pub(pmt::mp("out"), msg); + return; + } + pmt::pmt_t header_plus_burst = pmt::cdr(msg); gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst); @@ -92,5 +101,19 @@ namespace gr { return d_timeslot; } + /* Filtering policy */ + filter_policy + burst_timeslot_filter_impl::get_policy(void) + { + return d_filter_policy; + } + + filter_policy + burst_timeslot_filter_impl::set_policy(filter_policy policy) + { + d_filter_policy = policy; + return d_filter_policy; + } + } /* namespace gsm */ } /* namespace gr */ |