This commit adds the implementation of these range formats to the
encoder. In addition, the work-around that tried range 512 first is
removed, so that the selection is primarily based on the max distance
between frequencies.
Ticket: OW#1061
Sponsored-by: On-Waves ehf
---
openbsc/src/libbsc/arfcn_range_encode.c | 18 ++++++++----------
openbsc/tests/gsm0408/gsm0408_test.c | 4 ++--
openbsc/tests/gsm0408/gsm0408_test.ok | 17 ++++++-----------
3 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/openbsc/src/libbsc/arfcn_range_encode.c
b/openbsc/src/libbsc/arfcn_range_encode.c
index 3e5b1fc..e67bf0a 100644
--- a/openbsc/src/libbsc/arfcn_range_encode.c
+++ b/openbsc/src/libbsc/arfcn_range_encode.c
@@ -162,14 +162,12 @@ int range_enc_determine_range(const int *arfcns, const int size, int
*f0)
max = arfcns[size - 1] - arfcns[0];
*f0 = arfcns[0];
- if (max < 512 && size <= 18)
- return ARFCN_RANGE_512;
-
- /* The following are nyi, so they are checked last */
if (max < 128 && size <= 29)
return ARFCN_RANGE_128;
if (max < 256 && size <= 22)
return ARFCN_RANGE_256;
+ if (max < 512 && size <= 18)
+ return ARFCN_RANGE_512;
if (max < 1024 && size <= 17) {
*f0 = 0;
return ARFCN_RANGE_1024;
@@ -272,8 +270,8 @@ int range_enc_range128(uint8_t *chan_list, int f0, int *w)
chan_list[0] = 0x8C;
write_orig_arfcn(chan_list, f0);
- LOGP(DRR, LOGL_ERROR, "Range128 encoding is not implemented.\n");
- return -1;
+ write_all_wn(&chan_list[2], 1, w, 28, 7);
+ return 0;
}
int range_enc_range256(uint8_t *chan_list, int f0, int *w)
@@ -281,8 +279,8 @@ int range_enc_range256(uint8_t *chan_list, int f0, int *w)
chan_list[0] = 0x8A;
write_orig_arfcn(chan_list, f0);
- LOGP(DRR, LOGL_ERROR, "Range256 encoding is not implemented.\n");
- return -1;
+ write_all_wn(&chan_list[2], 1, w, 21, 8);
+ return 0;
}
int range_enc_range512(uint8_t *chan_list, int f0, int *w)
@@ -298,8 +296,8 @@ int range_enc_range1024(uint8_t *chan_list, int f0, int f0_included,
int *w)
{
chan_list[0] = 0x80 | (f0_included << 2);
- LOGP(DRR, LOGL_ERROR, "Range1024 encoding is not implemented.\n");
- return -1;
+ write_all_wn(&chan_list[0], 6, w, 16, 10);
+ return 0;
}
int range_enc_filter_arfcns(int *arfcns,
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index 3218379..894eb0f 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -436,11 +436,11 @@ static void test_si_range_helpers()
}
i = range_enc_determine_range(range128, ARRAY_SIZE(range128), &f0);
- VERIFY(i, ==, ARFCN_RANGE_512);
+ VERIFY(i, ==, ARFCN_RANGE_128);
VERIFY(f0, ==, 1);
i = range_enc_determine_range(range256, ARRAY_SIZE(range256), &f0);
- VERIFY(i, ==, ARFCN_RANGE_512);
+ VERIFY(i, ==, ARFCN_RANGE_256);
VERIFY(f0, ==, 1);
i = range_enc_determine_range(range512, ARRAY_SIZE(range512), &f0);
diff --git a/openbsc/tests/gsm0408/gsm0408_test.ok
b/openbsc/tests/gsm0408/gsm0408_test.ok
index dab495d..3d3c4e6 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -47,20 +47,15 @@ chan_list = 88 05 08 fc 88 b9 6b 00 00 00 00 00 00 00 00 00
Decoded freqs 6 (expected 6)
Decoded: 10 17 31 45 58 79
Range test 6: range 1023, num ARFCNs 17
-Cannot encode range, rc = -1
+chan_list = 84 71 e4 ab b9 58 05 cb 39 17 fd b0 75 62 0f 2f
+Decoded freqs 17 (expected 17)
+Decoded: 0 17 31 45 58 79 81 97 113 127 213 277 287 311 331 391 1023
Range test 7: range 1023, num ARFCNs 16
-Cannot encode range, rc = -1
+chan_list = 80 71 e4 ab b9 58 05 cb 39 17 fd b0 75 62 0f 2f
+Decoded freqs 16 (expected 16)
+Decoded: 17 31 45 58 79 81 97 113 127 213 277 287 311 331 391 1023
Random range test: range 127, max num ARFCNs 29
-Cannot encode range, rc = -1
-Failed on test 0, range 127, num ARFCNs 1
-Cannot encode range, rc = -1
Random range test: range 255, max num ARFCNs 22
-Cannot encode range, rc = -1
-Failed on test 0, range 255, num ARFCNs 1
-Cannot encode range, rc = -1
Random range test: range 511, max num ARFCNs 18
Random range test: range 1023, max num ARFCNs 16
-Cannot encode range, rc = -1
-Failed on test 0, range 1023, num ARFCNs 1
-Cannot encode range, rc = -1
Done.
--
1.7.9.5