pespin submitted this change.
RAN_Emulation: Fix handling of IMSI in RANAP Paging
The IMSI in RANAP Paging messages is encoded in octetstring BCD format.
We need to decode it before using it, since we use plain hexstrings
everywhere in the module to manage IMSIs.
Take the chance to clean up and improve logging on related lines, both
for BSSAP and RANAP.
Change-Id: Ia892a52bad41a4e331703bbab438d8c811b2025e
---
M library/Osmocom_Types.ttcn
M library/RAN_Emulation.ttcnpp
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index a7e37e6..690535c 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -265,6 +265,22 @@
return ret;
}
+function imsi_oct2hex(octetstring imsi) return hexstring {
+ var hexstring ret := ''H
+ var integer i;
+
+ /* swap nibbles and skip F */
+ for (i := 0; i < lengthof(imsi); i := i+1) {
+ var hexstring h := oct2hex(imsi[i]);
+ if (h[0] == 'F'H) {
+ ret := ret & h[1];
+ } else {
+ ret := ret & h[1] & h[0];
+ }
+ }
+ return ret;
+}
+
function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
var integer strlen := lengthof(str);
for (var integer i := 0; i < len-strlen; i := i+1) {
diff --git a/library/RAN_Emulation.ttcnpp b/library/RAN_Emulation.ttcnpp
index 9401ed6..4e28ab2 100644
--- a/library/RAN_Emulation.ttcnpp
+++ b/library/RAN_Emulation.ttcnpp
@@ -565,18 +565,19 @@
runs on RAN_Emulation_CT return template PDU_BSSAP {
if (match(bssap, tr_BSSMAP_Paging)) {
var RAN_ConnHdlr client := null;
- var template OCT4 tmsi := omit;
+ var hexstring imsi := bssap.pdu.bssmap.paging.iMSI.digits;
+ var template (omit) OCT4 tmsi := omit;
if (ispresent(bssap.pdu.bssmap.paging.tMSI)) {
tmsi := bssap.pdu.bssmap.paging.tMSI.tmsiOctets;
}
- client := f_imsi_table_find(bssap.pdu.bssmap.paging.iMSI.digits, tmsi);
+ client := f_imsi_table_find(imsi, tmsi);
if (client != null) {
log("CommonBssmapUnitdataCallback: IMSI/TMSI found in table, dispatching to ",
client);
CLIENT.send(bssap) to client;
return omit;
}
- log("CommonBssmapUnitdataCallback: IMSI/TMSI not found in table");
+ log("CommonBssmapUnitdataCallback: IMSI=", imsi, ", TMSI=", tmsi, " not found in table");
} else {
log("CommonBssmapUnitdataCallback: Not a paging message");
}
@@ -719,8 +720,8 @@
if (match(ranap, tr_RANAP_Paging(?, ?))) {
var RAN_ConnHdlr client := null;
/* extract IMSI and (if present) TMSI */
- var IMSI imsi := ranap.initiatingMessage.value_.paging.protocolIEs[1].value_.permanentNAS_UE_ID.iMSI;
- var template OCT4 tmsi := omit;
+ var hexstring imsi := imsi_oct2hex(ranap.initiatingMessage.value_.paging.protocolIEs[1].value_.permanentNAS_UE_ID.iMSI);
+ var template (omit) OCT4 tmsi := omit;
if (lengthof(ranap.initiatingMessage.value_.paging.protocolIEs) > 2 and
ranap.initiatingMessage.value_.paging.protocolIEs[2].id == id_TemporaryUE_ID) {
var TemporaryUE_ID ue_id;
@@ -731,14 +732,14 @@
tmsi := ue_id.p_TMSI;
}
}
- client := f_imsi_table_find(oct2hex(imsi), tmsi);
+ client := f_imsi_table_find(imsi, tmsi);
if (client != null) {
log("CommonRanapUnitdataCallback: IMSI/TMSI found in table, dispatching to ",
client);
CLIENT.send(ranap) to client;
return omit;
}
- log("CommonRanapUnitdataCallback: IMSI/TMSI not found in table");
+ log("CommonRanapUnitdataCallback: IMSI=", imsi, ", TMSI=", tmsi, " not found in table");
} else if (match(ranap, tr_RANAP_ResetResource(?, ?, ?))) {
/* extract IuSigConId */
if (lengthof(ranap.initiatingMessage.value_.resetResource.protocolIEs) > 2 and
To view, visit change 40634. To unsubscribe, or for help writing mail filters, visit settings.