summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-03-07 17:50:21 +0100
committerHarald Welte <laforge@gnumonks.org>2010-03-07 17:50:21 +0100
commit622b718195d607d7cfc8b9ec96f943ea0ce2d1dd (patch)
treedf5b56824b241b04e1ff3df3aaa75b858a938a45 /include
parent63d3e396e79bae0e3580a8813a8c1c0166a51b59 (diff)
import some gsm band/arfcn/time related utilities from OsmocomBB
Diffstat (limited to 'include')
-rw-r--r--include/osmocore/gsm_utils.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/osmocore/gsm_utils.h b/include/osmocore/gsm_utils.h
index b611050d..25360459 100644
--- a/include/osmocore/gsm_utils.h
+++ b/include/osmocore/gsm_utils.h
@@ -27,6 +27,14 @@
#include <stdint.h>
+struct gsm_time {
+ uint32_t fn; /* FN count */
+ uint16_t t1; /* FN div (26*51) */
+ uint8_t t2; /* FN modulo 26 */
+ uint8_t t3; /* FN modulo 51 */
+ uint8_t tc;
+};
+
enum gsm_band {
GSM_BAND_850 = 1,
GSM_BAND_900 = 2,
@@ -58,5 +66,19 @@ static inline int rach_max_trans_raw2val(int raw) {
return tbl[raw & 3];
}
+#define ARFCN_PCS 0x8000
+#define ARFCN_UPLINK 0x4000
+
+enum gsm_band gsm_arfcn2band(uint16_t arfcn);
+
+/* Convert an ARFCN to the frequency in MHz * 10 */
+uint16_t gsm_arfcn2freq10(uint16_t arfcn, int uplink);
+
+/* Convert from frame number to GSM time */
+void gsm_fn2gsmtime(struct gsm_time *time, uint32_t fn);
+
+/* Convert from GSM time to frame number */
+uint32_t gsm_gsmtime2fn(struct gsm_time *time);
+
void generate_backtrace();
#endif