summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-07-13 21:35:13 +0200
committerHarald Welte <laforge@gnumonks.org>2012-07-13 21:35:13 +0200
commit774a9de8b36a53c9e4e4dca4efbb9944cd39ff65 (patch)
treeda2eed2a3ed2bb2d919cc68b176284386c8aa95a /src
parente30b6ac5d1127c368184232dc749cef28d0cbb6c (diff)
import gsm48_decode_lai() function from osmocom-bb/mobile sysinfo.c
Diffstat (limited to 'src')
-rw-r--r--src/gsm/gsm48.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index 379ed65c..61e5d2cb 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -285,6 +285,20 @@ void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc,
lai48->lac = htons(lac);
}
+int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc,
+ uint16_t *mnc, uint16_t *lac)
+{
+ *mcc = ((lai->digits[0] & 0x0f) << 8)
+ | (lai->digits[0] & 0xf0)
+ | (lai->digits[1] & 0x0f);
+ *mnc = ((lai->digits[2] & 0x0f) << 8)
+ | (lai->digits[2] & 0xf0)
+ | ((lai->digits[1] & 0xf0) >> 4);
+ *lac = ntohs(lai->lac);
+
+ return 0;
+}
+
int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi)
{
uint32_t *tptr = (uint32_t *) &buf[3];