Check the gsm0503_xcch_decode return value

- Discard the message when gsm0503_xcch_decode returns -1
- Add automated decrypt test

See https://groups.google.com/d/msg/gr-gsm/9nOkIdrGOck/qTZh47McCQAJ
This commit is contained in:
Vasil Velichkov 2018-03-27 02:37:49 +03:00 committed by Piotr Krysik
parent 7476868d8e
commit bc2a23e0e7
4 changed files with 55 additions and 1 deletions

View File

@ -20,3 +20,4 @@ before_install:
script:
# - docker run -it --rm $IMGNAME sh -c 'cd /src/build;make test'
- docker run -it --rm $IMGNAME /src/tests/scripts/decode.sh
- docker run -it --rm $IMGNAME /src/tests/scripts/decrypt.sh

View File

@ -105,7 +105,11 @@ namespace gr {
//convert to soft bits
ubits2sbits(bursts_u, bursts_s, 116 * 4);
//decode
gsm0503_xcch_decode(result, bursts_s, &n_errors, &n_bits_total);
if (-1 == gsm0503_xcch_decode(result, bursts_s, &n_errors, &n_bits_total))
{
//Possibly an encrypted message
return;
}
//extract header of the first burst of the four bursts
pmt::pmt_t first_header_plus_burst = pmt::cdr(d_bursts[0]);

View File

@ -0,0 +1,12 @@
862210 1331352: 03 03 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
862242 1332356: 00 01 03 03 49 06 1d 9f 6d 18 10 80 00 00 00 00 00 00 00 00 00 00 00
862261 1331351: 01 73 35 06 27 00 03 50 18 a0 05 f4 01 5c 57 03 2b 2b 2b 2b 2b 2b 2b
862312 1331350: 03 20 0d 06 35 11 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
862344 1332354: 00 00 03 03 2d 06 1e 2b d9 62 f2 20 01 3e 95 78 7b 2b 2b 2b 2b 2b 2b
862363 1331349: 03 42 45 13 05 1e 02 ea 81 5c 08 11 83 94 03 98 93 92 49 81 2b 2b 2b
862414 1331348: 01 61 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
862446 1332352: 00 00 03 03 49 06 1d 9f 6d 18 10 80 00 00 00 00 00 00 00 00 00 00 00
862465 1331347: 01 81 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
862516 1331346: 03 84 21 06 2e 0d 02 d5 00 63 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
862548 1332376: 00 00 03 03 49 06 06 70 00 00 00 00 00 04 15 50 10 00 00 00 00 0a a8
862567 1331345: 03 03 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b

37
tests/scripts/decrypt.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
TEST_DIR=`dirname "$0"`
# PYTHONPATH and LD_LIBRARY_PATH are needed on Fedora 26
export PYTHONPATH=/usr/local/lib64/python2.7/site-packages/:/usr/local/lib64/python2.7/site-packages/grgsm/:$PYTHONPATH
export LD_LIBRARY_PATH=/usr/local/lib64/:$LD_LIBRARY_PATH
export AP_DECODE="grgsm_decode"
export CAPFILE="../../test_data/vf_call6_a725_d174_g5_Kc1EF00BAB3BAC7002.cfile"
export SHORTENED_CAPFILE="tmp.cfile"
export RESULT_EXPECTED="../fixtures/grgsm_decode_decrypt1_expected"
export RESULT_OBTAINED="grgsm_decode_test1_result"
export RUNLINE="$AP_DECODE -c $SHORTENED_CAPFILE -s $((100000000/174)) -m SDCCH8 -t 1 -k 0x1E,0xF0,0x0B,0xAB,0x3B,0xAC,0x70,0x02 -v --ppm -10"
echo "Testing with:"
echo " $RUNLINE"
gnuradio-companion --version
cd $TEST_DIR
cat $CAPFILE | head -c -37000000 | head -c 35800000 > $SHORTENED_CAPFILE
$RUNLINE | grep -A 999999 "862210 1331352: 03 03 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b" | tee $RESULT_OBTAINED
diff -u $RESULT_EXPECTED $RESULT_OBTAINED
TEST_RESULT=$?
rm $RESULT_OBTAINED
rm $SHORTENED_CAPFILE
if [ $TEST_RESULT == 0 ]
then
echo " Result: PASSED"
exit 0
else
echo " Result: FAILED"
exit 1
fi