diff options
-rw-r--r-- | include/osmocom/gsm/gsm48.h | 2 | ||||
-rw-r--r-- | src/gsm/gsm48.c | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h index 16a625aa..1e7498a9 100644 --- a/include/osmocom/gsm/gsm48.h +++ b/include/osmocom/gsm/gsm48.h @@ -20,6 +20,8 @@ const char *gsm48_cc_state_name(uint8_t state); const char *gsm48_cc_msg_name(uint8_t msgtype); const char *rr_cause_name(uint8_t cause); +int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc, + uint16_t *mnc, uint16_t *lac); void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc, uint16_t mnc, uint16_t lac); int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi); 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]; |