aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc/arfcn_range_encode.h
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-10-13 12:38:54 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-10-22 15:23:58 +0200
commit511f9c3e4a0a7ebb6294d6a2e4ac29dbcdad818c (patch)
treef3f8cfc0b9a5a3a62f2fa8c550f9dd7435740fa8 /openbsc/include/openbsc/arfcn_range_encode.h
parentd49eb747325e2745fb3cfa6da9d63ec302b4dc9d (diff)
si: Partially implement the range encoding for the SI.
I saw the old copy of the "Appendix J" code too late and I have discovered some quirks and I am more familar with my implementation. Most noticable 'w' only needs to be as big as the input arfcn but requires the 'w' to be initialized. The power_of_2 implementation differs as well (mine matches the output of wirehsark). The f0 could be chosen in a better way but right now picking the lower bound is the easiest. It is not clear if to use modulo if the range is chosen in the middle. This can be improved in the future. Right now I have no bit fiddling for range128, 256 and 1024 as I was running out of time.
Diffstat (limited to 'openbsc/include/openbsc/arfcn_range_encode.h')
-rw-r--r--openbsc/include/openbsc/arfcn_range_encode.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/arfcn_range_encode.h b/openbsc/include/openbsc/arfcn_range_encode.h
new file mode 100644
index 000000000..7a6fff000
--- /dev/null
+++ b/openbsc/include/openbsc/arfcn_range_encode.h
@@ -0,0 +1,26 @@
+#ifndef ARFCN_RANGE_ENCODE_H
+#define ARFCN_RANGE_ENCODE_H
+
+#include <stdint.h>
+
+enum {
+ ARFCN_RANGE_INVALID = -1,
+ ARFCN_RANGE_128 = 127,
+ ARFCN_RANGE_256 = 255,
+ ARFCN_RANGE_512 = 511,
+ ARFCN_RANGE_1024 = 1023,
+};
+
+#define RANGE_ENC_MAX_ARFCNS 29
+
+int range_enc_determine_range(const int *arfcns, int size, int *f0_out);
+int range_enc_arfcns(const int rng, const int *arfcns, int sze, int *out, int idx);
+int range_enc_find_index(const int rng, const int *arfcns, int size);
+int range_enc_filter_arfcns(const int rng, int *arfcns, const int sze, const int f0, int *f0_included);
+
+int range_enc_range128(uint8_t *chan_list, int f0, int *w);
+int range_enc_range256(uint8_t *chan_list, int f0, int *w);
+int range_enc_range512(uint8_t *chan_list, int f0, int *w);
+int range_enc_range1024(uint8_t *chan_list, int f0, int f0_incl, int *w);
+
+#endif