blob: d16b4a5014f40246527ba63177e3a3495147fcdc [file] [log] [blame]
Harald Weltedf327232017-12-28 22:51:51 +01001module GSUP_Types {
2
Harald Welte35bb7162018-01-03 21:07:52 +01003/* GSUP_Types, defining abstract TTCN-3 data types for the GSUP protocol.
4 *
5 * GSUP is a non-standard protocol used between OsmoMSC/OsmoSGSN and OsmoHLR
6 * in order to replace the complex TCAP/MAP protocol.
7 *
8 * (C) 2017 by Harald Welte <laforge@gnumonks.org>
9 * All rights reserved.
10 *
11 * Released under the terms of GNU General Public License, Version 2 or
12 * (at your option) any later version.
13 */
14
Harald Weltedf327232017-12-28 22:51:51 +010015import from General_Types all;
16import from Osmocom_Types all;
17
18type enumerated GSUP_IEI {
19 OSMO_GSUP_IMSI_IE ('01'O),
20 OSMO_GSUP_CAUSE_IE ('02'O),
21 OSMO_GSUP_AUTH_TUPLE_IE ('03'O),
22 OSMO_GSUP_PDP_INFO_COMPL_IE ('04'O),
23 OSMO_GSUP_PDP_INFO_IE ('05'O),
24 OSMO_GSUP_CANCEL_TYPE_IE ('06'O),
25 OSMO_GSUP_FREEZE_PTMSI_IE ('07'O),
26 OSMO_GSUP_MSISDN_IE ('08'O),
27 OSMO_GSUP_HLR_NUMBER_IE ('09'O),
28 OSMO_GSUP_PDP_CONTEXT_ID_IE ('10'O),
29 OSMO_GSUP_PDP_TYPE_IE ('11'O),
30 OSMO_GSUP_ACCESS_POINT_NAME_IE ('12'O),
31 OSMO_GSUP_PDP_QOS_IE ('13'O),
32 OSMO_GSUP_CHARG_CHAR_IE ('14'O),
33
34 OSMO_GSUP_RAND_IE ('20'O),
35 OSMO_GSUP_SRES_IE ('21'O),
36 OSMO_GSUP_KC_IE ('22'O),
37 OSMO_GSUP_IK_IE ('23'O),
38 OSMO_GSUP_CK_IE ('24'O),
39 OSMO_GSUP_AUTN_IE ('25'O),
40 OSMO_GSUP_AUTS_IE ('26'O),
41 OSMO_GSUP_RES_IE ('27'O),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +070042 OSMO_GSUP_CN_DOMAIN_IE ('28'O),
43
44 OSMO_GSUP_SESSION_ID_IE ('30'O),
45 OSMO_GSUP_SESSION_STATE_IE ('31'O),
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +070046 OSMO_GSUP_SS_INFO_IE ('35'O),
47
48 /* SM related IEs (see 3GPP TS 29.002, section 7.6.8) */
49 OSMO_GSUP_SM_RP_MR_IE ('40'O),
50 OSMO_GSUP_SM_RP_DA_IE ('41'O),
51 OSMO_GSUP_SM_RP_OA_IE ('42'O),
52 OSMO_GSUP_SM_RP_UI_IE ('43'O),
53 OSMO_GSUP_SM_RP_CAUSE_IE ('44'O),
Vadim Yanitskiy88e23232018-11-13 03:04:02 +070054 OSMO_GSUP_SM_RP_MMS_IE ('45'O),
55 OSMO_GSUP_SM_ALERT_RSN_IE ('46'O)
Harald Weltedf327232017-12-28 22:51:51 +010056} with { variant "FIELDLENGTH(8)" };
57
58type enumerated GSUP_MessageType {
59 OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST ('00000100'B),
60 OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR ('00000101'B),
61 OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT ('00000110'B),
62
63 OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST ('00001000'B),
64 OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR ('00001001'B),
65 OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT ('00001010'B),
66
67 OSMO_GSUP_MSGT_AUTH_FAIL_REPORT ('00001011'B),
68
69 OSMO_GSUP_MSGT_PURGE_MS_REQUEST ('00001100'B),
70 OSMO_GSUP_MSGT_PURGE_MS_ERROR ('00001101'B),
71 OSMO_GSUP_MSGT_PURGE_MS_RESULT ('00001110'B),
72
73 OSMO_GSUP_MSGT_INSERT_DATA_REQUEST ('00010000'B),
74 OSMO_GSUP_MSGT_INSERT_DATA_ERROR ('00010001'B),
75 OSMO_GSUP_MSGT_INSERT_DATA_RESULT ('00010010'B),
76
77 OSMO_GSUP_MSGT_DELETE_DATA_REQUEST ('00010100'B),
78 OSMO_GSUP_MSGT_DELETE_DATA_ERROR ('00010101'B),
79 OSMO_GSUP_MSGT_DELETE_DATA_RESULT ('00010110'B),
80
81 OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST ('00011100'B),
82 OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR ('00011101'B),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +070083 OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT ('00011110'B),
84
85 OSMO_GSUP_MSGT_PROC_SS_REQUEST ('00100000'B),
86 OSMO_GSUP_MSGT_PROC_SS_ERROR ('00100001'B),
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +070087 OSMO_GSUP_MSGT_PROC_SS_RESULT ('00100010'B),
88
89 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST ('00100100'B),
90 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR ('00100101'B),
91 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT ('00100110'B),
92
93 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST ('00101000'B),
94 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR ('00101001'B),
Vadim Yanitskiy88e23232018-11-13 03:04:02 +070095 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT ('00101010'B),
96
97 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST ('00101100'B),
98 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR ('00101101'B),
99 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT ('00101110'B)
Harald Weltedf327232017-12-28 22:51:51 +0100100} with { variant "FIELDLENGTH(8)" };
101
102type enumerated GSUP_CancelType {
Alexander Couzens4786b3f2018-09-16 03:33:30 +0200103 OSMO_GSUP_CANCEL_TYPE_UPDATE (0),
104 OSMO_GSUP_CANCEL_TYPE_WITHDRAW (1)
Harald Weltedf327232017-12-28 22:51:51 +0100105} with { variant "FIELDLENGTH(8)" };
106
107type enumerated GSUP_CnDomain {
108 OSMO_GSUP_CN_DOMAIN_PS (1),
109 OSMO_GSUP_CN_DOMAIN_CS (2)
110} with { variant "FIELDLENGTH(8)" };
111
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700112type enumerated GSUP_SessionState {
113 OSMO_GSUP_SESSION_STATE_NONE (0),
114 OSMO_GSUP_SESSION_STATE_BEGIN (1),
115 OSMO_GSUP_SESSION_STATE_CONTINUE (2),
116 OSMO_GSUP_SESSION_STATE_END (3)
117} with { variant "FIELDLENGTH(8)" };
118
Harald Welte3f95be82018-01-27 00:48:13 +0100119type record GSUP_MSISDN {
120 uint8_t len,
121 hexstring digits optional
122} with { variant (len) "LENGTHTO(digits)" };
123
Harald Weltedf327232017-12-28 22:51:51 +0100124type record GSUP_IE {
125 GSUP_IEI tag,
126 uint8_t len,
127 GSUP_IeValue val
128} with { variant (len) "LENGTHTO(val)"
129 variant (val) "CROSSTAG(imsi, tag = OSMO_GSUP_IMSI_IE;
130 cause, tag = OSMO_GSUP_CAUSE_IE;
131 cancel_type, tag = OSMO_GSUP_CANCEL_TYPE_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100132 auth_tuple, tag = OSMO_GSUP_AUTH_TUPLE_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100133 auts, tag = OSMO_GSUP_AUTS_IE;
134 rand, tag = OSMO_GSUP_RAND_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100135 sres, tag = OSMO_GSUP_SRES_IE;
136 kc, tag = OSMO_GSUP_KC_IE;
137 ik, tag = OSMO_GSUP_IK_IE;
138 ck, tag = OSMO_GSUP_CK_IE;
139 autn, tag = OSMO_GSUP_AUTN_IE;
140 res, tag = OSMO_GSUP_RES_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100141 msisdn, tag = OSMO_GSUP_MSISDN_IE;
142 hlr_number, tag = OSMO_GSUP_HLR_NUMBER_IE;
143 cn_domain, tag = OSMO_GSUP_CN_DOMAIN_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100144 pdp_info, tag = OSMO_GSUP_PDP_INFO_IE;
145 apn, tag = OSMO_GSUP_ACCESS_POINT_NAME_IE;
146 pdp_qos, tag = OSMO_GSUP_PDP_QOS_IE;
147 pdp_type, tag = OSMO_GSUP_PDP_TYPE_IE;
148 charg_char, tag = OSMO_GSUP_CHARG_CHAR_IE;
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700149 session_state, tag = OSMO_GSUP_SESSION_STATE_IE;
150 session_id, tag = OSMO_GSUP_SESSION_ID_IE;
151 ss_info, tag = OSMO_GSUP_SS_INFO_IE;
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700152 sm_rp_mr, tag = OSMO_GSUP_SM_RP_MR_IE;
153 sm_rp_da, tag = OSMO_GSUP_SM_RP_DA_IE;
154 sm_rp_oa, tag = OSMO_GSUP_SM_RP_OA_IE;
155 sm_rp_ui, tag = OSMO_GSUP_SM_RP_UI_IE;
156 sm_rp_cause, tag = OSMO_GSUP_SM_RP_CAUSE_IE;
157 sm_rp_mms, tag = OSMO_GSUP_SM_RP_MMS_IE;
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700158 sm_alert_rsn, tag = OSMO_GSUP_SM_ALERT_RSN_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100159 )"
Harald Weltedf327232017-12-28 22:51:51 +0100160};
161
162type record of GSUP_IE GSUP_IEs;
163
164type union GSUP_IeValue {
165 hexstring imsi,
166 integer cause,
167 GSUP_CancelType cancel_type,
168 //boolean pdp_info_compl,
169 //boolean freeze_ptmsi,
Harald Weltedf327232017-12-28 22:51:51 +0100170 GSUP_IEs auth_tuple,
171 octetstring auts,
172 octetstring rand,
Harald Welte77a8eba2018-01-22 21:22:32 +0100173 octetstring sres,
174 octetstring kc,
175 octetstring ik,
176 octetstring ck,
177 octetstring autn,
178 octetstring res,
Harald Welte3f95be82018-01-27 00:48:13 +0100179 GSUP_MSISDN msisdn,
Harald Weltedf327232017-12-28 22:51:51 +0100180 octetstring hlr_number,
181 GSUP_CnDomain cn_domain,
Harald Welteeded9ad2018-02-17 20:57:34 +0100182 /* PDP context + nested IEs */
183 GSUP_IEs pdp_info,
184 octetstring apn,
185 octetstring pdp_qos,
186 OCT2 pdp_type,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700187 octetstring charg_char,
188 /* Session information */
189 GSUP_SessionState session_state,
190 OCT4 session_id,
191 /* Supplementary Services */
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700192 octetstring ss_info,
193 /* Short Message Service */
194 OCT1 sm_rp_mr,
195 GSUP_SM_RP_DA sm_rp_da,
196 GSUP_SM_RP_OA sm_rp_oa,
197 octetstring sm_rp_ui,
198 OCT1 sm_rp_cause,
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700199 OCT1 sm_rp_mms,
200 GSUP_SM_ALERT_RSN_Type sm_alert_rsn
Harald Weltedf327232017-12-28 22:51:51 +0100201};
202
203type record GSUP_PDU {
204 GSUP_MessageType msg_type,
205 GSUP_IEs ies
206};
207
208external function enc_GSUP_PDU(in GSUP_PDU msg) return octetstring
209 with { extension "prototype(convert) encode(RAW)" };
210
211external function dec_GSUP_PDU(in octetstring msg) return GSUP_PDU
212 with { extension "prototype(convert) decode(RAW)" };
213
Harald Welte2f562b12018-01-24 20:52:38 +0100214function f_gsup_postprocess_decoded(inout GSUP_PDU gsup) {
215 if (gsup.ies[0].tag == OSMO_GSUP_IMSI_IE) {
216 /* if last digit is 'F', then there's an odd number of digits and we must strip the F */
217 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
218 if (gsup.ies[0].val.imsi[num_digits-1] == 'F'H) {
219 gsup.ies[0].val.imsi := substr(gsup.ies[0].val.imsi, 0, num_digits-1);
220 }
221 }
222}
223
224function f_gsup_preprocess_encoded(inout GSUP_PDU gsup) {
225 if (ischosen(gsup.ies[0].val.imsi)) {
226 /* if number of digits is odd, add a 'F' as padding at the end */
227 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
228 if (num_digits rem 2 == 1) {
229 gsup.ies[0].val.imsi := gsup.ies[0].val.imsi & 'F'H;
230 }
231 }
232}
233
Harald Welte3f95be82018-01-27 00:48:13 +0100234template (value) GSUP_MSISDN ts_GSUP_MSISDN(hexstring digits,
235 BIT3 ton := '000'B,
236 BIT4 npi := '0000'B) := {
237 len := 0, /* overwritten */
238 /* numberingPlanIdentification := npi,
239 typeOfNumber := ton,
240 ext1 := '0'B, */
241 digits := digits
242}
243
244template GSUP_MSISDN tr_GSUP_MSISDN(template hexstring digits,
245 template BIT3 ton := ?,
246 template BIT4 npi := ?) := {
247 len := ?,
248 /* numberingPlanIdentification := npi,
249 typeOfNumber := ton,
250 ext1 := '0'B, */
251 digits := digits
252}
253
254
Harald Weltedf327232017-12-28 22:51:51 +0100255
Harald Welte77a8eba2018-01-22 21:22:32 +0100256template GSUP_IE ts_GSUP_IE_AuthTuple2G(octetstring rand, octetstring sres,
257 octetstring kc) := {
258 tag := OSMO_GSUP_AUTH_TUPLE_IE,
259 len := 0, /* overwritten */
260 val := {
261 auth_tuple := {
262 valueof(ts_GSUP_IE_RAND(rand)),
263 valueof(ts_GSUP_IE_SRES(sres)),
264 valueof(ts_GSUP_IE_Kc(kc))
265 }
266 }
267}
268
269template GSUP_IE ts_GSUP_IE_AuthTuple2G3G(octetstring rand, octetstring sres,
270 octetstring kc, octetstring ik,
271 octetstring ck, octetstring autn,
272 octetstring res) := {
273 tag := OSMO_GSUP_AUTH_TUPLE_IE,
274 len := 0, /* overwritten */
275 val := {
276 auth_tuple := {
277 valueof(ts_GSUP_IE_RAND(rand)),
278 valueof(ts_GSUP_IE_SRES(sres)),
279 valueof(ts_GSUP_IE_Kc(kc)),
280 valueof(ts_GSUP_IE_IK(ik)),
281 valueof(ts_GSUP_IE_CK(ck)),
282 valueof(ts_GSUP_IE_AUTN(autn)),
283 valueof(ts_GSUP_IE_RES(res))
284 }
285 }
286}
287
Harald Welteeded9ad2018-02-17 20:57:34 +0100288template GSUP_IE ts_GSUP_IE_PdpInfo(octetstring apn, octetstring pdp_type, octetstring pdp_qos) := {
289 tag := OSMO_GSUP_PDP_INFO_IE,
290 len := 0, /* overwritten */
291 val := {
292 pdp_info := {
293 valueof(ts_GSUP_IE_APN(apn)),
294 valueof(ts_GSUP_IE_PDP_TYPE(pdp_type)),
295 valueof(ts_GSUP_IE_PDP_QOS(pdp_qos))
296 }
297 }
298}
299
300template (value) GSUP_IE ts_GSUP_IE_PDP_TYPE(OCT2 pdp_type) := {
301 tag := OSMO_GSUP_PDP_TYPE_IE,
302 len := 0,
303 val := {
304 pdp_type := pdp_type
305 }
306}
307
308template (value) GSUP_IE ts_GSUP_IE_PDP_QOS(octetstring pdp_qos) := {
309 tag := OSMO_GSUP_PDP_QOS_IE,
310 len := 0,
311 val := {
312 pdp_qos := pdp_qos
313 }
314}
315
316
Harald Weltedf327232017-12-28 22:51:51 +0100317template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
318 msg_type := msgt,
319 ies := ies
320}
321
Harald Welte8a1dd532018-01-27 15:38:18 +0100322template GSUP_PDU tr_GSUP_IMSI(template GSUP_MessageType msgt := ?, template hexstring imsi) := {
323 msg_type := msgt,
324 ies := { tr_GSUP_IE_IMSI(imsi), * }
325}
326
Harald Weltedf327232017-12-28 22:51:51 +0100327template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
328 msg_type := msgt,
329 ies := ies
330}
331
Harald Welte6aa04e32018-01-27 15:35:19 +0100332template (value) GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
Harald Weltedf327232017-12-28 22:51:51 +0100333 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
334
Harald Welteef9fa872018-01-22 03:00:17 +0100335template GSUP_PDU tr_GSUP_SAI_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100336 tr_GSUP_IMSI(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, imsi);
Harald Welteef9fa872018-01-22 03:00:17 +0100337
Alexander Couzensd24973d2018-09-04 16:10:14 +0200338template GSUP_PDU tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC(
339 template hexstring imsi,
340 template octetstring auts,
341 template octetstring rand) :=
342 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
343 tr_GSUP_IE_IMSI(imsi),
344 tr_GSUP_IE_AUTS(auts),
345 tr_GSUP_IE_RAND(rand),
346 *
347 });
348
Harald Welte77a8eba2018-01-22 21:22:32 +0100349template (value) GSUP_PDU ts_GSUP_SAI_RES(hexstring imsi, GSUP_IE auth_tuple) :=
350 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
351 valueof(ts_GSUP_IE_IMSI(imsi)), auth_tuple });
352
Harald Weltedf327232017-12-28 22:51:51 +0100353template GSUP_PDU tr_GSUP_SAI_ERR(template hexstring imsi, template integer cause) :=
Harald Welte071ed732018-01-23 19:53:52 +0100354 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
Harald Weltedf327232017-12-28 22:51:51 +0100355 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
356
Harald Welte6aa04e32018-01-27 15:35:19 +0100357template (value) GSUP_PDU ts_GSUP_SAI_ERR(hexstring imsi, integer cause) :=
358 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
359 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
Harald Welte071ed732018-01-23 19:53:52 +0100360
361
Harald Weltedf327232017-12-28 22:51:51 +0100362template GSUP_PDU tr_GSUP_SAI_RES(template hexstring imsi) :=
Harald Weltec2c52552018-03-01 21:20:39 +0100363 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
Harald Weltedf327232017-12-28 22:51:51 +0100364 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE), * });
365
Harald Weltec2c52552018-03-01 21:20:39 +0100366template (value) GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi) :=
367 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, {
368 valueof(ts_GSUP_IE_IMSI(imsi)) });
369
Harald Weltedfe94dd2018-01-21 13:55:22 +0100370template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100371 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, imsi);
Harald Weltedfe94dd2018-01-21 13:55:22 +0100372
Harald Welte6aa04e32018-01-27 15:35:19 +0100373template (value) GSUP_PDU ts_GSUP_UL_RES(hexstring imsi) :=
Harald Weltedfe94dd2018-01-21 13:55:22 +0100374 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)) });
375
Harald Weltec2c52552018-03-01 21:20:39 +0100376template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi) :=
377 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, imsi);
378
Harald Welte6aa04e32018-01-27 15:35:19 +0100379template (value) GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100380 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
381 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
382
Harald Weltec2c52552018-03-01 21:20:39 +0100383template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?) :=
384 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
385 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
386
Harald Welte6aa04e32018-01-27 15:35:19 +0100387template (value) GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100388 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
389 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)) });
390
Harald Weltec2c52552018-03-01 21:20:39 +0100391template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?) :=
392 tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
Harald Welte8f6ac162018-03-01 22:43:28 +0100393 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_MSISDN(msisdn), * });
Harald Weltec2c52552018-03-01 21:20:39 +0100394
395template (value) GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi) :=
396 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, {
397 valueof(ts_GSUP_IE_IMSI(imsi)) });
398
Harald Welte6ff81902018-01-21 19:09:08 +0100399template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100400 tr_GSUP_IMSI(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100401
Harald Weltec638f4d2018-01-24 22:00:36 +0100402template GSUP_PDU tr_GSUP_AUTH_FAIL_IND(hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100403 tr_GSUP_IMSI(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100404
Harald Welte167458a2018-01-27 15:58:16 +0100405template (value) GSUP_PDU ts_GSUP_CL_REQ(hexstring imsi, GSUP_CancelType ctype) :=
406 ts_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST, {
407 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CancelType(ctype)) });
408
409template GSUP_PDU tr_GSUP_CL_RES(template hexstring imsi) :=
410 tr_GSUP_IMSI(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT, imsi);
411
412template GSUP_PDU tr_GSUP_CL_ERR(template hexstring imsi, template integer cause := ?) :=
413 tr_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR, {
Alexander Couzens4cfff3a2018-05-22 17:08:36 +0200414 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause), * });
Harald Welte167458a2018-01-27 15:58:16 +0100415
Harald Welte958f8b42018-03-01 23:40:17 +0100416template (value) GSUP_PDU ts_GSUP_PURGE_MS_REQ(hexstring imsi, GSUP_CnDomain dom) :=
417 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
418 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CnDomain(dom)) });
419
Harald Welte6abb9fe2018-02-17 15:24:48 +0100420template GSUP_PDU tr_GSUP_PURGE_MS_REQ(template hexstring imsi, template GSUP_CnDomain dom := ?) :=
421 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
422 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_CnDomain(dom) });
423
424template (value) GSUP_PDU ts_GSUP_PURGE_MS_RES(hexstring imsi) :=
425 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
426 valueof(ts_GSUP_IE_IMSI(imsi)) });
427
Harald Welte958f8b42018-03-01 23:40:17 +0100428template GSUP_PDU tr_GSUP_PURGE_MS_RES(template hexstring imsi) :=
429 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
430 tr_GSUP_IE_IMSI(imsi), * });
431
432template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer cause) :=
433 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
434 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
435
Harald Welte167458a2018-01-27 15:58:16 +0100436
437template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
438 tag := OSMO_GSUP_CANCEL_TYPE_IE,
439 len := 0, /* overwritten */
440 val := {
441 cancel_type := ctype
442 }
443}
444
445template GSUP_IE tr_GSUP_IE_CancelType(template GSUP_CancelType ctype) :=
446 tr_GSUP_IE(OSMO_GSUP_CANCEL_TYPE_IE, GSUP_IeValue:{cancel_type:=ctype});
447
Harald Welte6abb9fe2018-02-17 15:24:48 +0100448template GSUP_IE tr_GSUP_IE_CnDomain(template GSUP_CnDomain domain) :=
449 tr_GSUP_IE(OSMO_GSUP_CN_DOMAIN_IE, GSUP_IeValue:{cn_domain:=domain});
450
Harald Weltedf327232017-12-28 22:51:51 +0100451template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := {
452 tag := iei,
453 len := ?,
454 val := val
455}
456
457template (value) GSUP_IE ts_GSUP_IE_IMSI(hexstring imsi) := {
458 tag := OSMO_GSUP_IMSI_IE,
459 len := 0, /* overwritten */
460 val := {
461 imsi := imsi
462 }
463}
464
465template GSUP_IE tr_GSUP_IE_IMSI(template hexstring imsi) := {
466 tag := OSMO_GSUP_IMSI_IE,
467 len := ?,
468 val := {
469 imsi := imsi
470 }
471}
472
Harald Welte6ff81902018-01-21 19:09:08 +0100473template (value) GSUP_IE ts_GSUP_IE_MSISDN(hexstring msisdn) := {
474 tag := OSMO_GSUP_MSISDN_IE,
475 len := 0, /* overwritten */
476 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100477 msisdn := ts_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100478 }
479}
480
481template GSUP_IE tr_GSUP_IE_MSISDN(template hexstring msisdn) := {
482 tag := OSMO_GSUP_MSISDN_IE,
483 len := ?,
484 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100485 msisdn := tr_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100486 }
487}
488
489
Harald Weltedf327232017-12-28 22:51:51 +0100490template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := {
491 tag := OSMO_GSUP_CAUSE_IE,
492 len := 0, /* overwritten */
493 val := {
494 cause := cause
495 }
496}
497
498template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := {
499 tag := OSMO_GSUP_CAUSE_IE,
500 len := ?,
501 val := {
502 cause := cause
503 }
504}
505
506template (value) GSUP_IE ts_GSUP_IE_AUTS(octetstring auts) := {
507 tag := OSMO_GSUP_AUTS_IE,
508 len := 0, /* overwritten */
509 val := {
510 auts := auts
511 }
512}
513
Alexander Couzensd24973d2018-09-04 16:10:14 +0200514template GSUP_IE tr_GSUP_IE_AUTS(template octetstring auts) := {
515 tag := OSMO_GSUP_AUTS_IE,
516 len := ?,
517 val := {
518 auts := auts
519 }
520}
521
Harald Weltedf327232017-12-28 22:51:51 +0100522template (value) GSUP_IE ts_GSUP_IE_RAND(octetstring rand) := {
523 tag := OSMO_GSUP_RAND_IE,
524 len := 0, /* overwritten */
525 val := {
526 rand := rand
527 }
528}
529
Alexander Couzensd24973d2018-09-04 16:10:14 +0200530template GSUP_IE tr_GSUP_IE_RAND(template octetstring rand) := {
531 tag := OSMO_GSUP_RAND_IE,
532 len := ?,
533 val := {
534 rand := rand
535 }
536}
537
Harald Welte77a8eba2018-01-22 21:22:32 +0100538template (value) GSUP_IE ts_GSUP_IE_SRES(octetstring sres) := {
539 tag := OSMO_GSUP_SRES_IE,
540 len := 0, /* overwritten */
541 val := {
542 sres := sres
543 }
544}
545
546template (value) GSUP_IE ts_GSUP_IE_Kc(octetstring kc) := {
547 tag := OSMO_GSUP_KC_IE,
548 len := 0, /* overwritten */
549 val := {
550 kc := kc
551 }
552}
553
554template (value) GSUP_IE ts_GSUP_IE_IK(octetstring ik) := {
555 tag := OSMO_GSUP_IK_IE,
556 len := 0, /* overwritten */
557 val := {
558 ik := ik
559 }
560}
561
562template (value) GSUP_IE ts_GSUP_IE_CK(octetstring ck) := {
563 tag := OSMO_GSUP_CK_IE,
564 len := 0, /* overwritten */
565 val := {
566 ck := ck
567 }
568}
569
570template (value) GSUP_IE ts_GSUP_IE_AUTN(octetstring autn) := {
571 tag := OSMO_GSUP_AUTN_IE,
572 len := 0, /* overwritten */
573 val := {
574 autn := autn
575 }
576}
577
578template (value) GSUP_IE ts_GSUP_IE_RES(octetstring res) := {
579 tag := OSMO_GSUP_RES_IE,
580 len := 0, /* overwritten */
581 val := {
582 res := res
583 }
584}
Harald Weltedf327232017-12-28 22:51:51 +0100585
Harald Welteeded9ad2018-02-17 20:57:34 +0100586template (value) GSUP_IE ts_GSUP_IE_APN(octetstring apn) := {
587 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
588 len := 0, /* overwritten */
589 val := {
590 apn := apn
591 }
592}
593
Harald Welte958f8b42018-03-01 23:40:17 +0100594template (value) GSUP_IE ts_GSUP_IE_CnDomain(GSUP_CnDomain dom) := {
595 tag := OSMO_GSUP_CN_DOMAIN_IE,
596 len := 0, /* overwritten */
597 val := {
598 cn_domain := dom
599 }
600}
Harald Weltedf327232017-12-28 22:51:51 +0100601
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700602template (value) GSUP_IE ts_GSUP_IE_SessionId(OCT4 sid) := {
603 tag := OSMO_GSUP_SESSION_ID_IE,
604 len := 0, /* overwritten */
605 val := {
606 session_id := sid
607 }
608}
609template GSUP_IE tr_GSUP_IE_SessionId(template OCT4 sid) := {
610 tag := OSMO_GSUP_SESSION_ID_IE,
611 len := ?,
612 val := {
613 session_id := sid
614 }
615}
616
617template (value) GSUP_IE ts_GSUP_IE_SessionState(GSUP_SessionState state) := {
618 tag := OSMO_GSUP_SESSION_STATE_IE,
619 len := 0, /* overwritten */
620 val := {
621 session_state := state
622 }
623}
624template GSUP_IE tr_GSUP_IE_SessionState(template GSUP_SessionState state) := {
625 tag := OSMO_GSUP_SESSION_STATE_IE,
626 len := ?,
627 val := {
628 session_state := state
629 }
630}
631
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700632template (value) GSUP_IE ts_GSUP_IE_SM_RP_MR(OCT1 ref) := {
633 tag := OSMO_GSUP_SM_RP_MR_IE,
634 len := 0, /* overwritten */
635 val := {
636 sm_rp_mr := ref
637 }
638}
639template GSUP_IE tr_GSUP_IE_SM_RP_MR(template OCT1 ref) := {
640 tag := OSMO_GSUP_SM_RP_MR_IE,
641 len := ?,
642 val := {
643 sm_rp_mr := ref
644 }
645}
646
647template (value) GSUP_IE ts_GSUP_IE_SM_RP_CAUSE(OCT1 cause) := {
648 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
649 len := 0, /* overwritten */
650 val := {
651 sm_rp_cause := cause
652 }
653}
654template GSUP_IE tr_GSUP_IE_SM_RP_CAUSE(template OCT1 cause) := {
655 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
656 len := ?,
657 val := {
658 sm_rp_cause := cause
659 }
660}
661
662template (value) GSUP_IE ts_GSUP_IE_SM_RP_MMS(OCT1 mms) := {
663 tag := OSMO_GSUP_SM_RP_MMS_IE,
664 len := 0, /* overwritten */
665 val := {
666 sm_rp_mms := mms
667 }
668}
669template GSUP_IE tr_GSUP_IE_SM_RP_MMS(template OCT1 mms) := {
670 tag := OSMO_GSUP_SM_RP_MMS_IE,
671 len := ?,
672 val := {
673 sm_rp_mms := mms
674 }
675}
676
677/* Possible identity types for SM-RP-{OA|DA} IEs */
678type enumerated GSUP_SM_RP_ODA_IdType {
679 OSMO_GSUP_SM_RP_ODA_ID_NONE ('00'O),
680 OSMO_GSUP_SM_RP_ODA_ID_IMSI ('01'O),
681 OSMO_GSUP_SM_RP_ODA_ID_MSISDN ('02'O),
682 OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR ('03'O),
683 /* Special value for noSM-RP-DA and noSM-RP-OA */
684 OSMO_GSUP_SM_RP_ODA_ID_NULL ('FF'O)
685} with { variant "FIELDLENGTH(8)" };
686
687/**
688 * SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
689 * It can be either of the following:
690 * - IMSI
691 * - LMSI (not implemented)
692 * - MSISDN
693 * - roaming number (not implemented)
694 * - service centre address
695 */
696type union GSUP_SM_RP_DA_ID {
697 hexstring imsi,
698 hexstring msisdn,
699 hexstring smsc_addr
700};
701
702type record GSUP_SM_RP_DA {
703 GSUP_SM_RP_ODA_IdType id_type,
704 uint8_t id_len,
705 GSUP_SM_RP_DA_ID id_enc optional
706} with { variant (id_len) "LENGTHTO(id_enc)"
707 variant (id_enc) "CROSSTAG(
708 imsi, id_type = OSMO_GSUP_SM_RP_ODA_ID_IMSI;
709 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
710 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
711 /* FIXME: how to handle noSM-RP-DA? */
712 )"
713};
714
715template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_IMSI(hexstring imsi) := {
716 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
717 id_len := 0, /* overwritten */
718 id_enc := { imsi := imsi }
719}
720template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_IMSI(template hexstring imsi) := {
721 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
722 id_len := ?,
723 id_enc := { imsi := imsi }
724}
725
726template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(hexstring msisdn) := {
727 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
728 id_len := 0, /* overwritten */
729 id_enc := { msisdn := msisdn }
730}
731template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template hexstring msisdn) := {
732 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
733 id_len := ?,
734 id_enc := { msisdn := msisdn }
735}
736
737template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(hexstring smsc_addr) := {
738 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
739 id_len := 0, /* overwritten */
740 id_enc := { smsc_addr := smsc_addr }
741}
742template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template hexstring smsc_addr) := {
743 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
744 id_len := ?,
745 id_enc := { smsc_addr := smsc_addr }
746}
747
748template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_NULL := {
749 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
750 id_len := 0, /* overwritten */
751 id_enc := omit
752}
753template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_NULL := {
754 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
755 id_len := ?,
756 id_enc := omit
757}
758
759template (value) GSUP_IE ts_GSUP_IE_SM_RP_DA(GSUP_SM_RP_DA val) := {
760 tag := OSMO_GSUP_SM_RP_DA_IE,
761 len := 0, /* overwritten */
762 val := {
763 sm_rp_da := val
764 }
765}
766template GSUP_IE tr_GSUP_IE_SM_RP_DA(template GSUP_SM_RP_DA val) := {
767 tag := OSMO_GSUP_SM_RP_DA_IE,
768 len := ?,
769 val := {
770 sm_rp_da := val
771 }
772}
773
774/**
775 * SM-RP-OA represents the SM Originating Address, see 7.6.8.2.
776 * It can be either of the following:
777 * - MSISDN
778 * - service centre address
779 */
780type union GSUP_SM_RP_OA_ID {
781 hexstring msisdn,
782 hexstring smsc_addr
783};
784
785type record GSUP_SM_RP_OA {
786 GSUP_SM_RP_ODA_IdType id_type,
787 uint8_t id_len,
788 GSUP_SM_RP_OA_ID id_enc optional
789} with { variant (id_len) "LENGTHTO(id_enc)"
790 variant (id_enc) "CROSSTAG(
791 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
792 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
793 /* FIXME: how to handle noSM-RP-OA? */
794 )"
795};
796
797template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(hexstring msisdn) := {
798 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
799 id_len := 0, /* overwritten */
800 id_enc := { msisdn := msisdn }
801}
802template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template hexstring msisdn) := {
803 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
804 id_len := ?,
805 id_enc := { msisdn := msisdn }
806}
807
808template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(hexstring smsc_addr) := {
809 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
810 id_len := 0, /* overwritten */
811 id_enc := { smsc_addr := smsc_addr }
812}
813template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template hexstring smsc_addr) := {
814 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
815 id_len := ?,
816 id_enc := { smsc_addr := smsc_addr }
817}
818
819template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_NULL := {
820 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
821 id_len := 0, /* overwritten */
822 id_enc := omit
823}
824template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_NULL := {
825 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
826 id_len := ?,
827 id_enc := omit
828}
829
830template (value) GSUP_IE ts_GSUP_IE_SM_RP_OA(GSUP_SM_RP_OA val) := {
831 tag := OSMO_GSUP_SM_RP_OA_IE,
832 len := 0, /* overwritten */
833 val := {
834 sm_rp_oa := val
835 }
836}
837template GSUP_IE tr_GSUP_IE_SM_RP_OA(template GSUP_SM_RP_OA val) := {
838 tag := OSMO_GSUP_SM_RP_OA_IE,
839 len := ?,
840 val := {
841 sm_rp_oa := val
842 }
843}
844
845/* SM-RP-UI represents the SM TPDU, see 7.6.8.4 */
846template (value) GSUP_IE ts_GSUP_IE_SM_RP_UI(octetstring val) := {
847 tag := OSMO_GSUP_SM_RP_UI_IE,
848 len := 0, /* overwritten */
849 val := {
850 sm_rp_ui := val
851 }
852}
853template GSUP_IE tr_GSUP_IE_SM_RP_UI(template octetstring val) := {
854 tag := OSMO_GSUP_SM_RP_UI_IE,
855 len := ?,
856 val := {
857 sm_rp_ui := val
858 }
859}
860
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700861/* SM Alert Reason types, see 7.6.8.8 */
862type enumerated GSUP_SM_ALERT_RSN_Type {
863 GSUP_SM_ALERT_RSN_TYPE_NONE ('00'O),
864 GSUP_SM_ALERT_RSN_TYPE_MS_PRESENT ('01'O),
865 GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL ('02'O)
866} with { variant "FIELDLENGTH(8)" };
867
868/* SM Alert Reason IE (used in READY-FOR-SM), see 7.6.8.8 */
869template (value) GSUP_IE ts_GSUP_IE_SM_ALERT_RSN(GSUP_SM_ALERT_RSN_Type rsn) := {
870 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
871 len := 0, /* overwritten */
872 val := {
873 sm_alert_rsn := rsn
874 }
875}
876template GSUP_IE tr_GSUP_IE_SM_ALERT_RSN(template GSUP_SM_ALERT_RSN_Type rsn) := {
877 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
878 len := ?,
879 val := {
880 sm_alert_rsn := rsn
881 }
882}
883
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700884template (value) GSUP_IE ts_GSUP_IE_SSInfo(octetstring ss) := {
885 tag := OSMO_GSUP_SS_INFO_IE,
886 len := 0, /* overwritten */
887 val := {
888 ss_info := ss
889 }
890}
891template GSUP_IE tr_GSUP_IE_SSInfo(template octetstring ss) := {
892 tag := OSMO_GSUP_SS_INFO_IE,
893 len := ?,
894 val := {
895 ss_info := ss
896 }
897}
898
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700899private function f_gen_ts_ss_ies(
900 hexstring imsi,
901 OCT4 sid,
902 GSUP_SessionState state,
903 template (omit) octetstring ss
904) return GSUP_IEs {
905 /* Mandatory IEs */
906 var GSUP_IEs ies := {
907 valueof(ts_GSUP_IE_IMSI(imsi)),
908 valueof(ts_GSUP_IE_SessionId(sid)),
909 valueof(ts_GSUP_IE_SessionState(state))
910 };
911
912 /* Optional SS payload */
913 if (isvalue(ss)) {
914 ies[3] := valueof(ts_GSUP_IE_SSInfo(valueof(ss)));
915 }
916
917 return ies;
918}
919private function f_gen_tr_ss_ies(
920 template hexstring imsi,
921 template OCT4 sid := ?,
922 template GSUP_SessionState state := ?,
923 template octetstring ss := ?
924) return template GSUP_IEs {
925 /* Mandatory IEs */
926 var template GSUP_IEs ies := {
927 tr_GSUP_IE_IMSI(imsi),
928 tr_GSUP_IE_SessionId(sid),
929 tr_GSUP_IE_SessionState(state)
930 };
931
932 /* Optional SS payload */
933 if (istemplatekind(ss, "*")) {
934 ies[3] := *;
935 } else if (not istemplatekind(ss, "omit")) {
936 ies[3] := tr_GSUP_IE_SSInfo(ss);
937 }
938
939 return ies;
940}
941
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700942template (value) GSUP_PDU ts_GSUP_PROC_SS_REQ(
943 hexstring imsi,
944 OCT4 sid,
945 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700946 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700947) := ts_GSUP(
948 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700949 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700950);
951template GSUP_PDU tr_GSUP_PROC_SS_REQ(
952 template hexstring imsi,
953 template OCT4 sid := ?,
954 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700955 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700956) := tr_GSUP(
957 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700958 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700959);
960
961template (value) GSUP_PDU ts_GSUP_PROC_SS_RES(
962 hexstring imsi,
963 OCT4 sid,
964 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700965 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700966) := ts_GSUP(
967 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700968 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700969);
970template GSUP_PDU tr_GSUP_PROC_SS_RES(
971 template hexstring imsi,
972 template OCT4 sid := ?,
973 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700974 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700975) := tr_GSUP(
976 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +0700977 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700978);
979
980template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR(
981 hexstring imsi,
982 OCT4 sid,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +0700983 GSUP_SessionState state,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700984 integer cause
985) := ts_GSUP(
986 OSMO_GSUP_MSGT_PROC_SS_ERROR,
987 {
988 valueof(ts_GSUP_IE_IMSI(imsi)),
Vadim Yanitskiy772a8452018-11-29 02:17:37 +0700989 valueof(ts_GSUP_IE_Cause(cause)),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700990 valueof(ts_GSUP_IE_SessionId(sid)),
Vadim Yanitskiy772a8452018-11-29 02:17:37 +0700991 valueof(ts_GSUP_IE_SessionState(state))
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700992 }
993);
994template GSUP_PDU tr_GSUP_PROC_SS_ERR(
995 template hexstring imsi,
996 template OCT4 sid := ?,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +0700997 template GSUP_SessionState state := ?,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700998 template integer cause := ?
999) := tr_GSUP(
1000 OSMO_GSUP_MSGT_PROC_SS_ERROR,
1001 {
1002 tr_GSUP_IE_IMSI(imsi),
Vadim Yanitskiy772a8452018-11-29 02:17:37 +07001003 tr_GSUP_IE_Cause(cause),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001004 tr_GSUP_IE_SessionId(sid),
Vadim Yanitskiy772a8452018-11-29 02:17:37 +07001005 tr_GSUP_IE_SessionState(state)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001006 }
1007);
Harald Weltedf327232017-12-28 22:51:51 +01001008
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001009template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_REQ(
1010 hexstring imsi,
1011 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1012 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1013 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1014 octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1015) := ts_GSUP(
1016 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1017 {
1018 valueof(ts_GSUP_IE_IMSI(imsi)),
1019 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1020 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1021 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1022 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui))
1023 }
1024);
1025template GSUP_PDU tr_GSUP_MO_FORWARD_SM_REQ(
1026 template hexstring imsi := ?,
1027 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1028 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1029 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1030 template octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1031) := tr_GSUP(
1032 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1033 {
1034 tr_GSUP_IE_IMSI(imsi),
1035 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1036 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1037 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1038 tr_GSUP_IE_SM_RP_UI(sm_rp_ui)
1039 }
1040);
1041
1042template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_RES(
1043 hexstring imsi,
1044 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1045) := ts_GSUP(
1046 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1047 {
1048 valueof(ts_GSUP_IE_IMSI(imsi)),
1049 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1050 }
1051);
1052template GSUP_PDU tr_GSUP_MO_FORWARD_SM_RES(
1053 template hexstring imsi := ?,
1054 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1055) := tr_GSUP(
1056 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1057 {
1058 tr_GSUP_IE_IMSI(imsi),
1059 tr_GSUP_IE_SM_RP_MR(sm_rp_mr)
1060 }
1061);
1062
1063template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_ERR(
1064 hexstring imsi,
1065 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1066 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1067) := ts_GSUP(
1068 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1069 {
1070 valueof(ts_GSUP_IE_IMSI(imsi)),
1071 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1072 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1073 }
1074);
1075template GSUP_PDU tr_GSUP_MO_FORWARD_SM_ERR(
1076 template hexstring imsi := ?,
1077 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1078 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1079) := tr_GSUP(
1080 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1081 {
1082 tr_GSUP_IE_IMSI(imsi),
1083 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1084 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)
1085 }
1086);
1087
1088template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_REQ(
1089 hexstring imsi,
1090 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1091 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1092 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1093 octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1094 OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1095) := ts_GSUP(
1096 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1097 {
1098 /**
1099 * TODO: add MT-specific fields (and IEs):
1100 * - smDeliveryTimer
1101 * - smDeliveryStartTime
1102 */
1103 valueof(ts_GSUP_IE_IMSI(imsi)),
1104 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1105 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1106 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1107 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
1108 valueof(ts_GSUP_IE_SM_RP_MMS(sm_rp_mms))
1109 }
1110);
1111template GSUP_PDU tr_GSUP_MT_FORWARD_SM_REQ(
1112 template hexstring imsi := ?,
1113 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1114 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1115 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1116 template octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1117 template OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1118) := tr_GSUP(
1119 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1120 {
1121 /**
1122 * TODO: add MT-specific fields (and IEs):
1123 * - smDeliveryTimer
1124 * - smDeliveryStartTime
1125 */
1126 tr_GSUP_IE_IMSI(imsi),
1127 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1128 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1129 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1130 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
1131 tr_GSUP_IE_SM_RP_MMS(sm_rp_mms)
1132 }
1133);
1134
1135template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_RES(
1136 hexstring imsi,
1137 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1138) := ts_GSUP(
1139 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1140 {
1141 valueof(ts_GSUP_IE_IMSI(imsi)),
1142 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1143 }
1144);
1145template GSUP_PDU tr_GSUP_MT_FORWARD_SM_RES(
1146 template hexstring imsi := ?,
1147 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1148) := tr_GSUP(
1149 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1150 {
1151 tr_GSUP_IE_IMSI(imsi),
1152 tr_GSUP_IE_SM_RP_MR(sm_rp_mr)
1153 }
1154);
1155
1156template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_ERR(
1157 hexstring imsi,
1158 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1159 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1160) := ts_GSUP(
1161 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1162 {
1163 valueof(ts_GSUP_IE_IMSI(imsi)),
1164 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1165 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1166 }
1167);
1168template GSUP_PDU tr_GSUP_MT_FORWARD_SM_ERR(
1169 template hexstring imsi := ?,
1170 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1171 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1172) := tr_GSUP(
1173 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1174 {
1175 tr_GSUP_IE_IMSI(imsi),
1176 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1177 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)
1178 }
1179);
1180
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001181template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_REQ(
1182 hexstring imsi,
1183 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1184 GSUP_SM_ALERT_RSN_Type sm_alert_rsn /* SM Alert Reason, see 7.6.8.8 */
1185) := ts_GSUP(
1186 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1187 {
1188 valueof(ts_GSUP_IE_IMSI(imsi)),
1189 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1190 valueof(ts_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn))
1191 }
1192);
1193template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_REQ(
1194 template hexstring imsi := ?,
1195 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1196 template GSUP_SM_ALERT_RSN_Type sm_alert_rsn := ? /* SM Alert Reason, see 7.6.8.8 */
1197) := tr_GSUP(
1198 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1199 {
1200 tr_GSUP_IE_IMSI(imsi),
1201 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1202 tr_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn)
1203 }
1204);
1205
1206template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_RES(
1207 hexstring imsi,
1208 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1209) := ts_GSUP(
1210 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1211 {
1212 valueof(ts_GSUP_IE_IMSI(imsi)),
1213 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1214 }
1215);
1216template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_RES(
1217 template hexstring imsi := ?,
1218 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1219) := tr_GSUP(
1220 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1221 {
1222 tr_GSUP_IE_IMSI(imsi),
1223 tr_GSUP_IE_SM_RP_MR(sm_rp_mr)
1224 }
1225);
1226
1227template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_ERR(
1228 hexstring imsi,
1229 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1230 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1231) := ts_GSUP(
1232 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1233 {
1234 valueof(ts_GSUP_IE_IMSI(imsi)),
1235 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1236 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1237 }
1238);
1239template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_ERR(
1240 template hexstring imsi := ?,
1241 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1242 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1243) := tr_GSUP(
1244 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1245 {
1246 tr_GSUP_IE_IMSI(imsi),
1247 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1248 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)
1249 }
1250);
1251
Harald Weltef9d449e2018-06-24 22:27:47 +02001252function f_gsup_find_ie(GSUP_PDU msg, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1253 for (var integer i := 0; i < sizeof(msg.ies); i := i+1) {
1254 if (msg.ies[i].tag == iei) {
1255 ret := msg.ies[i].val;
1256 return true;
1257 }
1258 }
1259 return false;
1260}
1261
1262
Harald Weltedf327232017-12-28 22:51:51 +01001263} with { encode "RAW"; variant "FIELDORDER(msb)" }