blob: 739dcbc79ce00d5ac537314bbe65c6a225b0fa1e [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 *
Harald Welte34b5a952019-05-27 11:54:11 +02008 * (C) 2017-2019 by Harald Welte <laforge@gnumonks.org>
9 * contributions by sysmocom - s.f.m.c. GmbH
Harald Welte35bb7162018-01-03 21:07:52 +010010 * All rights reserved.
11 *
12 * Released under the terms of GNU General Public License, Version 2 or
13 * (at your option) any later version.
Harald Welte34b5a952019-05-27 11:54:11 +020014 *
15 * SPDX-License-Identifier: GPL-2.0-or-later
Harald Welte35bb7162018-01-03 21:07:52 +010016 */
17
Harald Weltedf327232017-12-28 22:51:51 +010018import from General_Types all;
19import from Osmocom_Types all;
20
21type enumerated GSUP_IEI {
22 OSMO_GSUP_IMSI_IE ('01'O),
23 OSMO_GSUP_CAUSE_IE ('02'O),
24 OSMO_GSUP_AUTH_TUPLE_IE ('03'O),
25 OSMO_GSUP_PDP_INFO_COMPL_IE ('04'O),
26 OSMO_GSUP_PDP_INFO_IE ('05'O),
27 OSMO_GSUP_CANCEL_TYPE_IE ('06'O),
28 OSMO_GSUP_FREEZE_PTMSI_IE ('07'O),
29 OSMO_GSUP_MSISDN_IE ('08'O),
30 OSMO_GSUP_HLR_NUMBER_IE ('09'O),
31 OSMO_GSUP_PDP_CONTEXT_ID_IE ('10'O),
32 OSMO_GSUP_PDP_TYPE_IE ('11'O),
33 OSMO_GSUP_ACCESS_POINT_NAME_IE ('12'O),
34 OSMO_GSUP_PDP_QOS_IE ('13'O),
35 OSMO_GSUP_CHARG_CHAR_IE ('14'O),
36
37 OSMO_GSUP_RAND_IE ('20'O),
38 OSMO_GSUP_SRES_IE ('21'O),
39 OSMO_GSUP_KC_IE ('22'O),
40 OSMO_GSUP_IK_IE ('23'O),
41 OSMO_GSUP_CK_IE ('24'O),
42 OSMO_GSUP_AUTN_IE ('25'O),
43 OSMO_GSUP_AUTS_IE ('26'O),
44 OSMO_GSUP_RES_IE ('27'O),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +070045 OSMO_GSUP_CN_DOMAIN_IE ('28'O),
Harald Welte0a1fd0e2019-12-03 20:01:08 +010046 OSMO_GSUP_SUPPORTED_RAT_TYPES_IE ('29'O),
47 OSMO_GSUP_CURRENT_RAT_TYPE_IE ('2a'O),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +070048
49 OSMO_GSUP_SESSION_ID_IE ('30'O),
50 OSMO_GSUP_SESSION_STATE_IE ('31'O),
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +070051 OSMO_GSUP_SS_INFO_IE ('35'O),
52
53 /* SM related IEs (see 3GPP TS 29.002, section 7.6.8) */
54 OSMO_GSUP_SM_RP_MR_IE ('40'O),
55 OSMO_GSUP_SM_RP_DA_IE ('41'O),
56 OSMO_GSUP_SM_RP_OA_IE ('42'O),
57 OSMO_GSUP_SM_RP_UI_IE ('43'O),
58 OSMO_GSUP_SM_RP_CAUSE_IE ('44'O),
Vadim Yanitskiy88e23232018-11-13 03:04:02 +070059 OSMO_GSUP_SM_RP_MMS_IE ('45'O),
Oliver Smithc5748292019-02-22 15:02:48 +010060 OSMO_GSUP_SM_ALERT_RSN_IE ('46'O),
61
62 OSMO_GSUP_IMEI_IE ('50'O),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +020063 OSMO_GSUP_IMEI_RESULT_IE ('51'O),
Alexander Couzens752f86b2020-01-10 07:56:31 +010064 OSMO_GSUP_NUM_VECTORS_REQ_IE ('52'O),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +020065
66 OSMO_GSUP_MESSAGE_CLASS_IE ('0a'O),
67
68 OSMO_GSUP_SOURCE_NAME_IE ('60'O),
69 OSMO_GSUP_DESTINATION_NAME_IE ('61'O),
70 OSMO_GSUP_AN_APDU_IE ('62'O),
71 OSMO_GSUP_CAUSE_RR_IE ('63'O),
72 OSMO_GSUP_CAUSE_BSSAP_IE ('64'O),
73 OSMO_GSUP_CAUSE_SM_IE ('65'O)
Harald Weltedf327232017-12-28 22:51:51 +010074} with { variant "FIELDLENGTH(8)" };
75
76type enumerated GSUP_MessageType {
77 OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST ('00000100'B),
78 OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR ('00000101'B),
79 OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT ('00000110'B),
80
81 OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST ('00001000'B),
82 OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR ('00001001'B),
83 OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT ('00001010'B),
84
85 OSMO_GSUP_MSGT_AUTH_FAIL_REPORT ('00001011'B),
86
87 OSMO_GSUP_MSGT_PURGE_MS_REQUEST ('00001100'B),
88 OSMO_GSUP_MSGT_PURGE_MS_ERROR ('00001101'B),
89 OSMO_GSUP_MSGT_PURGE_MS_RESULT ('00001110'B),
90
91 OSMO_GSUP_MSGT_INSERT_DATA_REQUEST ('00010000'B),
92 OSMO_GSUP_MSGT_INSERT_DATA_ERROR ('00010001'B),
93 OSMO_GSUP_MSGT_INSERT_DATA_RESULT ('00010010'B),
94
95 OSMO_GSUP_MSGT_DELETE_DATA_REQUEST ('00010100'B),
96 OSMO_GSUP_MSGT_DELETE_DATA_ERROR ('00010101'B),
97 OSMO_GSUP_MSGT_DELETE_DATA_RESULT ('00010110'B),
98
99 OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST ('00011100'B),
100 OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR ('00011101'B),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700101 OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT ('00011110'B),
102
103 OSMO_GSUP_MSGT_PROC_SS_REQUEST ('00100000'B),
104 OSMO_GSUP_MSGT_PROC_SS_ERROR ('00100001'B),
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700105 OSMO_GSUP_MSGT_PROC_SS_RESULT ('00100010'B),
106
107 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST ('00100100'B),
108 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR ('00100101'B),
109 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT ('00100110'B),
110
111 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST ('00101000'B),
112 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR ('00101001'B),
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700113 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT ('00101010'B),
114
115 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST ('00101100'B),
116 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR ('00101101'B),
Oliver Smithc5748292019-02-22 15:02:48 +0100117 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT ('00101110'B),
118
119 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST ('00110000'B),
120 OSMO_GSUP_MSGT_CHECK_IMEI_ERROR ('00110001'B),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200121 OSMO_GSUP_MSGT_CHECK_IMEI_RESULT ('00110010'B),
122
123 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST ('00110100'B),
124 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_ERROR ('00110101'B),
125 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT ('00110110'B),
126
127 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST ('00111000'B),
128 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_ERROR ('00111001'B),
129 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT ('00111010'B),
130
131 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST ('00111100'B),
132 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_ERROR ('00111101'B),
133 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_RESULT ('00111110'B),
134
135 OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST ('01000000'B),
136 OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST ('01000100'B),
137
138 OSMO_GSUP_MSGT_E_CLOSE ('01000111'B),
139 OSMO_GSUP_MSGT_E_ABORT ('01001011'B),
140
141 OSMO_GSUP_MSGT_E_ROUTING_ERROR ('01001110'B)
Harald Weltedf327232017-12-28 22:51:51 +0100142} with { variant "FIELDLENGTH(8)" };
143
144type enumerated GSUP_CancelType {
Alexander Couzens4786b3f2018-09-16 03:33:30 +0200145 OSMO_GSUP_CANCEL_TYPE_UPDATE (0),
146 OSMO_GSUP_CANCEL_TYPE_WITHDRAW (1)
Harald Weltedf327232017-12-28 22:51:51 +0100147} with { variant "FIELDLENGTH(8)" };
148
149type enumerated GSUP_CnDomain {
150 OSMO_GSUP_CN_DOMAIN_PS (1),
151 OSMO_GSUP_CN_DOMAIN_CS (2)
152} with { variant "FIELDLENGTH(8)" };
153
Oliver Smithc5748292019-02-22 15:02:48 +0100154type enumerated GSUP_IMEIResult {
155 OSMO_GSUP_IMEI_RESULT_ACK (0),
156 OSMO_GSUP_IMEI_RESULT_NACK (1)
157} with { variant "FIELDLENGTH(8)" };
158
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700159type enumerated GSUP_SessionState {
160 OSMO_GSUP_SESSION_STATE_NONE (0),
161 OSMO_GSUP_SESSION_STATE_BEGIN (1),
162 OSMO_GSUP_SESSION_STATE_CONTINUE (2),
163 OSMO_GSUP_SESSION_STATE_END (3)
164} with { variant "FIELDLENGTH(8)" };
165
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200166type enumerated GSUP_Message_Class {
167 OSMO_GSUP_MESSAGE_CLASS_UNSET (0),
168 OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT (1),
169 OSMO_GSUP_MESSAGE_CLASS_SMS (2),
170 OSMO_GSUP_MESSAGE_CLASS_USSD (3),
171 OSMO_GSUP_MESSAGE_CLASS_INTER_MSC (4)
172} with { variant "FIELDLENGTH(8)" };
173
Harald Welte3f95be82018-01-27 00:48:13 +0100174type record GSUP_MSISDN {
175 uint8_t len,
176 hexstring digits optional
177} with { variant (len) "LENGTHTO(digits)" };
178
Oliver Smithc5748292019-02-22 15:02:48 +0100179type record GSUP_IMEI {
180 uint8_t len,
181 hexstring digits optional
182} with { variant (len) "LENGTHTO(digits)" };
183
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200184type enumerated GSUP_AN_PROTO {
185 OSMO_GSUP_AN_PROTO_48006 (1),
186 OSMO_GSUP_AN_PROTO_25413 (2)
187} with { variant "FIELDLENGTH(8)" };
188
189type record GSUP_AN_APDU {
190 GSUP_AN_PROTO proto,
191 octetstring pdu
192};
193
Harald Weltedf327232017-12-28 22:51:51 +0100194type record GSUP_IE {
195 GSUP_IEI tag,
196 uint8_t len,
197 GSUP_IeValue val
198} with { variant (len) "LENGTHTO(val)"
199 variant (val) "CROSSTAG(imsi, tag = OSMO_GSUP_IMSI_IE;
200 cause, tag = OSMO_GSUP_CAUSE_IE;
201 cancel_type, tag = OSMO_GSUP_CANCEL_TYPE_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100202 auth_tuple, tag = OSMO_GSUP_AUTH_TUPLE_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100203 auts, tag = OSMO_GSUP_AUTS_IE;
204 rand, tag = OSMO_GSUP_RAND_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100205 sres, tag = OSMO_GSUP_SRES_IE;
206 kc, tag = OSMO_GSUP_KC_IE;
207 ik, tag = OSMO_GSUP_IK_IE;
208 ck, tag = OSMO_GSUP_CK_IE;
209 autn, tag = OSMO_GSUP_AUTN_IE;
210 res, tag = OSMO_GSUP_RES_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100211 msisdn, tag = OSMO_GSUP_MSISDN_IE;
212 hlr_number, tag = OSMO_GSUP_HLR_NUMBER_IE;
213 cn_domain, tag = OSMO_GSUP_CN_DOMAIN_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100214 pdp_info, tag = OSMO_GSUP_PDP_INFO_IE;
215 apn, tag = OSMO_GSUP_ACCESS_POINT_NAME_IE;
216 pdp_qos, tag = OSMO_GSUP_PDP_QOS_IE;
217 pdp_type, tag = OSMO_GSUP_PDP_TYPE_IE;
218 charg_char, tag = OSMO_GSUP_CHARG_CHAR_IE;
Alexander Couzens25d28492023-04-26 19:30:04 +0200219 pdp_ctx_id, tag = OSMO_GSUP_PDP_CONTEXT_ID_IE;
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700220 session_state, tag = OSMO_GSUP_SESSION_STATE_IE;
221 session_id, tag = OSMO_GSUP_SESSION_ID_IE;
222 ss_info, tag = OSMO_GSUP_SS_INFO_IE;
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700223 sm_rp_mr, tag = OSMO_GSUP_SM_RP_MR_IE;
224 sm_rp_da, tag = OSMO_GSUP_SM_RP_DA_IE;
225 sm_rp_oa, tag = OSMO_GSUP_SM_RP_OA_IE;
226 sm_rp_ui, tag = OSMO_GSUP_SM_RP_UI_IE;
227 sm_rp_cause, tag = OSMO_GSUP_SM_RP_CAUSE_IE;
228 sm_rp_mms, tag = OSMO_GSUP_SM_RP_MMS_IE;
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700229 sm_alert_rsn, tag = OSMO_GSUP_SM_ALERT_RSN_IE;
Oliver Smithc5748292019-02-22 15:02:48 +0100230 imei, tag = OSMO_GSUP_IMEI_IE;
231 imei_result, tag = OSMO_GSUP_IMEI_RESULT_IE;
Alexander Couzens752f86b2020-01-10 07:56:31 +0100232 num_auth_vectors, tag = OSMO_GSUP_NUM_VECTORS_REQ_IE;
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200233 message_class, tag = OSMO_GSUP_MESSAGE_CLASS_IE;
234 source_name, tag = OSMO_GSUP_SOURCE_NAME_IE;
235 destination_name, tag = OSMO_GSUP_DESTINATION_NAME_IE;
236 an_apdu, tag = OSMO_GSUP_AN_APDU_IE;
237 cause_rr, tag = OSMO_GSUP_CAUSE_RR_IE;
238 cause_bssap, tag = OSMO_GSUP_CAUSE_BSSAP_IE;
239 cause_sm, tag = OSMO_GSUP_CAUSE_SM_IE;
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100240 supported_rat_types, tag = OSMO_GSUP_SUPPORTED_RAT_TYPES_IE;
241 current_rat_type, tag = OSMO_GSUP_CURRENT_RAT_TYPE_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100242 )"
Harald Weltedf327232017-12-28 22:51:51 +0100243};
244
245type record of GSUP_IE GSUP_IEs;
246
Harald Welte8eebb6c2019-08-22 12:40:03 +0200247type enumerated GSUP_RatType {
248 RAT_TYPE_UNKNOWN (0),
249 RAT_TYPE_GERAN_A (1),
250 RAT_TYPE_UTRAN_Iu (2),
251 RAT_TYPE_EUTRAN_SGs (3)
252} with { variant "FIELDLENGTH(8)" };
253
254type record of GSUP_RatType GSUP_RatTypes;
255
Harald Weltedf327232017-12-28 22:51:51 +0100256type union GSUP_IeValue {
257 hexstring imsi,
258 integer cause,
259 GSUP_CancelType cancel_type,
260 //boolean pdp_info_compl,
261 //boolean freeze_ptmsi,
Harald Weltedf327232017-12-28 22:51:51 +0100262 GSUP_IEs auth_tuple,
263 octetstring auts,
264 octetstring rand,
Harald Welte77a8eba2018-01-22 21:22:32 +0100265 octetstring sres,
266 octetstring kc,
267 octetstring ik,
268 octetstring ck,
269 octetstring autn,
270 octetstring res,
Harald Welte3f95be82018-01-27 00:48:13 +0100271 GSUP_MSISDN msisdn,
Harald Weltedf327232017-12-28 22:51:51 +0100272 octetstring hlr_number,
273 GSUP_CnDomain cn_domain,
Harald Welteeded9ad2018-02-17 20:57:34 +0100274 /* PDP context + nested IEs */
275 GSUP_IEs pdp_info,
Alexander Couzens25d28492023-04-26 19:30:04 +0200276 OCT1 pdp_ctx_id,
Harald Welteeded9ad2018-02-17 20:57:34 +0100277 octetstring apn,
278 octetstring pdp_qos,
279 OCT2 pdp_type,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700280 octetstring charg_char,
281 /* Session information */
282 GSUP_SessionState session_state,
283 OCT4 session_id,
284 /* Supplementary Services */
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700285 octetstring ss_info,
286 /* Short Message Service */
287 OCT1 sm_rp_mr,
288 GSUP_SM_RP_DA sm_rp_da,
289 GSUP_SM_RP_OA sm_rp_oa,
290 octetstring sm_rp_ui,
291 OCT1 sm_rp_cause,
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700292 OCT1 sm_rp_mms,
Oliver Smithc5748292019-02-22 15:02:48 +0100293 GSUP_SM_ALERT_RSN_Type sm_alert_rsn,
294
295 GSUP_IMEI imei,
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200296 GSUP_IMEIResult imei_result,
Alexander Couzens752f86b2020-01-10 07:56:31 +0100297 OCT1 num_auth_vectors,
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200298
299 GSUP_Message_Class message_class,
300
301 octetstring source_name,
302 octetstring destination_name,
303
304 GSUP_AN_APDU an_apdu,
305
306 OCT1 cause_rr,
307 OCT1 cause_bssap,
Harald Welte8eebb6c2019-08-22 12:40:03 +0200308 OCT1 cause_sm,
309
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100310 GSUP_RatTypes supported_rat_types,
311 GSUP_RatType current_rat_type
Harald Weltedf327232017-12-28 22:51:51 +0100312};
313
314type record GSUP_PDU {
315 GSUP_MessageType msg_type,
316 GSUP_IEs ies
317};
318
Alexander Couzens25d28492023-04-26 19:30:04 +0200319type record of GSUP_PDU GSUP_PDUs;
320
Harald Weltedf327232017-12-28 22:51:51 +0100321external function enc_GSUP_PDU(in GSUP_PDU msg) return octetstring
322 with { extension "prototype(convert) encode(RAW)" };
323
324external function dec_GSUP_PDU(in octetstring msg) return GSUP_PDU
325 with { extension "prototype(convert) decode(RAW)" };
326
Harald Welte2f562b12018-01-24 20:52:38 +0100327function f_gsup_postprocess_decoded(inout GSUP_PDU gsup) {
328 if (gsup.ies[0].tag == OSMO_GSUP_IMSI_IE) {
329 /* if last digit is 'F', then there's an odd number of digits and we must strip the F */
330 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
331 if (gsup.ies[0].val.imsi[num_digits-1] == 'F'H) {
332 gsup.ies[0].val.imsi := substr(gsup.ies[0].val.imsi, 0, num_digits-1);
333 }
334 }
335}
336
337function f_gsup_preprocess_encoded(inout GSUP_PDU gsup) {
338 if (ischosen(gsup.ies[0].val.imsi)) {
339 /* if number of digits is odd, add a 'F' as padding at the end */
340 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
341 if (num_digits rem 2 == 1) {
342 gsup.ies[0].val.imsi := gsup.ies[0].val.imsi & 'F'H;
343 }
344 }
345}
346
Harald Welte3f95be82018-01-27 00:48:13 +0100347template (value) GSUP_MSISDN ts_GSUP_MSISDN(hexstring digits,
348 BIT3 ton := '000'B,
349 BIT4 npi := '0000'B) := {
350 len := 0, /* overwritten */
351 /* numberingPlanIdentification := npi,
352 typeOfNumber := ton,
353 ext1 := '0'B, */
354 digits := digits
355}
356
357template GSUP_MSISDN tr_GSUP_MSISDN(template hexstring digits,
358 template BIT3 ton := ?,
359 template BIT4 npi := ?) := {
360 len := ?,
361 /* numberingPlanIdentification := npi,
362 typeOfNumber := ton,
363 ext1 := '0'B, */
364 digits := digits
365}
366
367
Harald Weltedf327232017-12-28 22:51:51 +0100368
Harald Welte77a8eba2018-01-22 21:22:32 +0100369template GSUP_IE ts_GSUP_IE_AuthTuple2G(octetstring rand, octetstring sres,
370 octetstring kc) := {
371 tag := OSMO_GSUP_AUTH_TUPLE_IE,
372 len := 0, /* overwritten */
373 val := {
374 auth_tuple := {
375 valueof(ts_GSUP_IE_RAND(rand)),
376 valueof(ts_GSUP_IE_SRES(sres)),
377 valueof(ts_GSUP_IE_Kc(kc))
378 }
379 }
380}
381
Pau Espin Pedrol965ac642023-10-16 18:12:45 +0200382template GSUP_IE tr_GSUP_IE_AuthTuple3G(
383 template (present) octetstring rand := ?,
384 template (present) octetstring ik := ?,
385 template (present) octetstring ck := ?,
386 template (present) octetstring autn := ?,
387 template (present) octetstring res := ?) := {
388 tag := OSMO_GSUP_AUTH_TUPLE_IE,
389 len := ?,
390 val := {
391 auth_tuple := {
392 tr_GSUP_IE_RAND(rand),
393 tr_GSUP_IE_IK(ik),
394 tr_GSUP_IE_CK(ck),
395 tr_GSUP_IE_AUTN(autn),
396 tr_GSUP_IE_RES(res)
397 }
398 }
399}
400
401template GSUP_IE ts_GSUP_IE_AuthTuple3G(octetstring rand, octetstring ik,
402 octetstring ck, octetstring autn,
403 octetstring res) := {
404 tag := OSMO_GSUP_AUTH_TUPLE_IE,
405 len := 0, /* overwritten */
406 val := {
407 auth_tuple := {
408 valueof(ts_GSUP_IE_RAND(rand)),
409 valueof(ts_GSUP_IE_IK(ik)),
410 valueof(ts_GSUP_IE_CK(ck)),
411 valueof(ts_GSUP_IE_AUTN(autn)),
412 valueof(ts_GSUP_IE_RES(res))
413 }
414 }
415}
416
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200417template GSUP_IE tr_GSUP_IE_AuthTuple2G3G(
418 template (present) octetstring rand := ?,
419 template (present) octetstring sres := ?,
420 template (present) octetstring kc := ?,
421 template (present) octetstring ik := ?,
422 template (present) octetstring ck := ?,
423 template (present) octetstring autn := ?,
424 template (present) octetstring res := ?) := {
425 tag := OSMO_GSUP_AUTH_TUPLE_IE,
426 len := ?,
427 val := {
428 auth_tuple := {
429 tr_GSUP_IE_RAND(rand),
430 tr_GSUP_IE_SRES(sres),
431 tr_GSUP_IE_Kc(kc),
432 tr_GSUP_IE_IK(ik),
433 tr_GSUP_IE_CK(ck),
434 tr_GSUP_IE_AUTN(autn),
435 tr_GSUP_IE_RES(res)
436 }
437 }
438}
439
Harald Welte77a8eba2018-01-22 21:22:32 +0100440template GSUP_IE ts_GSUP_IE_AuthTuple2G3G(octetstring rand, octetstring sres,
441 octetstring kc, octetstring ik,
442 octetstring ck, octetstring autn,
443 octetstring res) := {
444 tag := OSMO_GSUP_AUTH_TUPLE_IE,
445 len := 0, /* overwritten */
446 val := {
447 auth_tuple := {
448 valueof(ts_GSUP_IE_RAND(rand)),
449 valueof(ts_GSUP_IE_SRES(sres)),
450 valueof(ts_GSUP_IE_Kc(kc)),
451 valueof(ts_GSUP_IE_IK(ik)),
452 valueof(ts_GSUP_IE_CK(ck)),
453 valueof(ts_GSUP_IE_AUTN(autn)),
454 valueof(ts_GSUP_IE_RES(res))
455 }
456 }
457}
458
Harald Welteeded9ad2018-02-17 20:57:34 +0100459template GSUP_IE ts_GSUP_IE_PdpInfo(octetstring apn, octetstring pdp_type, octetstring pdp_qos) := {
460 tag := OSMO_GSUP_PDP_INFO_IE,
461 len := 0, /* overwritten */
462 val := {
463 pdp_info := {
464 valueof(ts_GSUP_IE_APN(apn)),
465 valueof(ts_GSUP_IE_PDP_TYPE(pdp_type)),
466 valueof(ts_GSUP_IE_PDP_QOS(pdp_qos))
467 }
468 }
469}
470
Alexander Couzens25d28492023-04-26 19:30:04 +0200471template (value) GSUP_IE ts_GSUP_IE_PDP_CONTEXT_ID(OCT1 ctx_id) := {
472 tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
473 len := 0,
474 val := {
475 pdp_ctx_id := ctx_id
476 }
477}
478
479template GSUP_IE tr_GSUP_IE_PDP_CONTEXT_ID(template OCT1 ctx_id) := {
480 tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
481 len := ?,
482 val := {
483 pdp_ctx_id := ctx_id
484 }
485}
486
487
Harald Welteeded9ad2018-02-17 20:57:34 +0100488template (value) GSUP_IE ts_GSUP_IE_PDP_TYPE(OCT2 pdp_type) := {
489 tag := OSMO_GSUP_PDP_TYPE_IE,
490 len := 0,
491 val := {
492 pdp_type := pdp_type
493 }
494}
495
496template (value) GSUP_IE ts_GSUP_IE_PDP_QOS(octetstring pdp_qos) := {
497 tag := OSMO_GSUP_PDP_QOS_IE,
498 len := 0,
499 val := {
500 pdp_qos := pdp_qos
501 }
502}
503
504
Harald Weltedf327232017-12-28 22:51:51 +0100505template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
506 msg_type := msgt,
507 ies := ies
508}
509
Pau Espin Pedrolafc186d2023-10-19 16:54:58 +0200510template (present) GSUP_PDU tr_GSUP_IMSI(template (present) GSUP_MessageType msgt := ?, template (present) hexstring imsi := ?) := {
Harald Welte8a1dd532018-01-27 15:38:18 +0100511 msg_type := msgt,
512 ies := { tr_GSUP_IE_IMSI(imsi), * }
513}
514
Harald Weltedf327232017-12-28 22:51:51 +0100515template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
516 msg_type := msgt,
517 ies := ies
518}
519
Oliver Smith936dbe62019-06-04 15:54:17 +0200520template (value) GSUP_IMEI ts_GSUP_IMEI(hexstring digits) := {
521 len := 0, /* overwritten */
522 digits := digits
523}
524
525template GSUP_IMEI tr_GSUP_IMEI(template hexstring digits) := {
526 len := ?,
527 digits := digits
528}
529
530
Harald Welte6aa04e32018-01-27 15:35:19 +0100531template (value) GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
Harald Weltedf327232017-12-28 22:51:51 +0100532 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
533
Harald Welte8eebb6c2019-08-22 12:40:03 +0200534template (value) GSUP_PDU ts_GSUP_SAI_REQ_EPS(hexstring imsi) :=
535 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
536 valueof(ts_GSUP_IE_IMSI(imsi)),
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100537 valueof(ts_GSUP_IE_CURRENT_RAT_TYPE(RAT_TYPE_EUTRAN_SGs))
Harald Welte8eebb6c2019-08-22 12:40:03 +0200538 });
539
Alexander Couzens752f86b2020-01-10 07:56:31 +0100540template (value) GSUP_PDU ts_GSUP_SAI_REQ_NUM_AUTH(hexstring imsi, OCT1 num_auth_vectors) :=
541 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
542 valueof(ts_GSUP_IE_IMSI(imsi)),
543 valueof(ts_GSUP_IE_NUM_VECTORS_REQ(num_auth_vectors))
544 });
545
Harald Welteef9fa872018-01-22 03:00:17 +0100546template GSUP_PDU tr_GSUP_SAI_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100547 tr_GSUP_IMSI(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, imsi);
Harald Welteef9fa872018-01-22 03:00:17 +0100548
Alexander Couzensd24973d2018-09-04 16:10:14 +0200549template GSUP_PDU tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC(
550 template hexstring imsi,
551 template octetstring auts,
552 template octetstring rand) :=
553 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
554 tr_GSUP_IE_IMSI(imsi),
555 tr_GSUP_IE_AUTS(auts),
556 tr_GSUP_IE_RAND(rand),
557 *
558 });
559
Harald Welte77a8eba2018-01-22 21:22:32 +0100560template (value) GSUP_PDU ts_GSUP_SAI_RES(hexstring imsi, GSUP_IE auth_tuple) :=
561 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
562 valueof(ts_GSUP_IE_IMSI(imsi)), auth_tuple });
563
Harald Weltedf327232017-12-28 22:51:51 +0100564template GSUP_PDU tr_GSUP_SAI_ERR(template hexstring imsi, template integer cause) :=
Harald Welte071ed732018-01-23 19:53:52 +0100565 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
Harald Weltedf327232017-12-28 22:51:51 +0100566 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
567
Harald Welte6aa04e32018-01-27 15:35:19 +0100568template (value) GSUP_PDU ts_GSUP_SAI_ERR(hexstring imsi, integer cause) :=
569 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
570 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
Harald Welte071ed732018-01-23 19:53:52 +0100571
572
Pau Espin Pedrol965ac642023-10-16 18:12:45 +0200573template GSUP_PDU tr_GSUP_SAI_RES(template (present) hexstring imsi,
574 template (present) GSUP_IE auth_tuple_ie := tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE)) :=
Harald Weltec2c52552018-03-01 21:20:39 +0100575 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
Pau Espin Pedrol965ac642023-10-16 18:12:45 +0200576 tr_GSUP_IE_IMSI(imsi), *, auth_tuple_ie, * });
Harald Weltedf327232017-12-28 22:51:51 +0100577
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100578template GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi, GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS,
579 template octetstring source_name := omit) :=
580 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, f_gen_ts_ies(imsi, dom := dom,
581 source_name := source_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100582
Harald Weltedfe94dd2018-01-21 13:55:22 +0100583template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100584 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, imsi);
Harald Weltedfe94dd2018-01-21 13:55:22 +0100585
Oliver Smith07786da2020-01-29 14:48:19 +0100586template (value) GSUP_PDU ts_GSUP_UL_RES(hexstring imsi, octetstring destination_name := ''O) :=
587 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)),
588 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
Harald Weltedfe94dd2018-01-21 13:55:22 +0100589
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100590template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi, template octetstring destination_name := omit) :=
591 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, f_gen_tr_ies(imsi, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100592
Harald Welte6aa04e32018-01-27 15:35:19 +0100593template (value) GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100594 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
595 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
596
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100597template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?,
598 template octetstring destination_name := omit) :=
599 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR,
600 f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100601
Oliver Smith07786da2020-01-29 14:48:19 +0100602template (value) GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn, octetstring destination_name := ''O) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100603 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
Oliver Smith07786da2020-01-29 14:48:19 +0100604 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)),
605 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
Harald Welte6ff81902018-01-21 19:09:08 +0100606
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100607template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?,
608 template octetstring destination_name := omit) :=
609 tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST,
610 f_gen_tr_ies(imsi, msisdn := msisdn, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100611
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100612template GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi,
613 template octetstring source_name := omit,
614 template octetstring destination_name := omit) :=
615 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT,
616 f_gen_ts_ies(imsi, source_name := source_name,
617 destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100618
Harald Welte6ff81902018-01-21 19:09:08 +0100619template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100620 tr_GSUP_IMSI(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100621
Harald Weltec638f4d2018-01-24 22:00:36 +0100622template GSUP_PDU tr_GSUP_AUTH_FAIL_IND(hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100623 tr_GSUP_IMSI(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100624
Harald Welte167458a2018-01-27 15:58:16 +0100625template (value) GSUP_PDU ts_GSUP_CL_REQ(hexstring imsi, GSUP_CancelType ctype) :=
626 ts_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST, {
627 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CancelType(ctype)) });
628
629template GSUP_PDU tr_GSUP_CL_RES(template hexstring imsi) :=
630 tr_GSUP_IMSI(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT, imsi);
631
632template GSUP_PDU tr_GSUP_CL_ERR(template hexstring imsi, template integer cause := ?) :=
633 tr_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR, {
Alexander Couzens4cfff3a2018-05-22 17:08:36 +0200634 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause), * });
Harald Welte167458a2018-01-27 15:58:16 +0100635
Harald Welte958f8b42018-03-01 23:40:17 +0100636template (value) GSUP_PDU ts_GSUP_PURGE_MS_REQ(hexstring imsi, GSUP_CnDomain dom) :=
637 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
638 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CnDomain(dom)) });
639
Harald Welte6abb9fe2018-02-17 15:24:48 +0100640template GSUP_PDU tr_GSUP_PURGE_MS_REQ(template hexstring imsi, template GSUP_CnDomain dom := ?) :=
641 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
642 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_CnDomain(dom) });
643
644template (value) GSUP_PDU ts_GSUP_PURGE_MS_RES(hexstring imsi) :=
645 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
646 valueof(ts_GSUP_IE_IMSI(imsi)) });
647
Harald Welte958f8b42018-03-01 23:40:17 +0100648template GSUP_PDU tr_GSUP_PURGE_MS_RES(template hexstring imsi) :=
649 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
650 tr_GSUP_IE_IMSI(imsi), * });
651
652template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer cause) :=
653 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
654 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
655
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100656template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei,
657 template (omit) octetstring source_name := omit) :=
658 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST, f_gen_ts_ies(imsi, imei := imei, source_name := source_name));
Oliver Smith936dbe62019-06-04 15:54:17 +0200659
Oliver Smith1d118ff2019-07-03 10:57:35 +0200660template GSUP_PDU tr_GSUP_CHECK_IMEI_REQ(
661 template hexstring imsi,
662 template hexstring imei
663) := tr_GSUP(
664 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST,
665 {
666 tr_GSUP_IE_IMSI(imsi),
667 tr_GSUP_IE_IMEI(imei),
668 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT)
669 }
670);
671
672template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_RES(hexstring imsi, GSUP_IMEIResult result) :=
673 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
674 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI_Result(result)) });
675
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100676template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result,
677 template octetstring destination_name := omit) :=
678 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT,
679 f_gen_tr_ies(imsi, imei_result := result, destination_name := destination_name));
Oliver Smith936dbe62019-06-04 15:54:17 +0200680
Oliver Smith1d118ff2019-07-03 10:57:35 +0200681template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_ERR(hexstring imsi, integer cause) :=
682 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
683 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
684
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100685template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause,
686 template octetstring destination_name := omit) :=
687 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name));
Oliver Smith936dbe62019-06-04 15:54:17 +0200688
Harald Welte167458a2018-01-27 15:58:16 +0100689
690template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
691 tag := OSMO_GSUP_CANCEL_TYPE_IE,
692 len := 0, /* overwritten */
693 val := {
694 cancel_type := ctype
695 }
696}
697
698template GSUP_IE tr_GSUP_IE_CancelType(template GSUP_CancelType ctype) :=
699 tr_GSUP_IE(OSMO_GSUP_CANCEL_TYPE_IE, GSUP_IeValue:{cancel_type:=ctype});
700
Harald Welte6abb9fe2018-02-17 15:24:48 +0100701template GSUP_IE tr_GSUP_IE_CnDomain(template GSUP_CnDomain domain) :=
702 tr_GSUP_IE(OSMO_GSUP_CN_DOMAIN_IE, GSUP_IeValue:{cn_domain:=domain});
703
Harald Weltedf327232017-12-28 22:51:51 +0100704template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := {
705 tag := iei,
706 len := ?,
707 val := val
708}
709
710template (value) GSUP_IE ts_GSUP_IE_IMSI(hexstring imsi) := {
711 tag := OSMO_GSUP_IMSI_IE,
712 len := 0, /* overwritten */
713 val := {
714 imsi := imsi
715 }
716}
717
Pau Espin Pedrolafc186d2023-10-19 16:54:58 +0200718template (present) GSUP_IE tr_GSUP_IE_IMSI(template (present) hexstring imsi := ?) := {
Harald Weltedf327232017-12-28 22:51:51 +0100719 tag := OSMO_GSUP_IMSI_IE,
720 len := ?,
721 val := {
722 imsi := imsi
723 }
724}
725
Harald Welte6ff81902018-01-21 19:09:08 +0100726template (value) GSUP_IE ts_GSUP_IE_MSISDN(hexstring msisdn) := {
727 tag := OSMO_GSUP_MSISDN_IE,
728 len := 0, /* overwritten */
729 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100730 msisdn := ts_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100731 }
732}
733
734template GSUP_IE tr_GSUP_IE_MSISDN(template hexstring msisdn) := {
735 tag := OSMO_GSUP_MSISDN_IE,
736 len := ?,
737 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100738 msisdn := tr_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100739 }
740}
741
742
Harald Weltedf327232017-12-28 22:51:51 +0100743template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := {
744 tag := OSMO_GSUP_CAUSE_IE,
745 len := 0, /* overwritten */
746 val := {
747 cause := cause
748 }
749}
750
751template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := {
752 tag := OSMO_GSUP_CAUSE_IE,
753 len := ?,
754 val := {
755 cause := cause
756 }
757}
758
759template (value) GSUP_IE ts_GSUP_IE_AUTS(octetstring auts) := {
760 tag := OSMO_GSUP_AUTS_IE,
761 len := 0, /* overwritten */
762 val := {
763 auts := auts
764 }
765}
766
Alexander Couzensd24973d2018-09-04 16:10:14 +0200767template GSUP_IE tr_GSUP_IE_AUTS(template octetstring auts) := {
768 tag := OSMO_GSUP_AUTS_IE,
769 len := ?,
770 val := {
771 auts := auts
772 }
773}
774
Harald Weltedf327232017-12-28 22:51:51 +0100775template (value) GSUP_IE ts_GSUP_IE_RAND(octetstring rand) := {
776 tag := OSMO_GSUP_RAND_IE,
777 len := 0, /* overwritten */
778 val := {
779 rand := rand
780 }
781}
782
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200783template GSUP_IE tr_GSUP_IE_RAND(template octetstring rand := ?) := {
Alexander Couzensd24973d2018-09-04 16:10:14 +0200784 tag := OSMO_GSUP_RAND_IE,
785 len := ?,
786 val := {
787 rand := rand
788 }
789}
790
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200791template (present) GSUP_IE tr_GSUP_IE_SRES(template (present) octetstring sres := ?) := {
792 tag := OSMO_GSUP_SRES_IE,
793 len := ?,
794 val := {
795 sres := sres
796 }
797}
798
Harald Welte77a8eba2018-01-22 21:22:32 +0100799template (value) GSUP_IE ts_GSUP_IE_SRES(octetstring sres) := {
800 tag := OSMO_GSUP_SRES_IE,
801 len := 0, /* overwritten */
802 val := {
803 sres := sres
804 }
805}
806
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200807template (present) GSUP_IE tr_GSUP_IE_Kc(template (present) octetstring kc := ?) := {
808 tag := OSMO_GSUP_KC_IE,
809 len := ?,
810 val := {
811 kc := kc
812 }
813}
814
Harald Welte77a8eba2018-01-22 21:22:32 +0100815template (value) GSUP_IE ts_GSUP_IE_Kc(octetstring kc) := {
816 tag := OSMO_GSUP_KC_IE,
817 len := 0, /* overwritten */
818 val := {
819 kc := kc
820 }
821}
822
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200823template (present) GSUP_IE tr_GSUP_IE_IK(template (present) octetstring ik := ?) := {
824 tag := OSMO_GSUP_IK_IE,
825 len := ?,
826 val := {
827 ik := ik
828 }
829}
830
Harald Welte77a8eba2018-01-22 21:22:32 +0100831template (value) GSUP_IE ts_GSUP_IE_IK(octetstring ik) := {
832 tag := OSMO_GSUP_IK_IE,
833 len := 0, /* overwritten */
834 val := {
835 ik := ik
836 }
837}
838
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200839template (present) GSUP_IE tr_GSUP_IE_CK(template (present) octetstring ck := ?) := {
840 tag := OSMO_GSUP_CK_IE,
841 len := ?,
842 val := {
843 ck := ck
844 }
845}
846
Harald Welte77a8eba2018-01-22 21:22:32 +0100847template (value) GSUP_IE ts_GSUP_IE_CK(octetstring ck) := {
848 tag := OSMO_GSUP_CK_IE,
849 len := 0, /* overwritten */
850 val := {
851 ck := ck
852 }
853}
854
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200855template (present) GSUP_IE tr_GSUP_IE_AUTN(template (present) octetstring autn := ?) := {
856 tag := OSMO_GSUP_AUTN_IE,
857 len := ?,
858 val := {
859 autn := autn
860 }
861}
862
Harald Welte77a8eba2018-01-22 21:22:32 +0100863template (value) GSUP_IE ts_GSUP_IE_AUTN(octetstring autn) := {
864 tag := OSMO_GSUP_AUTN_IE,
865 len := 0, /* overwritten */
866 val := {
867 autn := autn
868 }
869}
870
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200871template (present) GSUP_IE tr_GSUP_IE_RES(template (present) octetstring res := ?) := {
872 tag := OSMO_GSUP_RES_IE,
873 len := ?,
874 val := {
875 res := res
876 }
877}
878
Harald Welte77a8eba2018-01-22 21:22:32 +0100879template (value) GSUP_IE ts_GSUP_IE_RES(octetstring res) := {
880 tag := OSMO_GSUP_RES_IE,
881 len := 0, /* overwritten */
882 val := {
883 res := res
884 }
885}
Harald Weltedf327232017-12-28 22:51:51 +0100886
Harald Welteeded9ad2018-02-17 20:57:34 +0100887template (value) GSUP_IE ts_GSUP_IE_APN(octetstring apn) := {
888 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
889 len := 0, /* overwritten */
890 val := {
891 apn := apn
892 }
893}
894
Alexander Couzens25d28492023-04-26 19:30:04 +0200895template GSUP_IE tr_GSUP_IE_APN(template octetstring apn) := {
896 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
897 len := ?,
898 val := {
899 apn := apn
900 }
901}
902
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100903template GSUP_IE ts_GSUP_IE_CnDomain(template GSUP_CnDomain dom) := {
Harald Welte958f8b42018-03-01 23:40:17 +0100904 tag := OSMO_GSUP_CN_DOMAIN_IE,
905 len := 0, /* overwritten */
906 val := {
907 cn_domain := dom
908 }
909}
Harald Weltedf327232017-12-28 22:51:51 +0100910
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700911template (value) GSUP_IE ts_GSUP_IE_SessionId(OCT4 sid) := {
912 tag := OSMO_GSUP_SESSION_ID_IE,
913 len := 0, /* overwritten */
914 val := {
915 session_id := sid
916 }
917}
918template GSUP_IE tr_GSUP_IE_SessionId(template OCT4 sid) := {
919 tag := OSMO_GSUP_SESSION_ID_IE,
920 len := ?,
921 val := {
922 session_id := sid
923 }
924}
925
926template (value) GSUP_IE ts_GSUP_IE_SessionState(GSUP_SessionState state) := {
927 tag := OSMO_GSUP_SESSION_STATE_IE,
928 len := 0, /* overwritten */
929 val := {
930 session_state := state
931 }
932}
933template GSUP_IE tr_GSUP_IE_SessionState(template GSUP_SessionState state) := {
934 tag := OSMO_GSUP_SESSION_STATE_IE,
935 len := ?,
936 val := {
937 session_state := state
938 }
939}
940
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700941template (value) GSUP_IE ts_GSUP_IE_SM_RP_MR(OCT1 ref) := {
942 tag := OSMO_GSUP_SM_RP_MR_IE,
943 len := 0, /* overwritten */
944 val := {
945 sm_rp_mr := ref
946 }
947}
948template GSUP_IE tr_GSUP_IE_SM_RP_MR(template OCT1 ref) := {
949 tag := OSMO_GSUP_SM_RP_MR_IE,
950 len := ?,
951 val := {
952 sm_rp_mr := ref
953 }
954}
955
956template (value) GSUP_IE ts_GSUP_IE_SM_RP_CAUSE(OCT1 cause) := {
957 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
958 len := 0, /* overwritten */
959 val := {
960 sm_rp_cause := cause
961 }
962}
963template GSUP_IE tr_GSUP_IE_SM_RP_CAUSE(template OCT1 cause) := {
964 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
965 len := ?,
966 val := {
967 sm_rp_cause := cause
968 }
969}
970
971template (value) GSUP_IE ts_GSUP_IE_SM_RP_MMS(OCT1 mms) := {
972 tag := OSMO_GSUP_SM_RP_MMS_IE,
973 len := 0, /* overwritten */
974 val := {
975 sm_rp_mms := mms
976 }
977}
978template GSUP_IE tr_GSUP_IE_SM_RP_MMS(template OCT1 mms) := {
979 tag := OSMO_GSUP_SM_RP_MMS_IE,
980 len := ?,
981 val := {
982 sm_rp_mms := mms
983 }
984}
985
Oliver Smith936dbe62019-06-04 15:54:17 +0200986template (value) GSUP_IE ts_GSUP_IE_IMEI(hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100987 tag := OSMO_GSUP_IMEI_IE,
988 len := 0, /* overwritten */
989 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +0200990 imei := ts_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +0100991 }
992}
Oliver Smith936dbe62019-06-04 15:54:17 +0200993template GSUP_IE tr_GSUP_IE_IMEI(template hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100994 tag := OSMO_GSUP_IMEI_IE,
995 len := ?,
996 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +0200997 imei := tr_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +0100998 }
999}
1000
Oliver Smith936dbe62019-06-04 15:54:17 +02001001template (value) GSUP_IE ts_GSUP_IE_IMEI_Result(GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +01001002 tag := OSMO_GSUP_IMEI_RESULT_IE,
1003 len := 0, /* overwritten */
1004 val := {
1005 imei_result := result
1006 }
1007}
Oliver Smith936dbe62019-06-04 15:54:17 +02001008template GSUP_IE tr_GSUP_IE_IMEI_Result(template GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +01001009 tag := OSMO_GSUP_IMEI_RESULT_IE,
1010 len := ?,
1011 val := {
1012 imei_result := result
1013 }
1014}
1015
Alexander Couzens752f86b2020-01-10 07:56:31 +01001016template (value) GSUP_IE ts_GSUP_IE_NUM_VECTORS_REQ(OCT1 num) := {
1017 tag := OSMO_GSUP_NUM_VECTORS_REQ_IE,
1018 len := 0, /* overwritten */
1019 val := {
1020 num_auth_vectors := num
1021 }
1022}
1023template GSUP_IE tr_GSUP_IE_NUM_VECTORS_REQ(template OCT1 num) := {
1024 tag := OSMO_GSUP_NUM_VECTORS_REQ_IE,
1025 len := ?,
1026 val := {
1027 num_auth_vectors := num
1028 }
1029}
1030
1031
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001032/* Possible identity types for SM-RP-{OA|DA} IEs */
1033type enumerated GSUP_SM_RP_ODA_IdType {
1034 OSMO_GSUP_SM_RP_ODA_ID_NONE ('00'O),
1035 OSMO_GSUP_SM_RP_ODA_ID_IMSI ('01'O),
1036 OSMO_GSUP_SM_RP_ODA_ID_MSISDN ('02'O),
1037 OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR ('03'O),
1038 /* Special value for noSM-RP-DA and noSM-RP-OA */
1039 OSMO_GSUP_SM_RP_ODA_ID_NULL ('FF'O)
1040} with { variant "FIELDLENGTH(8)" };
1041
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001042/* See 3GPP TS 24.011, figures 8.5 and 8.6 */
1043type record GSUP_SM_RP_Addr {
1044 BIT1 ext, /* Extension? */
1045 BIT3 ton, /* Type of Number */
1046 BIT4 npi, /* Numbering Plan Identification */
1047 hexstring number length (1..20)
1048} with {
1049 variant "PADDING(yes)";
1050 variant "PADDING_PATTERN('1111'B)"
1051};
1052
1053private function f_pad_SM_RP_Addr(template hexstring number)
1054return template hexstring {
1055 if (isvalue(number) and not istemplatekind(number, "omit")) {
1056 return f_pad_bcd_number(valueof(number));
1057 } else {
1058 return number;
1059 }
1060}
1061
1062template GSUP_SM_RP_Addr t_GSUP_SM_RP_Addr(template hexstring number,
1063 template BIT4 npi := '0001'B,
1064 template BIT3 ton := '001'B,
1065 template BIT1 ext := '1'B) := {
1066 ext := ext,
1067 ton := ton,
1068 npi := npi,
1069 /* Work around TITAN's padding problems: encoding works fine,
1070 * but it does not consider 'F'H as padding in decoded data. */
1071 number := f_pad_SM_RP_Addr(number)
1072}
1073
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001074/**
1075 * SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
1076 * It can be either of the following:
1077 * - IMSI
1078 * - LMSI (not implemented)
1079 * - MSISDN
1080 * - roaming number (not implemented)
1081 * - service centre address
1082 */
1083type union GSUP_SM_RP_DA_ID {
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001084 hexstring imsi,
1085 GSUP_SM_RP_Addr msisdn,
1086 GSUP_SM_RP_Addr smsc_addr
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001087};
1088
1089type record GSUP_SM_RP_DA {
1090 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001091 GSUP_SM_RP_DA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +07001092} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001093 imsi, id_type = OSMO_GSUP_SM_RP_ODA_ID_IMSI;
1094 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
1095 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
1096 /* FIXME: how to handle noSM-RP-DA? */
1097 )"
1098};
1099
1100template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_IMSI(hexstring imsi) := {
1101 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001102 id_enc := { imsi := imsi }
1103}
1104template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_IMSI(template hexstring imsi) := {
1105 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001106 id_enc := { imsi := imsi }
1107}
1108
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001109template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001110 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001111 id_enc := { msisdn := msisdn }
1112}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001113template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001114 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001115 id_enc := { msisdn := msisdn }
1116}
1117
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001118template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(GSUP_SM_RP_Addr smsc_addr) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001119 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001120 id_enc := { smsc_addr := smsc_addr }
1121}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001122template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template GSUP_SM_RP_Addr smsc_addr) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001123 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001124 id_enc := { smsc_addr := smsc_addr }
1125}
1126
1127template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_NULL := {
1128 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001129 id_enc := omit
1130}
1131template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_NULL := {
1132 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001133 id_enc := omit
1134}
1135
1136template (value) GSUP_IE ts_GSUP_IE_SM_RP_DA(GSUP_SM_RP_DA val) := {
1137 tag := OSMO_GSUP_SM_RP_DA_IE,
1138 len := 0, /* overwritten */
1139 val := {
1140 sm_rp_da := val
1141 }
1142}
1143template GSUP_IE tr_GSUP_IE_SM_RP_DA(template GSUP_SM_RP_DA val) := {
1144 tag := OSMO_GSUP_SM_RP_DA_IE,
1145 len := ?,
1146 val := {
1147 sm_rp_da := val
1148 }
1149}
1150
1151/**
1152 * SM-RP-OA represents the SM Originating Address, see 7.6.8.2.
1153 * It can be either of the following:
1154 * - MSISDN
1155 * - service centre address
1156 */
1157type union GSUP_SM_RP_OA_ID {
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001158 GSUP_SM_RP_Addr msisdn,
1159 GSUP_SM_RP_Addr smsc_addr
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001160};
1161
1162type record GSUP_SM_RP_OA {
1163 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001164 GSUP_SM_RP_OA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +07001165} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001166 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
1167 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
1168 /* FIXME: how to handle noSM-RP-OA? */
1169 )"
1170};
1171
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001172template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001173 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001174 id_enc := { msisdn := msisdn }
1175}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001176template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001177 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001178 id_enc := { msisdn := msisdn }
1179}
1180
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001181template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(GSUP_SM_RP_Addr smsc_addr) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001182 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001183 id_enc := { smsc_addr := smsc_addr }
1184}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001185template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template GSUP_SM_RP_Addr smsc_addr) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001186 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001187 id_enc := { smsc_addr := smsc_addr }
1188}
1189
1190template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_NULL := {
1191 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001192 id_enc := omit
1193}
1194template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_NULL := {
1195 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001196 id_enc := omit
1197}
1198
1199template (value) GSUP_IE ts_GSUP_IE_SM_RP_OA(GSUP_SM_RP_OA val) := {
1200 tag := OSMO_GSUP_SM_RP_OA_IE,
1201 len := 0, /* overwritten */
1202 val := {
1203 sm_rp_oa := val
1204 }
1205}
1206template GSUP_IE tr_GSUP_IE_SM_RP_OA(template GSUP_SM_RP_OA val) := {
1207 tag := OSMO_GSUP_SM_RP_OA_IE,
1208 len := ?,
1209 val := {
1210 sm_rp_oa := val
1211 }
1212}
1213
1214/* SM-RP-UI represents the SM TPDU, see 7.6.8.4 */
1215template (value) GSUP_IE ts_GSUP_IE_SM_RP_UI(octetstring val) := {
1216 tag := OSMO_GSUP_SM_RP_UI_IE,
1217 len := 0, /* overwritten */
1218 val := {
1219 sm_rp_ui := val
1220 }
1221}
1222template GSUP_IE tr_GSUP_IE_SM_RP_UI(template octetstring val) := {
1223 tag := OSMO_GSUP_SM_RP_UI_IE,
1224 len := ?,
1225 val := {
1226 sm_rp_ui := val
1227 }
1228}
1229
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001230/* SM Alert Reason types, see 7.6.8.8 */
1231type enumerated GSUP_SM_ALERT_RSN_Type {
1232 GSUP_SM_ALERT_RSN_TYPE_NONE ('00'O),
1233 GSUP_SM_ALERT_RSN_TYPE_MS_PRESENT ('01'O),
1234 GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL ('02'O)
1235} with { variant "FIELDLENGTH(8)" };
1236
1237/* SM Alert Reason IE (used in READY-FOR-SM), see 7.6.8.8 */
1238template (value) GSUP_IE ts_GSUP_IE_SM_ALERT_RSN(GSUP_SM_ALERT_RSN_Type rsn) := {
1239 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1240 len := 0, /* overwritten */
1241 val := {
1242 sm_alert_rsn := rsn
1243 }
1244}
1245template GSUP_IE tr_GSUP_IE_SM_ALERT_RSN(template GSUP_SM_ALERT_RSN_Type rsn) := {
1246 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1247 len := ?,
1248 val := {
1249 sm_alert_rsn := rsn
1250 }
1251}
1252
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001253template (value) GSUP_IE ts_GSUP_IE_SSInfo(octetstring ss) := {
1254 tag := OSMO_GSUP_SS_INFO_IE,
1255 len := 0, /* overwritten */
1256 val := {
1257 ss_info := ss
1258 }
1259}
1260template GSUP_IE tr_GSUP_IE_SSInfo(template octetstring ss) := {
1261 tag := OSMO_GSUP_SS_INFO_IE,
1262 len := ?,
1263 val := {
1264 ss_info := ss
1265 }
1266}
1267
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001268template GSUP_IE tr_GSUP_IE_Message_Class(template GSUP_Message_Class val) := {
1269 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1270 len := ?,
1271 val := {
1272 message_class := val
1273 }
1274}
1275
1276template (value) GSUP_IE ts_GSUP_IE_Message_Class(GSUP_Message_Class val) := {
1277 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1278 len := 0, /* overwritten */
1279 val := {
1280 message_class := val
1281 }
1282}
1283
1284template GSUP_IE tr_GSUP_IE_Source_Name(template octetstring name) := {
1285 tag := OSMO_GSUP_SOURCE_NAME_IE,
1286 len := ?,
1287 val := {
1288 source_name := name
1289 }
1290}
1291
1292template (value) GSUP_IE ts_GSUP_IE_Source_Name(octetstring name) := {
1293 tag := OSMO_GSUP_SOURCE_NAME_IE,
1294 len := 0, /* overwritten */
1295 val := {
1296 source_name := name
1297 }
1298}
1299
1300template GSUP_IE tr_GSUP_IE_Destination_Name(template octetstring name) := {
1301 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1302 len := ?,
1303 val := {
1304 destination_name := name
1305 }
1306}
1307
1308template (value) GSUP_IE ts_GSUP_IE_Destination_Name(octetstring name) := {
1309 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1310 len := 0, /* overwritten */
1311 val := {
1312 destination_name := name
1313 }
1314}
1315
1316template GSUP_IE tr_GSUP_IE_AN_APDU(template GSUP_AN_APDU an_apdu) := {
1317 tag := OSMO_GSUP_AN_APDU_IE,
1318 len := ?,
1319 val := {
1320 an_apdu := an_apdu
1321 }
1322}
1323
1324template (value) GSUP_IE ts_GSUP_IE_AN_APDU(GSUP_AN_APDU an_apdu) := {
1325 tag := OSMO_GSUP_AN_APDU_IE,
1326 len := 0, /* overwritten */
1327 val := {
1328 an_apdu := an_apdu
1329 }
1330}
1331
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001332template (present) GSUP_IE tr_GSUP_IE_SUPPORTED_RAT_TYPES(template (present) GSUP_RatTypes ratt) := {
1333 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
Harald Welte8eebb6c2019-08-22 12:40:03 +02001334 len := ?,
1335 val := {
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001336 supported_rat_types := ratt
Harald Welte8eebb6c2019-08-22 12:40:03 +02001337 }
1338}
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001339template (value) GSUP_IE ts_GSUP_IE_SUPPORTED_RAT_TYPES(GSUP_RatTypes ratt) := {
1340 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
Harald Welte8eebb6c2019-08-22 12:40:03 +02001341 len := 0, /* overwritten */
1342 val := {
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001343 supported_rat_types := ratt
1344 }
1345}
1346
1347template (present) GSUP_IE tr_GSUP_IE_CURRENT_RAT_TYPE(template (present) GSUP_RatType ratt) := {
1348 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1349 len := ?,
1350 val := {
1351 current_rat_type := ratt
1352 }
1353}
1354template (value) GSUP_IE ts_GSUP_IE_CURRENT_RAT_TYPE(GSUP_RatType ratt) := {
1355 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1356 len := 0, /* overwritten */
1357 val := {
1358 current_rat_type := ratt
Harald Welte8eebb6c2019-08-22 12:40:03 +02001359 }
1360}
1361
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001362private function f_gen_ts_ies(hexstring imsi,
1363 template hexstring imei := omit,
1364 template GSUP_CnDomain dom := omit,
1365 template octetstring source_name := omit,
1366 template octetstring destination_name := omit
1367 ) return GSUP_IEs {
1368 var GSUP_IEs ies := {
1369 valueof(ts_GSUP_IE_IMSI(imsi))
1370 };
1371
1372 if (isvalue(dom)) {
1373 ies := ies & { valueof(ts_GSUP_IE_CnDomain(dom)) };
1374 }
1375
1376 if (isvalue(imei)) {
1377 ies := ies & { valueof(ts_GSUP_IE_IMEI(valueof(imei))) };
1378 }
1379
1380 if (isvalue(source_name)) {
1381 ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) };
1382 }
1383
1384 if (isvalue(destination_name)) {
1385 ies := ies & { valueof(ts_GSUP_IE_Destination_Name(valueof(destination_name))) };
1386 }
1387
1388 return ies;
1389}
1390
1391private function f_gen_tr_ies(template hexstring imsi,
1392 template integer cause := omit,
1393 template hexstring msisdn := omit,
1394 template GSUP_IMEIResult imei_result := omit,
1395 template octetstring source_name := omit,
1396 template octetstring destination_name := omit
1397 ) return template GSUP_IEs {
1398 var template GSUP_IEs ies := {
1399 tr_GSUP_IE_IMSI(imsi)
1400 };
1401 var integer idx := 1;
1402
1403 if (isvalue(cause)) {
1404 ies[idx] := tr_GSUP_IE_Cause(cause);
1405 idx := idx + 1;
1406 }
1407
1408 if (isvalue(msisdn)) {
1409 ies[idx] := tr_GSUP_IE_MSISDN(msisdn);
1410 idx := idx + 1;
1411 }
1412
1413 if (isvalue(imei_result)) {
1414 ies[idx] := tr_GSUP_IE_IMEI_Result(imei_result);
1415 idx := idx + 1;
1416 }
1417
1418 if (isvalue(source_name)) {
1419 ies[idx] := tr_GSUP_IE_Source_Name(source_name);
1420 idx := idx + 1;
1421 }
1422
1423 ies[idx] := *;
1424 idx := idx + 1;
1425
1426 if (isvalue(destination_name)) {
1427 ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
1428 idx := idx + 1;
1429 }
1430
1431 return ies;
1432}
Harald Welte8eebb6c2019-08-22 12:40:03 +02001433
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001434private function f_gen_ts_ss_ies(
1435 hexstring imsi,
1436 OCT4 sid,
1437 GSUP_SessionState state,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001438 template (omit) octetstring ss := omit,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001439 template (omit) integer cause := omit,
1440 template octetstring source_name := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001441) return GSUP_IEs {
1442 /* Mandatory IEs */
1443 var GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001444 valueof(ts_GSUP_IE_IMSI(imsi))
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001445 };
1446
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001447 /* Cause IE is needed for PROC_SS_ERR */
1448 if (isvalue(cause)) {
1449 ies := ies & { valueof(ts_GSUP_IE_Cause(valueof(cause))) };
1450 }
1451
1452 /* Mandatory session IEs */
1453 ies := ies & { valueof(ts_GSUP_IE_SessionId(sid)) };
1454 ies := ies & { valueof(ts_GSUP_IE_SessionState(state)) };
1455
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001456 /* Optional SS payload */
1457 if (isvalue(ss)) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001458 ies := ies & { valueof(ts_GSUP_IE_SSInfo(valueof(ss))) };
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001459 }
1460
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001461 if (isvalue(source_name)) {
1462 ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) };
1463 }
1464
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001465 return ies;
1466}
1467private function f_gen_tr_ss_ies(
1468 template hexstring imsi,
1469 template OCT4 sid := ?,
1470 template GSUP_SessionState state := ?,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001471 template octetstring ss := omit,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001472 template integer cause := omit,
1473 template octetstring destination_name := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001474) return template GSUP_IEs {
1475 /* Mandatory IEs */
1476 var template GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001477 tr_GSUP_IE_IMSI(imsi)
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001478 };
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001479 var integer idx := 1;
1480
1481 /* Cause IE is needed for PROC_SS_ERR */
1482 if (istemplatekind(cause, "*")) {
1483 ies[idx] := *;
1484 idx := idx + 1;
1485 } else if (not istemplatekind(cause, "omit")) {
1486 ies[idx] := tr_GSUP_IE_Cause(cause);
1487 idx := idx + 1;
1488 }
1489
1490 /* Mandatory session IEs */
1491 ies[idx] := tr_GSUP_IE_SessionId(sid);
1492 ies[idx + 1] := tr_GSUP_IE_SessionState(state);
1493 idx := idx + 2;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001494
1495 /* Optional SS payload */
1496 if (istemplatekind(ss, "*")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001497 ies[idx] := *;
1498 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001499 } else if (not istemplatekind(ss, "omit")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001500 ies[idx] := tr_GSUP_IE_SSInfo(ss);
1501 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001502 }
1503
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001504 if (isvalue(destination_name)) {
1505 ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
1506 idx := idx + 1;
1507 }
1508
Harald Welte0622a9f2019-05-11 10:58:15 +02001509 /* the GSUP Message Class IE is optional, as old implementations don't have it yet */
1510 var template GSUP_IEs ies2 := ies;
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001511 ies2[idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD);
1512 idx := idx + 1;
Harald Welte0622a9f2019-05-11 10:58:15 +02001513
1514 return (ies, ies2);
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001515}
1516
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001517template (value) GSUP_PDU ts_GSUP_PROC_SS_REQ(
1518 hexstring imsi,
1519 OCT4 sid,
1520 GSUP_SessionState state,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001521 template (omit) octetstring ss := omit,
1522 template (omit) octetstring source_name := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001523) := ts_GSUP(
1524 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001525 f_gen_ts_ss_ies(imsi, sid, state, ss, source_name := source_name)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001526);
1527template GSUP_PDU tr_GSUP_PROC_SS_REQ(
1528 template hexstring imsi,
1529 template OCT4 sid := ?,
1530 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001531 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001532) := tr_GSUP(
1533 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001534 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001535);
1536
1537template (value) GSUP_PDU ts_GSUP_PROC_SS_RES(
1538 hexstring imsi,
1539 OCT4 sid,
1540 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001541 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001542) := ts_GSUP(
1543 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001544 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001545);
1546template GSUP_PDU tr_GSUP_PROC_SS_RES(
1547 template hexstring imsi,
1548 template OCT4 sid := ?,
1549 template GSUP_SessionState state := ?,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001550 template octetstring ss := *,
1551 template octetstring destination_name := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001552) := tr_GSUP(
1553 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001554 f_gen_tr_ss_ies(imsi, sid, state, ss, destination_name := destination_name)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001555);
1556
1557template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR(
1558 hexstring imsi,
1559 OCT4 sid,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001560 GSUP_SessionState state,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001561 integer cause
1562) := ts_GSUP(
1563 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001564 f_gen_ts_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001565);
1566template GSUP_PDU tr_GSUP_PROC_SS_ERR(
1567 template hexstring imsi,
1568 template OCT4 sid := ?,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001569 template GSUP_SessionState state := ?,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001570 template integer cause := ?
1571) := tr_GSUP(
1572 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001573 f_gen_tr_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001574);
Harald Weltedf327232017-12-28 22:51:51 +01001575
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001576template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_REQ(
1577 hexstring imsi,
1578 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1579 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1580 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1581 octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1582) := ts_GSUP(
1583 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1584 {
1585 valueof(ts_GSUP_IE_IMSI(imsi)),
1586 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1587 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1588 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1589 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui))
1590 }
1591);
1592template GSUP_PDU tr_GSUP_MO_FORWARD_SM_REQ(
1593 template hexstring imsi := ?,
1594 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1595 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1596 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1597 template octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1598) := tr_GSUP(
1599 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1600 {
1601 tr_GSUP_IE_IMSI(imsi),
1602 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1603 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1604 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001605 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
1606 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001607 }
1608);
1609
1610template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_RES(
1611 hexstring imsi,
1612 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1613) := ts_GSUP(
1614 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1615 {
1616 valueof(ts_GSUP_IE_IMSI(imsi)),
1617 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1618 }
1619);
1620template GSUP_PDU tr_GSUP_MO_FORWARD_SM_RES(
1621 template hexstring imsi := ?,
1622 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1623) := tr_GSUP(
1624 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1625 {
1626 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001627 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1628 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001629 }
1630);
1631
1632template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_ERR(
1633 hexstring imsi,
1634 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1635 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1636) := ts_GSUP(
1637 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1638 {
1639 valueof(ts_GSUP_IE_IMSI(imsi)),
1640 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1641 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1642 }
1643);
1644template GSUP_PDU tr_GSUP_MO_FORWARD_SM_ERR(
1645 template hexstring imsi := ?,
1646 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1647 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1648) := tr_GSUP(
1649 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1650 {
1651 tr_GSUP_IE_IMSI(imsi),
1652 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001653 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1654 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001655 }
1656);
1657
1658template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_REQ(
1659 hexstring imsi,
1660 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1661 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1662 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1663 octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1664 OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1665) := ts_GSUP(
1666 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1667 {
1668 /**
1669 * TODO: add MT-specific fields (and IEs):
1670 * - smDeliveryTimer
1671 * - smDeliveryStartTime
1672 */
1673 valueof(ts_GSUP_IE_IMSI(imsi)),
1674 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1675 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1676 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1677 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
1678 valueof(ts_GSUP_IE_SM_RP_MMS(sm_rp_mms))
1679 }
1680);
1681template GSUP_PDU tr_GSUP_MT_FORWARD_SM_REQ(
1682 template hexstring imsi := ?,
1683 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1684 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1685 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1686 template octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1687 template OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1688) := tr_GSUP(
1689 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1690 {
1691 /**
1692 * TODO: add MT-specific fields (and IEs):
1693 * - smDeliveryTimer
1694 * - smDeliveryStartTime
1695 */
1696 tr_GSUP_IE_IMSI(imsi),
1697 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1698 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1699 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1700 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001701 tr_GSUP_IE_SM_RP_MMS(sm_rp_mms),
1702 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001703 }
1704);
1705
1706template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_RES(
1707 hexstring imsi,
1708 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1709) := ts_GSUP(
1710 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1711 {
1712 valueof(ts_GSUP_IE_IMSI(imsi)),
1713 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1714 }
1715);
1716template GSUP_PDU tr_GSUP_MT_FORWARD_SM_RES(
1717 template hexstring imsi := ?,
1718 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1719) := tr_GSUP(
1720 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1721 {
1722 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001723 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1724 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001725 }
1726);
1727
1728template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_ERR(
1729 hexstring imsi,
1730 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1731 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1732) := ts_GSUP(
1733 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1734 {
1735 valueof(ts_GSUP_IE_IMSI(imsi)),
1736 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1737 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1738 }
1739);
1740template GSUP_PDU tr_GSUP_MT_FORWARD_SM_ERR(
1741 template hexstring imsi := ?,
1742 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1743 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1744) := tr_GSUP(
1745 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1746 {
1747 tr_GSUP_IE_IMSI(imsi),
1748 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001749 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1750 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001751 }
1752);
1753
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001754template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_REQ(
1755 hexstring imsi,
1756 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1757 GSUP_SM_ALERT_RSN_Type sm_alert_rsn /* SM Alert Reason, see 7.6.8.8 */
1758) := ts_GSUP(
1759 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1760 {
1761 valueof(ts_GSUP_IE_IMSI(imsi)),
1762 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1763 valueof(ts_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn))
1764 }
1765);
1766template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_REQ(
1767 template hexstring imsi := ?,
1768 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1769 template GSUP_SM_ALERT_RSN_Type sm_alert_rsn := ? /* SM Alert Reason, see 7.6.8.8 */
1770) := tr_GSUP(
1771 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1772 {
1773 tr_GSUP_IE_IMSI(imsi),
1774 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001775 tr_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn),
1776 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001777 }
1778);
1779
1780template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_RES(
1781 hexstring imsi,
1782 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1783) := ts_GSUP(
1784 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1785 {
1786 valueof(ts_GSUP_IE_IMSI(imsi)),
1787 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1788 }
1789);
1790template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_RES(
1791 template hexstring imsi := ?,
1792 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1793) := tr_GSUP(
1794 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1795 {
1796 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001797 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1798 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001799 }
1800);
1801
1802template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_ERR(
1803 hexstring imsi,
1804 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1805 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1806) := ts_GSUP(
1807 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1808 {
1809 valueof(ts_GSUP_IE_IMSI(imsi)),
1810 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1811 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1812 }
1813);
1814template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_ERR(
1815 template hexstring imsi := ?,
1816 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1817 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1818) := tr_GSUP(
1819 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1820 {
1821 tr_GSUP_IE_IMSI(imsi),
1822 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001823 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1824 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001825 }
1826);
1827
Alexander Couzens25d28492023-04-26 19:30:04 +02001828function f_gsup_find_nested_ie_multiple(GSUP_IEs ies, GSUP_IEI iei, integer nth, out GSUP_IeValue ret) return boolean {
1829 var integer current := 0;
1830 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1831 if (ies[i].tag == iei) {
1832 if (current == nth) {
1833 ret := ies[i].val;
1834 return true;
1835 } else {
1836 current := current + 1;
1837 }
1838 }
1839 }
1840 return false;
1841}
1842
Harald Welte8eebb6c2019-08-22 12:40:03 +02001843function f_gsup_find_nested_ie(GSUP_IEs ies, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1844 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1845 if (ies[i].tag == iei) {
1846 ret := ies[i].val;
Harald Weltef9d449e2018-06-24 22:27:47 +02001847 return true;
1848 }
1849 }
Harald Welte8eebb6c2019-08-22 12:40:03 +02001850 return false;
1851}
1852
1853function f_gsup_find_ie(GSUP_PDU msg, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1854 return f_gsup_find_nested_ie(msg.ies, iei, ret);
Harald Weltef9d449e2018-06-24 22:27:47 +02001855}
1856
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001857template GSUP_AN_APDU t_GSUP_AN_APDU(
1858 template GSUP_AN_PROTO an_proto := ?,
1859 template octetstring pdu := ?
1860) := {
1861 proto := an_proto,
1862 pdu := pdu
1863};
1864
1865template GSUP_PDU tr_GSUP_E_AN_APDU(
1866 template GSUP_MessageType msgt,
1867 template hexstring imsi := ?,
1868 template octetstring source_name := ?,
1869 template octetstring destination_name := ?,
1870 template GSUP_AN_APDU an_apdu := ?
1871) := tr_GSUP(
1872 msgt,
1873 {
1874 tr_GSUP_IE_IMSI(imsi),
1875 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1876 tr_GSUP_IE_Source_Name(source_name),
1877 tr_GSUP_IE_Destination_Name(destination_name),
1878 tr_GSUP_IE_AN_APDU(an_apdu)
1879 }
1880);
1881
1882template GSUP_PDU tr_GSUP_E_NO_PDU(
1883 template GSUP_MessageType msgt,
1884 template hexstring imsi := ?,
1885 template octetstring source_name := ?,
1886 template octetstring destination_name := ?
1887) := tr_GSUP(
1888 msgt,
1889 {
1890 tr_GSUP_IE_IMSI(imsi),
1891 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1892 tr_GSUP_IE_Source_Name(source_name),
1893 tr_GSUP_IE_Destination_Name(destination_name)
1894 }
1895);
1896
1897template (value) GSUP_PDU ts_GSUP_E_AN_APDU(
1898 GSUP_MessageType msgt,
1899 hexstring imsi,
1900 octetstring source_name,
1901 octetstring destination_name,
1902 GSUP_AN_APDU an_apdu
1903) := ts_GSUP(
1904 msgt,
1905 {
1906 valueof(ts_GSUP_IE_IMSI(imsi)),
1907 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1908 valueof(ts_GSUP_IE_Source_Name(source_name)),
1909 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1910 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1911 }
1912);
1913
1914template (value) GSUP_PDU ts_GSUP_E_PrepareHandoverResult(
1915 hexstring imsi,
1916 hexstring msisdn,
1917 octetstring source_name,
1918 octetstring destination_name,
1919 GSUP_AN_APDU an_apdu
1920) := ts_GSUP(
1921 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT,
1922 {
1923 valueof(ts_GSUP_IE_IMSI(imsi)),
1924 valueof(ts_GSUP_IE_MSISDN(msisdn)),
1925 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1926 valueof(ts_GSUP_IE_Source_Name(source_name)),
1927 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1928 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1929 }
1930);
Harald Weltef9d449e2018-06-24 22:27:47 +02001931
Harald Weltedf327232017-12-28 22:51:51 +01001932} with { encode "RAW"; variant "FIELDORDER(msb)" }