aboutsummaryrefslogtreecommitdiffstats
path: root/libosmocore/src/gsm48.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-05-01 12:07:56 +0200
committerHarald Welte <laforge@gnumonks.org>2010-05-01 12:07:56 +0200
commitd66c2bef54835a181d5ed171fff71b5ab7f2261a (patch)
tree34435182ea7af70e3e56596b6d1abef56077e60a /libosmocore/src/gsm48.c
parentf32cc4bee55da4ff20be095eb5f4e883f2f54de6 (diff)
parentdebf95507461965aa82be2fa2bf34119343cfb0e (diff)
Merge commit 'debf95507461965aa82be2fa2bf34119343cfb0e'
Diffstat (limited to 'libosmocore/src/gsm48.c')
-rw-r--r--libosmocore/src/gsm48.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libosmocore/src/gsm48.c b/libosmocore/src/gsm48.c
index 783ff6a5d..7e510664b 100644
--- a/libosmocore/src/gsm48.c
+++ b/libosmocore/src/gsm48.c
@@ -305,3 +305,24 @@ int gsm48_mi_to_string(char *string, const int str_len, const uint8_t *mi,
return str_cur - string;
}
+
+void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf)
+{
+ raid->mcc = (buf[0] & 0xf) * 100;
+ raid->mcc += (buf[0] >> 4) * 10;
+ raid->mcc += (buf[1] & 0xf) * 1;
+
+ /* I wonder who came up with the stupidity of encoding the MNC
+ * differently depending on how many digits its decimal number has! */
+ if ((buf[1] >> 4) == 0xf) {
+ raid->mnc = (buf[2] & 0xf) * 10;
+ raid->mnc += (buf[2] >> 4) * 1;
+ } else {
+ raid->mnc = (buf[2] & 0xf) * 100;
+ raid->mnc += (buf[2] >> 4) * 10;
+ raid->mnc += (buf[1] >> 4) * 1;
+ }
+
+ raid->lac = ntohs(*(uint16_t *)(buf + 3));
+ raid->rac = buf[5];
+}