library/GSUP_Types.ttcn: fix MSISDN / SMSC coding in SM-RP-OA/DA
Unlike IMSI, both MSISDN and SMSC address in SM-RP-OA/DA not only contain the BCD encoded digits, but also a little header with NPI (Numbering Plan Identification), ToN (Type of Number), and Extension fields. Change-Id: I3f55834489f3e613f541cf1e216027e8d48ccaf0 Related: OS#4324
This commit is contained in:
parent
437b5a6c7d
commit
a52347ca32
|
@ -869,6 +869,38 @@ type enumerated GSUP_SM_RP_ODA_IdType {
|
|||
OSMO_GSUP_SM_RP_ODA_ID_NULL ('FF'O)
|
||||
} with { variant "FIELDLENGTH(8)" };
|
||||
|
||||
/* See 3GPP TS 24.011, figures 8.5 and 8.6 */
|
||||
type record GSUP_SM_RP_Addr {
|
||||
BIT1 ext, /* Extension? */
|
||||
BIT3 ton, /* Type of Number */
|
||||
BIT4 npi, /* Numbering Plan Identification */
|
||||
hexstring number length (1..20)
|
||||
} with {
|
||||
variant "PADDING(yes)";
|
||||
variant "PADDING_PATTERN('1111'B)"
|
||||
};
|
||||
|
||||
private function f_pad_SM_RP_Addr(template hexstring number)
|
||||
return template hexstring {
|
||||
if (isvalue(number) and not istemplatekind(number, "omit")) {
|
||||
return f_pad_bcd_number(valueof(number));
|
||||
} else {
|
||||
return number;
|
||||
}
|
||||
}
|
||||
|
||||
template GSUP_SM_RP_Addr t_GSUP_SM_RP_Addr(template hexstring number,
|
||||
template BIT4 npi := '0001'B,
|
||||
template BIT3 ton := '001'B,
|
||||
template BIT1 ext := '1'B) := {
|
||||
ext := ext,
|
||||
ton := ton,
|
||||
npi := npi,
|
||||
/* Work around TITAN's padding problems: encoding works fine,
|
||||
* but it does not consider 'F'H as padding in decoded data. */
|
||||
number := f_pad_SM_RP_Addr(number)
|
||||
}
|
||||
|
||||
/**
|
||||
* SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
|
||||
* It can be either of the following:
|
||||
|
@ -879,9 +911,9 @@ type enumerated GSUP_SM_RP_ODA_IdType {
|
|||
* - service centre address
|
||||
*/
|
||||
type union GSUP_SM_RP_DA_ID {
|
||||
hexstring imsi,
|
||||
hexstring msisdn,
|
||||
hexstring smsc_addr
|
||||
hexstring imsi,
|
||||
GSUP_SM_RP_Addr msisdn,
|
||||
GSUP_SM_RP_Addr smsc_addr
|
||||
};
|
||||
|
||||
type record GSUP_SM_RP_DA {
|
||||
|
@ -904,20 +936,20 @@ template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_IMSI(template hexstring imsi) := {
|
|||
id_enc := { imsi := imsi }
|
||||
}
|
||||
|
||||
template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(hexstring msisdn) := {
|
||||
template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
|
||||
id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
|
||||
id_enc := { msisdn := msisdn }
|
||||
}
|
||||
template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template hexstring msisdn) := {
|
||||
template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
|
||||
id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
|
||||
id_enc := { msisdn := msisdn }
|
||||
}
|
||||
|
||||
template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(hexstring smsc_addr) := {
|
||||
template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(GSUP_SM_RP_Addr smsc_addr) := {
|
||||
id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
|
||||
id_enc := { smsc_addr := smsc_addr }
|
||||
}
|
||||
template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template hexstring smsc_addr) := {
|
||||
template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template GSUP_SM_RP_Addr smsc_addr) := {
|
||||
id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
|
||||
id_enc := { smsc_addr := smsc_addr }
|
||||
}
|
||||
|
@ -953,8 +985,8 @@ template GSUP_IE tr_GSUP_IE_SM_RP_DA(template GSUP_SM_RP_DA val) := {
|
|||
* - service centre address
|
||||
*/
|
||||
type union GSUP_SM_RP_OA_ID {
|
||||
hexstring msisdn,
|
||||
hexstring smsc_addr
|
||||
GSUP_SM_RP_Addr msisdn,
|
||||
GSUP_SM_RP_Addr smsc_addr
|
||||
};
|
||||
|
||||
type record GSUP_SM_RP_OA {
|
||||
|
@ -967,20 +999,20 @@ type record GSUP_SM_RP_OA {
|
|||
)"
|
||||
};
|
||||
|
||||
template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(hexstring msisdn) := {
|
||||
template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
|
||||
id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
|
||||
id_enc := { msisdn := msisdn }
|
||||
}
|
||||
template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template hexstring msisdn) := {
|
||||
template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
|
||||
id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
|
||||
id_enc := { msisdn := msisdn }
|
||||
}
|
||||
|
||||
template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(hexstring smsc_addr) := {
|
||||
template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(GSUP_SM_RP_Addr smsc_addr) := {
|
||||
id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
|
||||
id_enc := { smsc_addr := smsc_addr }
|
||||
}
|
||||
template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template hexstring smsc_addr) := {
|
||||
template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template GSUP_SM_RP_Addr smsc_addr) := {
|
||||
id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
|
||||
id_enc := { smsc_addr := smsc_addr }
|
||||
}
|
||||
|
|
|
@ -170,5 +170,13 @@ function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
|
|||
return str;
|
||||
}
|
||||
|
||||
function f_pad_bcd_number(hexstring number) return hexstring {
|
||||
if (lengthof(number) mod 2 != 0) {
|
||||
return number & 'F'H;
|
||||
} else {
|
||||
return number;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} with { encode "RAW"; variant "FIELDORDER(msb)" }
|
||||
|
|
|
@ -2268,14 +2268,16 @@ testcase TC_gsup_mo_smma() runs on MTC_CT {
|
|||
/* Helper for sending MT SMS over GSUP */
|
||||
private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O)
|
||||
runs on BSC_ConnHdlr {
|
||||
var GSUP_SM_RP_Addr msisdn := valueof(t_GSUP_SM_RP_Addr(g_pars.msisdn));
|
||||
|
||||
GSUP.send(ts_GSUP_MT_FORWARD_SM_REQ(
|
||||
imsi := g_pars.imsi,
|
||||
/* NOTE: MSC should assign RP-MR itself */
|
||||
sm_rp_mr := 'FF'O,
|
||||
/* FIXME: extract SM-RP-DA from spars.rp.dest */
|
||||
/* TODO: fix encoding of ts_GSUP_SM_RP_DA_IMSI */
|
||||
sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(g_pars.msisdn)),
|
||||
sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(g_pars.msisdn)),
|
||||
sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(msisdn)),
|
||||
sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(msisdn)),
|
||||
/* Encoded SMS TPDU (taken from Wireshark)
|
||||
* FIXME: we should encode spars somehow */
|
||||
sm_rp_ui := '00068021436500008111328130858200'O,
|
||||
|
|
Loading…
Reference in New Issue