aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@users.noreply.github.com>2015-07-16 21:19:34 +0200
committerPiotr Krysik <ptrkrysik@users.noreply.github.com>2015-07-16 21:19:34 +0200
commitf329ae5633b98bec3365c6337099b25fca469188 (patch)
tree63b16626b094ca7800cdfc12abc74d2ffee707b2 /lib
parentbc8de9cd0f4997d3af2b774737c5930bbf2b61a5 (diff)
parent11b549e7ea01d4248c6479684eed917d52d3f86b (diff)
Merge pull request #82 from rpp0/rpp0-hopping-checks
Added input validation to CX channel hopper block
Diffstat (limited to 'lib')
-rw-r--r--lib/receiver/cx_channel_hopper_impl.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/receiver/cx_channel_hopper_impl.cc b/lib/receiver/cx_channel_hopper_impl.cc
index b67cb15..1fe15df 100644
--- a/lib/receiver/cx_channel_hopper_impl.cc
+++ b/lib/receiver/cx_channel_hopper_impl.cc
@@ -27,6 +27,7 @@
#include <gnuradio/io_signature.h>
#include <grgsm/gsmtap.h>
#include <grgsm/endian.h>
+#include <boost/algorithm/clamp.hpp>
#include "cx_channel_hopper_impl.h"
namespace gr {
@@ -52,6 +53,23 @@ namespace gr {
{
d_narfcn = ma.size();
+ // Check user input for GSM 05.02, p16 compliance
+ if(d_narfcn < 1 || d_narfcn > 64) {
+ std::cerr << "warning: clamping number of RFCNs in the MA (" << d_narfcn << "), which should be 1 <= N <= 64." << std::endl;
+ d_narfcn = boost::algorithm::clamp(d_narfcn, 1, 64);
+ d_ma.resize(d_narfcn);
+ }
+
+ if(d_maio < 0 || d_maio >= d_narfcn) {
+ std::cerr << "warning: clamping MAIO (" << d_maio << "), which should be 0 <= MAIO < N." << std::endl;
+ d_maio = boost::algorithm::clamp(d_maio, 0, d_narfcn - 1);
+ }
+
+ if(d_hsn < 0 || d_hsn > 63) {
+ std::cerr << "warning: clamping HSN (" << d_hsn << "), which should be 0 <= HSN < 64." << std::endl;
+ d_hsn = boost::algorithm::clamp(d_hsn, 0, 63);
+ }
+
message_port_register_in(pmt::mp("CX"));
set_msg_handler(pmt::mp("CX"), boost::bind(&cx_channel_hopper_impl::assemble_bursts, this, _1));
message_port_register_out(pmt::mp("bursts"));
@@ -128,7 +146,7 @@ namespace gr {
uint16_t frame_ca = be16toh(header->arfcn);
int mai = calculate_ma_sfh(d_maio, d_hsn, d_narfcn, frame_nr);
- if(d_ma[mai] == frame_ca) {
+ if(d_ma[mai] == (int)frame_ca) {
message_port_pub(pmt::mp("bursts"), msg);
}
}