diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2014-01-14 10:42:58 +0100 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2014-01-16 12:04:30 +0100 |
commit | 45014a0cadfd1f28d68d61b5160ee18fa391c4ba (patch) | |
tree | 428329d79af34cf66fb8aae804b90d2859ad8214 /openbsc/src/libbsc/arfcn_range_encode.c | |
parent | 131406c86dc1c589af8dea91e772eac01340ac94 (diff) |
si: Fix range1024 encoding
f0 is currently set to arfcns[0] in range_enc_determine_range(),
while GSM 04.08 requires f0 to be ARFCN 0 in range1024 encoding.
This patch modifies range_enc_determine_range() to force f0 to be 0
if this encoding is used. This way the case distinction in
range_enc_filter_arfcns() is not longer necessary.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/src/libbsc/arfcn_range_encode.c')
-rw-r--r-- | openbsc/src/libbsc/arfcn_range_encode.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/openbsc/src/libbsc/arfcn_range_encode.c b/openbsc/src/libbsc/arfcn_range_encode.c index 917754623..a047a06ea 100644 --- a/openbsc/src/libbsc/arfcn_range_encode.c +++ b/openbsc/src/libbsc/arfcn_range_encode.c @@ -144,7 +144,9 @@ int range_enc_arfcns(const int range, */ /** * This implements the range determination as described in GSM 04.08 J4. The - * result will be a base frequency f0 and the range to use. + * result will be a base frequency f0 and the range to use. Note that for range + * 1024 encoding f0 always refers to ARFCN 0 even if it is not an element of + * the arfcns list. * * \param[in] arfcns The input frequencies, they must be sorted, lowest number first * \param[in] size The length of the array @@ -166,8 +168,10 @@ int range_enc_determine_range(const int *arfcns, const int size, int *f0) return ARFCN_RANGE_256; if (max < 512 && size <= 18) return ARFCN_RANGE_512; - if (max < 1024 && size <= 17) + if (max < 1024 && size <= 17) { + *f0 = 0; return ARFCN_RANGE_1024; + } return ARFCN_RANGE_INVALID; } @@ -271,34 +275,24 @@ int range_enc_range1024(uint8_t *chan_list, int f0, int f0_included, int *w) return -1; } -int range_enc_filter_arfcns(const int range, int *arfcns, - const int size, const int f0, int *f0_included) +int range_enc_filter_arfcns(int *arfcns, + const int size, const int f0, int *f0_included) { int i, j = 0; *f0_included = 0; - if (range == ARFCN_RANGE_1024) { - for (i = 0; i < size; ++i) { - if (arfcns[i] == f0) { - *f0_included = 1; - continue; - } - - /* copy and subtract */ - arfcns[j++] = mod(arfcns[i] - 1, 1024); - } - } else { - for (i = 0; i < size; ++i) { - /* - * Appendix J.4 says the following: - * All frequencies except F(0), minus F(0) + 1. - * I assume we need to exclude it here. - */ - if (arfcns[i] == f0) - continue; - - arfcns[j++] = mod(arfcns[i] - (f0 + 1), 1024); + for (i = 0; i < size; ++i) { + /* + * Appendix J.4 says the following: + * All frequencies except F(0), minus F(0) + 1. + * I assume we need to exclude it here. + */ + if (arfcns[i] == f0) { + *f0_included = 1; + continue; } + + arfcns[j++] = mod(arfcns[i] - (f0 + 1), 1024); } return j; |