summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gsm48.c21
-rw-r--r--src/gsm_utils.c15
2 files changed, 36 insertions, 0 deletions
diff --git a/src/gsm48.c b/src/gsm48.c
index 783ff6a5..7e510664 100644
--- a/src/gsm48.c
+++ b/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];
+}
diff --git a/src/gsm_utils.c b/src/gsm_utils.c
index 593dd5c9..b392fd37 100644
--- a/src/gsm_utils.c
+++ b/src/gsm_utils.c
@@ -359,3 +359,18 @@ uint32_t gsm_gsmtime2fn(struct gsm_time *time)
/* TS 05.02 Chapter 4.3.3 TDMA frame number */
return (51 * ((time->t3 - time->t2 + 26) % 26) + time->t3 + (26 * 51 * time->t1));
}
+
+/* TS 03.03 Chapter 2.6 */
+int gprs_tlli_type(uint32_t tlli)
+{
+ if ((tlli & 0xc0000000) == 0xc0000000)
+ return TLLI_LOCAL;
+ else if ((tlli & 0xc0000000) == 0x80000000)
+ return TLLI_FOREIGN;
+ else if ((tlli & 0xf8000000) == 0x78000000)
+ return TLLI_RANDOM;
+ else if ((tlli & 0xf8000000) == 0x70000000)
+ return TLLI_AUXILIARY;
+
+ return TLLI_RESERVED;
+}