diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-05-10 14:59:02 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-03-16 15:32:30 +0100 |
commit | 38fa951e523f3e36233224d84d35cbe151e7fbe1 (patch) | |
tree | cb87257d260db12ecf0191928e1f799e26cc12b6 /openbsc/src/libcommon-cs | |
parent | 49e65b3aeb463249032ff5f93a63b77f2cb65dbf (diff) |
move to libcommon-cs: gsm48_extract_mi(), gsm48_paging_extract_mi() -- TODO move to libfilter instead?
Change-Id: I00ca0caf8224de029f53f4dedb1146e3cf7650ec
Diffstat (limited to 'openbsc/src/libcommon-cs')
-rw-r--r-- | openbsc/src/libcommon-cs/common_cs.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/openbsc/src/libcommon-cs/common_cs.c b/openbsc/src/libcommon-cs/common_cs.c index 7a0530834..d94381b4c 100644 --- a/openbsc/src/libcommon-cs/common_cs.c +++ b/openbsc/src/libcommon-cs/common_cs.c @@ -115,6 +115,30 @@ struct msgb *gsm48_create_loc_upd_rej(uint8_t cause) return msg; } +int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, uint8_t *mi_type) +{ + /* Check the size for the classmark */ + if (length < 1 + *classmark2_lv) + return -1; + + uint8_t *mi_lv = classmark2_lv + *classmark2_lv + 1; + if (length < 2 + *classmark2_lv + mi_lv[0]) + return -2; + + *mi_type = mi_lv[1] & GSM_MI_TYPE_MASK; + return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv); +} + +int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length, + char *mi_string, uint8_t *mi_type) +{ + static const uint32_t classmark_offset = + offsetof(struct gsm48_pag_resp, classmark2); + uint8_t *classmark2_lv = (uint8_t *) &resp->classmark2; + return gsm48_extract_mi(classmark2_lv, length - classmark_offset, + mi_string, mi_type); +} + uint8_t sms_next_rp_msg_ref(uint8_t *next_rp_ref) { const uint8_t rp_msg_ref = *next_rp_ref; |