blob: b3154ac5c8de0949e2bd59d0140ee03f959bbeb8 [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
Pau Espin Pedrolafe3e192023-10-19 16:55:56 +0200141 OSMO_GSUP_MSGT_E_ROUTING_ERROR ('01001110'B),
142
143 OSMO_GSUP_MSGT_EPDG_TUNNEL_REQUEST ('01010000'B),
144 OSMO_GSUP_MSGT_EPDG_TUNNEL_ERROR ('01010001'B),
145 OSMO_GSUP_MSGT_EPDG_TUNNEL_RESULT ('01010010'B)
Harald Weltedf327232017-12-28 22:51:51 +0100146} with { variant "FIELDLENGTH(8)" };
147
148type enumerated GSUP_CancelType {
Alexander Couzens4786b3f2018-09-16 03:33:30 +0200149 OSMO_GSUP_CANCEL_TYPE_UPDATE (0),
150 OSMO_GSUP_CANCEL_TYPE_WITHDRAW (1)
Harald Weltedf327232017-12-28 22:51:51 +0100151} with { variant "FIELDLENGTH(8)" };
152
153type enumerated GSUP_CnDomain {
154 OSMO_GSUP_CN_DOMAIN_PS (1),
155 OSMO_GSUP_CN_DOMAIN_CS (2)
156} with { variant "FIELDLENGTH(8)" };
157
Oliver Smithc5748292019-02-22 15:02:48 +0100158type enumerated GSUP_IMEIResult {
159 OSMO_GSUP_IMEI_RESULT_ACK (0),
160 OSMO_GSUP_IMEI_RESULT_NACK (1)
161} with { variant "FIELDLENGTH(8)" };
162
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700163type enumerated GSUP_SessionState {
164 OSMO_GSUP_SESSION_STATE_NONE (0),
165 OSMO_GSUP_SESSION_STATE_BEGIN (1),
166 OSMO_GSUP_SESSION_STATE_CONTINUE (2),
167 OSMO_GSUP_SESSION_STATE_END (3)
168} with { variant "FIELDLENGTH(8)" };
169
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200170type enumerated GSUP_Message_Class {
171 OSMO_GSUP_MESSAGE_CLASS_UNSET (0),
172 OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT (1),
173 OSMO_GSUP_MESSAGE_CLASS_SMS (2),
174 OSMO_GSUP_MESSAGE_CLASS_USSD (3),
175 OSMO_GSUP_MESSAGE_CLASS_INTER_MSC (4)
176} with { variant "FIELDLENGTH(8)" };
177
Harald Welte3f95be82018-01-27 00:48:13 +0100178type record GSUP_MSISDN {
179 uint8_t len,
180 hexstring digits optional
181} with { variant (len) "LENGTHTO(digits)" };
182
Oliver Smithc5748292019-02-22 15:02:48 +0100183type record GSUP_IMEI {
184 uint8_t len,
185 hexstring digits optional
186} with { variant (len) "LENGTHTO(digits)" };
187
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200188type enumerated GSUP_AN_PROTO {
189 OSMO_GSUP_AN_PROTO_48006 (1),
190 OSMO_GSUP_AN_PROTO_25413 (2)
191} with { variant "FIELDLENGTH(8)" };
192
193type record GSUP_AN_APDU {
194 GSUP_AN_PROTO proto,
195 octetstring pdu
196};
197
Harald Weltedf327232017-12-28 22:51:51 +0100198type record GSUP_IE {
199 GSUP_IEI tag,
200 uint8_t len,
201 GSUP_IeValue val
202} with { variant (len) "LENGTHTO(val)"
203 variant (val) "CROSSTAG(imsi, tag = OSMO_GSUP_IMSI_IE;
204 cause, tag = OSMO_GSUP_CAUSE_IE;
205 cancel_type, tag = OSMO_GSUP_CANCEL_TYPE_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100206 auth_tuple, tag = OSMO_GSUP_AUTH_TUPLE_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100207 auts, tag = OSMO_GSUP_AUTS_IE;
208 rand, tag = OSMO_GSUP_RAND_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100209 sres, tag = OSMO_GSUP_SRES_IE;
210 kc, tag = OSMO_GSUP_KC_IE;
211 ik, tag = OSMO_GSUP_IK_IE;
212 ck, tag = OSMO_GSUP_CK_IE;
213 autn, tag = OSMO_GSUP_AUTN_IE;
214 res, tag = OSMO_GSUP_RES_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100215 msisdn, tag = OSMO_GSUP_MSISDN_IE;
216 hlr_number, tag = OSMO_GSUP_HLR_NUMBER_IE;
217 cn_domain, tag = OSMO_GSUP_CN_DOMAIN_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100218 pdp_info, tag = OSMO_GSUP_PDP_INFO_IE;
219 apn, tag = OSMO_GSUP_ACCESS_POINT_NAME_IE;
220 pdp_qos, tag = OSMO_GSUP_PDP_QOS_IE;
221 pdp_type, tag = OSMO_GSUP_PDP_TYPE_IE;
222 charg_char, tag = OSMO_GSUP_CHARG_CHAR_IE;
Alexander Couzens25d28492023-04-26 19:30:04 +0200223 pdp_ctx_id, tag = OSMO_GSUP_PDP_CONTEXT_ID_IE;
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700224 session_state, tag = OSMO_GSUP_SESSION_STATE_IE;
225 session_id, tag = OSMO_GSUP_SESSION_ID_IE;
226 ss_info, tag = OSMO_GSUP_SS_INFO_IE;
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700227 sm_rp_mr, tag = OSMO_GSUP_SM_RP_MR_IE;
228 sm_rp_da, tag = OSMO_GSUP_SM_RP_DA_IE;
229 sm_rp_oa, tag = OSMO_GSUP_SM_RP_OA_IE;
230 sm_rp_ui, tag = OSMO_GSUP_SM_RP_UI_IE;
231 sm_rp_cause, tag = OSMO_GSUP_SM_RP_CAUSE_IE;
232 sm_rp_mms, tag = OSMO_GSUP_SM_RP_MMS_IE;
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700233 sm_alert_rsn, tag = OSMO_GSUP_SM_ALERT_RSN_IE;
Oliver Smithc5748292019-02-22 15:02:48 +0100234 imei, tag = OSMO_GSUP_IMEI_IE;
235 imei_result, tag = OSMO_GSUP_IMEI_RESULT_IE;
Alexander Couzens752f86b2020-01-10 07:56:31 +0100236 num_auth_vectors, tag = OSMO_GSUP_NUM_VECTORS_REQ_IE;
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200237 message_class, tag = OSMO_GSUP_MESSAGE_CLASS_IE;
238 source_name, tag = OSMO_GSUP_SOURCE_NAME_IE;
239 destination_name, tag = OSMO_GSUP_DESTINATION_NAME_IE;
240 an_apdu, tag = OSMO_GSUP_AN_APDU_IE;
241 cause_rr, tag = OSMO_GSUP_CAUSE_RR_IE;
242 cause_bssap, tag = OSMO_GSUP_CAUSE_BSSAP_IE;
243 cause_sm, tag = OSMO_GSUP_CAUSE_SM_IE;
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100244 supported_rat_types, tag = OSMO_GSUP_SUPPORTED_RAT_TYPES_IE;
245 current_rat_type, tag = OSMO_GSUP_CURRENT_RAT_TYPE_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100246 )"
Harald Weltedf327232017-12-28 22:51:51 +0100247};
248
249type record of GSUP_IE GSUP_IEs;
250
Harald Welte8eebb6c2019-08-22 12:40:03 +0200251type enumerated GSUP_RatType {
252 RAT_TYPE_UNKNOWN (0),
253 RAT_TYPE_GERAN_A (1),
254 RAT_TYPE_UTRAN_Iu (2),
255 RAT_TYPE_EUTRAN_SGs (3)
256} with { variant "FIELDLENGTH(8)" };
257
258type record of GSUP_RatType GSUP_RatTypes;
259
Harald Weltedf327232017-12-28 22:51:51 +0100260type union GSUP_IeValue {
261 hexstring imsi,
262 integer cause,
263 GSUP_CancelType cancel_type,
264 //boolean pdp_info_compl,
265 //boolean freeze_ptmsi,
Harald Weltedf327232017-12-28 22:51:51 +0100266 GSUP_IEs auth_tuple,
267 octetstring auts,
268 octetstring rand,
Harald Welte77a8eba2018-01-22 21:22:32 +0100269 octetstring sres,
270 octetstring kc,
271 octetstring ik,
272 octetstring ck,
273 octetstring autn,
274 octetstring res,
Harald Welte3f95be82018-01-27 00:48:13 +0100275 GSUP_MSISDN msisdn,
Harald Weltedf327232017-12-28 22:51:51 +0100276 octetstring hlr_number,
277 GSUP_CnDomain cn_domain,
Harald Welteeded9ad2018-02-17 20:57:34 +0100278 /* PDP context + nested IEs */
279 GSUP_IEs pdp_info,
Alexander Couzens25d28492023-04-26 19:30:04 +0200280 OCT1 pdp_ctx_id,
Harald Welteeded9ad2018-02-17 20:57:34 +0100281 octetstring apn,
282 octetstring pdp_qos,
283 OCT2 pdp_type,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700284 octetstring charg_char,
285 /* Session information */
286 GSUP_SessionState session_state,
287 OCT4 session_id,
288 /* Supplementary Services */
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700289 octetstring ss_info,
290 /* Short Message Service */
291 OCT1 sm_rp_mr,
292 GSUP_SM_RP_DA sm_rp_da,
293 GSUP_SM_RP_OA sm_rp_oa,
294 octetstring sm_rp_ui,
295 OCT1 sm_rp_cause,
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700296 OCT1 sm_rp_mms,
Oliver Smithc5748292019-02-22 15:02:48 +0100297 GSUP_SM_ALERT_RSN_Type sm_alert_rsn,
298
299 GSUP_IMEI imei,
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200300 GSUP_IMEIResult imei_result,
Alexander Couzens752f86b2020-01-10 07:56:31 +0100301 OCT1 num_auth_vectors,
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200302
303 GSUP_Message_Class message_class,
304
305 octetstring source_name,
306 octetstring destination_name,
307
308 GSUP_AN_APDU an_apdu,
309
310 OCT1 cause_rr,
311 OCT1 cause_bssap,
Harald Welte8eebb6c2019-08-22 12:40:03 +0200312 OCT1 cause_sm,
313
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100314 GSUP_RatTypes supported_rat_types,
315 GSUP_RatType current_rat_type
Harald Weltedf327232017-12-28 22:51:51 +0100316};
317
318type record GSUP_PDU {
319 GSUP_MessageType msg_type,
320 GSUP_IEs ies
321};
322
Alexander Couzens25d28492023-04-26 19:30:04 +0200323type record of GSUP_PDU GSUP_PDUs;
324
Harald Weltedf327232017-12-28 22:51:51 +0100325external function enc_GSUP_PDU(in GSUP_PDU msg) return octetstring
326 with { extension "prototype(convert) encode(RAW)" };
327
328external function dec_GSUP_PDU(in octetstring msg) return GSUP_PDU
329 with { extension "prototype(convert) decode(RAW)" };
330
Harald Welte2f562b12018-01-24 20:52:38 +0100331function f_gsup_postprocess_decoded(inout GSUP_PDU gsup) {
332 if (gsup.ies[0].tag == OSMO_GSUP_IMSI_IE) {
333 /* if last digit is 'F', then there's an odd number of digits and we must strip the F */
334 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
335 if (gsup.ies[0].val.imsi[num_digits-1] == 'F'H) {
336 gsup.ies[0].val.imsi := substr(gsup.ies[0].val.imsi, 0, num_digits-1);
337 }
338 }
339}
340
341function f_gsup_preprocess_encoded(inout GSUP_PDU gsup) {
342 if (ischosen(gsup.ies[0].val.imsi)) {
343 /* if number of digits is odd, add a 'F' as padding at the end */
344 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
345 if (num_digits rem 2 == 1) {
346 gsup.ies[0].val.imsi := gsup.ies[0].val.imsi & 'F'H;
347 }
348 }
349}
350
Harald Welte3f95be82018-01-27 00:48:13 +0100351template (value) GSUP_MSISDN ts_GSUP_MSISDN(hexstring digits,
352 BIT3 ton := '000'B,
353 BIT4 npi := '0000'B) := {
354 len := 0, /* overwritten */
355 /* numberingPlanIdentification := npi,
356 typeOfNumber := ton,
357 ext1 := '0'B, */
358 digits := digits
359}
360
361template GSUP_MSISDN tr_GSUP_MSISDN(template hexstring digits,
362 template BIT3 ton := ?,
363 template BIT4 npi := ?) := {
364 len := ?,
365 /* numberingPlanIdentification := npi,
366 typeOfNumber := ton,
367 ext1 := '0'B, */
368 digits := digits
369}
370
371
Harald Weltedf327232017-12-28 22:51:51 +0100372
Harald Welte77a8eba2018-01-22 21:22:32 +0100373template GSUP_IE ts_GSUP_IE_AuthTuple2G(octetstring rand, octetstring sres,
374 octetstring kc) := {
375 tag := OSMO_GSUP_AUTH_TUPLE_IE,
376 len := 0, /* overwritten */
377 val := {
378 auth_tuple := {
379 valueof(ts_GSUP_IE_RAND(rand)),
380 valueof(ts_GSUP_IE_SRES(sres)),
381 valueof(ts_GSUP_IE_Kc(kc))
382 }
383 }
384}
385
Pau Espin Pedrol965ac642023-10-16 18:12:45 +0200386template GSUP_IE tr_GSUP_IE_AuthTuple3G(
387 template (present) octetstring rand := ?,
388 template (present) octetstring ik := ?,
389 template (present) octetstring ck := ?,
390 template (present) octetstring autn := ?,
391 template (present) octetstring res := ?) := {
392 tag := OSMO_GSUP_AUTH_TUPLE_IE,
393 len := ?,
394 val := {
395 auth_tuple := {
396 tr_GSUP_IE_RAND(rand),
397 tr_GSUP_IE_IK(ik),
398 tr_GSUP_IE_CK(ck),
399 tr_GSUP_IE_AUTN(autn),
400 tr_GSUP_IE_RES(res)
401 }
402 }
403}
404
405template GSUP_IE ts_GSUP_IE_AuthTuple3G(octetstring rand, octetstring ik,
406 octetstring ck, octetstring autn,
407 octetstring res) := {
408 tag := OSMO_GSUP_AUTH_TUPLE_IE,
409 len := 0, /* overwritten */
410 val := {
411 auth_tuple := {
412 valueof(ts_GSUP_IE_RAND(rand)),
413 valueof(ts_GSUP_IE_IK(ik)),
414 valueof(ts_GSUP_IE_CK(ck)),
415 valueof(ts_GSUP_IE_AUTN(autn)),
416 valueof(ts_GSUP_IE_RES(res))
417 }
418 }
419}
420
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200421template GSUP_IE tr_GSUP_IE_AuthTuple2G3G(
422 template (present) octetstring rand := ?,
423 template (present) octetstring sres := ?,
424 template (present) octetstring kc := ?,
425 template (present) octetstring ik := ?,
426 template (present) octetstring ck := ?,
427 template (present) octetstring autn := ?,
428 template (present) octetstring res := ?) := {
429 tag := OSMO_GSUP_AUTH_TUPLE_IE,
430 len := ?,
431 val := {
432 auth_tuple := {
433 tr_GSUP_IE_RAND(rand),
434 tr_GSUP_IE_SRES(sres),
435 tr_GSUP_IE_Kc(kc),
436 tr_GSUP_IE_IK(ik),
437 tr_GSUP_IE_CK(ck),
438 tr_GSUP_IE_AUTN(autn),
439 tr_GSUP_IE_RES(res)
440 }
441 }
442}
443
Harald Welte77a8eba2018-01-22 21:22:32 +0100444template GSUP_IE ts_GSUP_IE_AuthTuple2G3G(octetstring rand, octetstring sres,
445 octetstring kc, octetstring ik,
446 octetstring ck, octetstring autn,
447 octetstring res) := {
448 tag := OSMO_GSUP_AUTH_TUPLE_IE,
449 len := 0, /* overwritten */
450 val := {
451 auth_tuple := {
452 valueof(ts_GSUP_IE_RAND(rand)),
453 valueof(ts_GSUP_IE_SRES(sres)),
454 valueof(ts_GSUP_IE_Kc(kc)),
455 valueof(ts_GSUP_IE_IK(ik)),
456 valueof(ts_GSUP_IE_CK(ck)),
457 valueof(ts_GSUP_IE_AUTN(autn)),
458 valueof(ts_GSUP_IE_RES(res))
459 }
460 }
461}
462
Harald Welteeded9ad2018-02-17 20:57:34 +0100463template GSUP_IE ts_GSUP_IE_PdpInfo(octetstring apn, octetstring pdp_type, octetstring pdp_qos) := {
464 tag := OSMO_GSUP_PDP_INFO_IE,
465 len := 0, /* overwritten */
466 val := {
467 pdp_info := {
468 valueof(ts_GSUP_IE_APN(apn)),
469 valueof(ts_GSUP_IE_PDP_TYPE(pdp_type)),
470 valueof(ts_GSUP_IE_PDP_QOS(pdp_qos))
471 }
472 }
473}
474
Alexander Couzens25d28492023-04-26 19:30:04 +0200475template (value) GSUP_IE ts_GSUP_IE_PDP_CONTEXT_ID(OCT1 ctx_id) := {
476 tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
477 len := 0,
478 val := {
479 pdp_ctx_id := ctx_id
480 }
481}
482
483template GSUP_IE tr_GSUP_IE_PDP_CONTEXT_ID(template OCT1 ctx_id) := {
484 tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
485 len := ?,
486 val := {
487 pdp_ctx_id := ctx_id
488 }
489}
490
491
Harald Welteeded9ad2018-02-17 20:57:34 +0100492template (value) GSUP_IE ts_GSUP_IE_PDP_TYPE(OCT2 pdp_type) := {
493 tag := OSMO_GSUP_PDP_TYPE_IE,
494 len := 0,
495 val := {
496 pdp_type := pdp_type
497 }
498}
499
500template (value) GSUP_IE ts_GSUP_IE_PDP_QOS(octetstring pdp_qos) := {
501 tag := OSMO_GSUP_PDP_QOS_IE,
502 len := 0,
503 val := {
504 pdp_qos := pdp_qos
505 }
506}
507
508
Harald Weltedf327232017-12-28 22:51:51 +0100509template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
510 msg_type := msgt,
511 ies := ies
512}
513
Pau Espin Pedrolafc186d2023-10-19 16:54:58 +0200514template (present) GSUP_PDU tr_GSUP_IMSI(template (present) GSUP_MessageType msgt := ?, template (present) hexstring imsi := ?) := {
Harald Welte8a1dd532018-01-27 15:38:18 +0100515 msg_type := msgt,
516 ies := { tr_GSUP_IE_IMSI(imsi), * }
517}
518
Harald Weltedf327232017-12-28 22:51:51 +0100519template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
520 msg_type := msgt,
521 ies := ies
522}
523
Oliver Smith936dbe62019-06-04 15:54:17 +0200524template (value) GSUP_IMEI ts_GSUP_IMEI(hexstring digits) := {
525 len := 0, /* overwritten */
526 digits := digits
527}
528
529template GSUP_IMEI tr_GSUP_IMEI(template hexstring digits) := {
530 len := ?,
531 digits := digits
532}
533
534
Harald Welte6aa04e32018-01-27 15:35:19 +0100535template (value) GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
Harald Weltedf327232017-12-28 22:51:51 +0100536 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
537
Harald Welte8eebb6c2019-08-22 12:40:03 +0200538template (value) GSUP_PDU ts_GSUP_SAI_REQ_EPS(hexstring imsi) :=
539 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
540 valueof(ts_GSUP_IE_IMSI(imsi)),
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100541 valueof(ts_GSUP_IE_CURRENT_RAT_TYPE(RAT_TYPE_EUTRAN_SGs))
Harald Welte8eebb6c2019-08-22 12:40:03 +0200542 });
543
Alexander Couzens752f86b2020-01-10 07:56:31 +0100544template (value) GSUP_PDU ts_GSUP_SAI_REQ_NUM_AUTH(hexstring imsi, OCT1 num_auth_vectors) :=
545 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
546 valueof(ts_GSUP_IE_IMSI(imsi)),
547 valueof(ts_GSUP_IE_NUM_VECTORS_REQ(num_auth_vectors))
548 });
549
Harald Welteef9fa872018-01-22 03:00:17 +0100550template GSUP_PDU tr_GSUP_SAI_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100551 tr_GSUP_IMSI(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, imsi);
Harald Welteef9fa872018-01-22 03:00:17 +0100552
Alexander Couzensd24973d2018-09-04 16:10:14 +0200553template GSUP_PDU tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC(
554 template hexstring imsi,
555 template octetstring auts,
556 template octetstring rand) :=
557 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
558 tr_GSUP_IE_IMSI(imsi),
559 tr_GSUP_IE_AUTS(auts),
560 tr_GSUP_IE_RAND(rand),
561 *
562 });
563
Harald Welte77a8eba2018-01-22 21:22:32 +0100564template (value) GSUP_PDU ts_GSUP_SAI_RES(hexstring imsi, GSUP_IE auth_tuple) :=
565 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
566 valueof(ts_GSUP_IE_IMSI(imsi)), auth_tuple });
567
Harald Weltedf327232017-12-28 22:51:51 +0100568template GSUP_PDU tr_GSUP_SAI_ERR(template hexstring imsi, template integer cause) :=
Harald Welte071ed732018-01-23 19:53:52 +0100569 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
Harald Weltedf327232017-12-28 22:51:51 +0100570 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
571
Harald Welte6aa04e32018-01-27 15:35:19 +0100572template (value) GSUP_PDU ts_GSUP_SAI_ERR(hexstring imsi, integer cause) :=
573 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
574 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
Harald Welte071ed732018-01-23 19:53:52 +0100575
576
Pau Espin Pedrol965ac642023-10-16 18:12:45 +0200577template GSUP_PDU tr_GSUP_SAI_RES(template (present) hexstring imsi,
578 template (present) GSUP_IE auth_tuple_ie := tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE)) :=
Harald Weltec2c52552018-03-01 21:20:39 +0100579 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
Pau Espin Pedrol965ac642023-10-16 18:12:45 +0200580 tr_GSUP_IE_IMSI(imsi), *, auth_tuple_ie, * });
Harald Weltedf327232017-12-28 22:51:51 +0100581
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100582template GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi, GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS,
583 template octetstring source_name := omit) :=
584 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, f_gen_ts_ies(imsi, dom := dom,
585 source_name := source_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100586
Harald Weltedfe94dd2018-01-21 13:55:22 +0100587template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100588 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, imsi);
Harald Weltedfe94dd2018-01-21 13:55:22 +0100589
Oliver Smith07786da2020-01-29 14:48:19 +0100590template (value) GSUP_PDU ts_GSUP_UL_RES(hexstring imsi, octetstring destination_name := ''O) :=
591 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)),
592 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
Harald Weltedfe94dd2018-01-21 13:55:22 +0100593
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100594template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi, template octetstring destination_name := omit) :=
595 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, f_gen_tr_ies(imsi, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100596
Harald Welte6aa04e32018-01-27 15:35:19 +0100597template (value) GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100598 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
599 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
600
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100601template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?,
602 template octetstring destination_name := omit) :=
603 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR,
604 f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100605
Oliver Smith07786da2020-01-29 14:48:19 +0100606template (value) GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn, octetstring destination_name := ''O) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100607 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
Oliver Smith07786da2020-01-29 14:48:19 +0100608 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)),
609 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
Harald Welte6ff81902018-01-21 19:09:08 +0100610
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100611template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?,
612 template octetstring destination_name := omit) :=
613 tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST,
614 f_gen_tr_ies(imsi, msisdn := msisdn, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100615
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100616template GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi,
617 template octetstring source_name := omit,
618 template octetstring destination_name := omit) :=
619 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT,
620 f_gen_ts_ies(imsi, source_name := source_name,
621 destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100622
Harald Welte6ff81902018-01-21 19:09:08 +0100623template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100624 tr_GSUP_IMSI(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100625
Harald Weltec638f4d2018-01-24 22:00:36 +0100626template GSUP_PDU tr_GSUP_AUTH_FAIL_IND(hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100627 tr_GSUP_IMSI(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100628
Harald Welte167458a2018-01-27 15:58:16 +0100629template (value) GSUP_PDU ts_GSUP_CL_REQ(hexstring imsi, GSUP_CancelType ctype) :=
630 ts_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST, {
631 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CancelType(ctype)) });
632
633template GSUP_PDU tr_GSUP_CL_RES(template hexstring imsi) :=
634 tr_GSUP_IMSI(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT, imsi);
635
636template GSUP_PDU tr_GSUP_CL_ERR(template hexstring imsi, template integer cause := ?) :=
637 tr_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR, {
Alexander Couzens4cfff3a2018-05-22 17:08:36 +0200638 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause), * });
Harald Welte167458a2018-01-27 15:58:16 +0100639
Harald Welte958f8b42018-03-01 23:40:17 +0100640template (value) GSUP_PDU ts_GSUP_PURGE_MS_REQ(hexstring imsi, GSUP_CnDomain dom) :=
641 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
642 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CnDomain(dom)) });
643
Harald Welte6abb9fe2018-02-17 15:24:48 +0100644template GSUP_PDU tr_GSUP_PURGE_MS_REQ(template hexstring imsi, template GSUP_CnDomain dom := ?) :=
645 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
646 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_CnDomain(dom) });
647
648template (value) GSUP_PDU ts_GSUP_PURGE_MS_RES(hexstring imsi) :=
649 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
650 valueof(ts_GSUP_IE_IMSI(imsi)) });
651
Harald Welte958f8b42018-03-01 23:40:17 +0100652template GSUP_PDU tr_GSUP_PURGE_MS_RES(template hexstring imsi) :=
653 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
654 tr_GSUP_IE_IMSI(imsi), * });
655
656template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer cause) :=
657 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
658 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
659
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100660template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei,
661 template (omit) octetstring source_name := omit) :=
662 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 +0200663
Oliver Smith1d118ff2019-07-03 10:57:35 +0200664template GSUP_PDU tr_GSUP_CHECK_IMEI_REQ(
665 template hexstring imsi,
666 template hexstring imei
667) := tr_GSUP(
668 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST,
669 {
670 tr_GSUP_IE_IMSI(imsi),
671 tr_GSUP_IE_IMEI(imei),
672 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT)
673 }
674);
675
676template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_RES(hexstring imsi, GSUP_IMEIResult result) :=
677 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
678 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI_Result(result)) });
679
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100680template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result,
681 template octetstring destination_name := omit) :=
682 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT,
683 f_gen_tr_ies(imsi, imei_result := result, destination_name := destination_name));
Oliver Smith936dbe62019-06-04 15:54:17 +0200684
Oliver Smith1d118ff2019-07-03 10:57:35 +0200685template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_ERR(hexstring imsi, integer cause) :=
686 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
687 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
688
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100689template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause,
690 template octetstring destination_name := omit) :=
691 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 +0200692
Harald Welte167458a2018-01-27 15:58:16 +0100693
Pau Espin Pedrolafe3e192023-10-19 16:55:56 +0200694/* EPDG Tunnel */
695template (value) GSUP_PDU ts_GSUP_EPDGTunnel_REQ(hexstring imsi, GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS,
696 template (omit) octetstring source_name := omit) :=
697 ts_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_REQUEST, f_gen_ts_ies(imsi, dom := dom,
698 source_name := source_name));
699
700template (present) GSUP_PDU tr_GSUP_EPDGTunnel_REQ(template (present) hexstring imsi := ?) :=
701 tr_GSUP_IMSI(OSMO_GSUP_MSGT_EPDG_TUNNEL_REQUEST, imsi);
702
703template (value) GSUP_PDU ts_GSUP_EPDGTunnel_RES(hexstring imsi, octetstring destination_name := ''O) :=
704 ts_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)),
705 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
706
707template (present) GSUP_PDU tr_GSUP_EPDGTunnel_RES(template (present) hexstring imsi, template octetstring destination_name := omit) :=
708 tr_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_RESULT, f_gen_tr_ies(imsi, destination_name := destination_name));
709
710template (value) GSUP_PDU ts_GSUP_EPDGTunnel_ERR(hexstring imsi, integer cause) :=
711 ts_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_ERROR, {
712 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
713
714template (present) GSUP_PDU tr_GSUP_EPDGTunnel_ERR(template (present) hexstring imsi, template (present) integer cause := ?,
715 template octetstring destination_name := omit) :=
716 tr_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_ERROR,
717 f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name));
718
719
Harald Welte167458a2018-01-27 15:58:16 +0100720template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
721 tag := OSMO_GSUP_CANCEL_TYPE_IE,
722 len := 0, /* overwritten */
723 val := {
724 cancel_type := ctype
725 }
726}
727
728template GSUP_IE tr_GSUP_IE_CancelType(template GSUP_CancelType ctype) :=
729 tr_GSUP_IE(OSMO_GSUP_CANCEL_TYPE_IE, GSUP_IeValue:{cancel_type:=ctype});
730
Harald Welte6abb9fe2018-02-17 15:24:48 +0100731template GSUP_IE tr_GSUP_IE_CnDomain(template GSUP_CnDomain domain) :=
732 tr_GSUP_IE(OSMO_GSUP_CN_DOMAIN_IE, GSUP_IeValue:{cn_domain:=domain});
733
Harald Weltedf327232017-12-28 22:51:51 +0100734template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := {
735 tag := iei,
736 len := ?,
737 val := val
738}
739
740template (value) GSUP_IE ts_GSUP_IE_IMSI(hexstring imsi) := {
741 tag := OSMO_GSUP_IMSI_IE,
742 len := 0, /* overwritten */
743 val := {
744 imsi := imsi
745 }
746}
747
Pau Espin Pedrolafc186d2023-10-19 16:54:58 +0200748template (present) GSUP_IE tr_GSUP_IE_IMSI(template (present) hexstring imsi := ?) := {
Harald Weltedf327232017-12-28 22:51:51 +0100749 tag := OSMO_GSUP_IMSI_IE,
750 len := ?,
751 val := {
752 imsi := imsi
753 }
754}
755
Harald Welte6ff81902018-01-21 19:09:08 +0100756template (value) GSUP_IE ts_GSUP_IE_MSISDN(hexstring msisdn) := {
757 tag := OSMO_GSUP_MSISDN_IE,
758 len := 0, /* overwritten */
759 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100760 msisdn := ts_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100761 }
762}
763
764template GSUP_IE tr_GSUP_IE_MSISDN(template hexstring msisdn) := {
765 tag := OSMO_GSUP_MSISDN_IE,
766 len := ?,
767 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100768 msisdn := tr_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100769 }
770}
771
772
Harald Weltedf327232017-12-28 22:51:51 +0100773template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := {
774 tag := OSMO_GSUP_CAUSE_IE,
775 len := 0, /* overwritten */
776 val := {
777 cause := cause
778 }
779}
780
781template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := {
782 tag := OSMO_GSUP_CAUSE_IE,
783 len := ?,
784 val := {
785 cause := cause
786 }
787}
788
789template (value) GSUP_IE ts_GSUP_IE_AUTS(octetstring auts) := {
790 tag := OSMO_GSUP_AUTS_IE,
791 len := 0, /* overwritten */
792 val := {
793 auts := auts
794 }
795}
796
Alexander Couzensd24973d2018-09-04 16:10:14 +0200797template GSUP_IE tr_GSUP_IE_AUTS(template octetstring auts) := {
798 tag := OSMO_GSUP_AUTS_IE,
799 len := ?,
800 val := {
801 auts := auts
802 }
803}
804
Harald Weltedf327232017-12-28 22:51:51 +0100805template (value) GSUP_IE ts_GSUP_IE_RAND(octetstring rand) := {
806 tag := OSMO_GSUP_RAND_IE,
807 len := 0, /* overwritten */
808 val := {
809 rand := rand
810 }
811}
812
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200813template GSUP_IE tr_GSUP_IE_RAND(template octetstring rand := ?) := {
Alexander Couzensd24973d2018-09-04 16:10:14 +0200814 tag := OSMO_GSUP_RAND_IE,
815 len := ?,
816 val := {
817 rand := rand
818 }
819}
820
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200821template (present) GSUP_IE tr_GSUP_IE_SRES(template (present) octetstring sres := ?) := {
822 tag := OSMO_GSUP_SRES_IE,
823 len := ?,
824 val := {
825 sres := sres
826 }
827}
828
Harald Welte77a8eba2018-01-22 21:22:32 +0100829template (value) GSUP_IE ts_GSUP_IE_SRES(octetstring sres) := {
830 tag := OSMO_GSUP_SRES_IE,
831 len := 0, /* overwritten */
832 val := {
833 sres := sres
834 }
835}
836
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200837template (present) GSUP_IE tr_GSUP_IE_Kc(template (present) octetstring kc := ?) := {
838 tag := OSMO_GSUP_KC_IE,
839 len := ?,
840 val := {
841 kc := kc
842 }
843}
844
Harald Welte77a8eba2018-01-22 21:22:32 +0100845template (value) GSUP_IE ts_GSUP_IE_Kc(octetstring kc) := {
846 tag := OSMO_GSUP_KC_IE,
847 len := 0, /* overwritten */
848 val := {
849 kc := kc
850 }
851}
852
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200853template (present) GSUP_IE tr_GSUP_IE_IK(template (present) octetstring ik := ?) := {
854 tag := OSMO_GSUP_IK_IE,
855 len := ?,
856 val := {
857 ik := ik
858 }
859}
860
Harald Welte77a8eba2018-01-22 21:22:32 +0100861template (value) GSUP_IE ts_GSUP_IE_IK(octetstring ik) := {
862 tag := OSMO_GSUP_IK_IE,
863 len := 0, /* overwritten */
864 val := {
865 ik := ik
866 }
867}
868
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200869template (present) GSUP_IE tr_GSUP_IE_CK(template (present) octetstring ck := ?) := {
870 tag := OSMO_GSUP_CK_IE,
871 len := ?,
872 val := {
873 ck := ck
874 }
875}
876
Harald Welte77a8eba2018-01-22 21:22:32 +0100877template (value) GSUP_IE ts_GSUP_IE_CK(octetstring ck) := {
878 tag := OSMO_GSUP_CK_IE,
879 len := 0, /* overwritten */
880 val := {
881 ck := ck
882 }
883}
884
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200885template (present) GSUP_IE tr_GSUP_IE_AUTN(template (present) octetstring autn := ?) := {
886 tag := OSMO_GSUP_AUTN_IE,
887 len := ?,
888 val := {
889 autn := autn
890 }
891}
892
Harald Welte77a8eba2018-01-22 21:22:32 +0100893template (value) GSUP_IE ts_GSUP_IE_AUTN(octetstring autn) := {
894 tag := OSMO_GSUP_AUTN_IE,
895 len := 0, /* overwritten */
896 val := {
897 autn := autn
898 }
899}
900
Pau Espin Pedrol7f8ce322023-10-16 18:04:55 +0200901template (present) GSUP_IE tr_GSUP_IE_RES(template (present) octetstring res := ?) := {
902 tag := OSMO_GSUP_RES_IE,
903 len := ?,
904 val := {
905 res := res
906 }
907}
908
Harald Welte77a8eba2018-01-22 21:22:32 +0100909template (value) GSUP_IE ts_GSUP_IE_RES(octetstring res) := {
910 tag := OSMO_GSUP_RES_IE,
911 len := 0, /* overwritten */
912 val := {
913 res := res
914 }
915}
Harald Weltedf327232017-12-28 22:51:51 +0100916
Harald Welteeded9ad2018-02-17 20:57:34 +0100917template (value) GSUP_IE ts_GSUP_IE_APN(octetstring apn) := {
918 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
919 len := 0, /* overwritten */
920 val := {
921 apn := apn
922 }
923}
924
Alexander Couzens25d28492023-04-26 19:30:04 +0200925template GSUP_IE tr_GSUP_IE_APN(template octetstring apn) := {
926 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
927 len := ?,
928 val := {
929 apn := apn
930 }
931}
932
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100933template GSUP_IE ts_GSUP_IE_CnDomain(template GSUP_CnDomain dom) := {
Harald Welte958f8b42018-03-01 23:40:17 +0100934 tag := OSMO_GSUP_CN_DOMAIN_IE,
935 len := 0, /* overwritten */
936 val := {
937 cn_domain := dom
938 }
939}
Harald Weltedf327232017-12-28 22:51:51 +0100940
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700941template (value) GSUP_IE ts_GSUP_IE_SessionId(OCT4 sid) := {
942 tag := OSMO_GSUP_SESSION_ID_IE,
943 len := 0, /* overwritten */
944 val := {
945 session_id := sid
946 }
947}
948template GSUP_IE tr_GSUP_IE_SessionId(template OCT4 sid) := {
949 tag := OSMO_GSUP_SESSION_ID_IE,
950 len := ?,
951 val := {
952 session_id := sid
953 }
954}
955
956template (value) GSUP_IE ts_GSUP_IE_SessionState(GSUP_SessionState state) := {
957 tag := OSMO_GSUP_SESSION_STATE_IE,
958 len := 0, /* overwritten */
959 val := {
960 session_state := state
961 }
962}
963template GSUP_IE tr_GSUP_IE_SessionState(template GSUP_SessionState state) := {
964 tag := OSMO_GSUP_SESSION_STATE_IE,
965 len := ?,
966 val := {
967 session_state := state
968 }
969}
970
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700971template (value) GSUP_IE ts_GSUP_IE_SM_RP_MR(OCT1 ref) := {
972 tag := OSMO_GSUP_SM_RP_MR_IE,
973 len := 0, /* overwritten */
974 val := {
975 sm_rp_mr := ref
976 }
977}
978template GSUP_IE tr_GSUP_IE_SM_RP_MR(template OCT1 ref) := {
979 tag := OSMO_GSUP_SM_RP_MR_IE,
980 len := ?,
981 val := {
982 sm_rp_mr := ref
983 }
984}
985
986template (value) GSUP_IE ts_GSUP_IE_SM_RP_CAUSE(OCT1 cause) := {
987 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
988 len := 0, /* overwritten */
989 val := {
990 sm_rp_cause := cause
991 }
992}
993template GSUP_IE tr_GSUP_IE_SM_RP_CAUSE(template OCT1 cause) := {
994 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
995 len := ?,
996 val := {
997 sm_rp_cause := cause
998 }
999}
1000
1001template (value) GSUP_IE ts_GSUP_IE_SM_RP_MMS(OCT1 mms) := {
1002 tag := OSMO_GSUP_SM_RP_MMS_IE,
1003 len := 0, /* overwritten */
1004 val := {
1005 sm_rp_mms := mms
1006 }
1007}
1008template GSUP_IE tr_GSUP_IE_SM_RP_MMS(template OCT1 mms) := {
1009 tag := OSMO_GSUP_SM_RP_MMS_IE,
1010 len := ?,
1011 val := {
1012 sm_rp_mms := mms
1013 }
1014}
1015
Oliver Smith936dbe62019-06-04 15:54:17 +02001016template (value) GSUP_IE ts_GSUP_IE_IMEI(hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +01001017 tag := OSMO_GSUP_IMEI_IE,
1018 len := 0, /* overwritten */
1019 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +02001020 imei := ts_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +01001021 }
1022}
Oliver Smith936dbe62019-06-04 15:54:17 +02001023template GSUP_IE tr_GSUP_IE_IMEI(template hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +01001024 tag := OSMO_GSUP_IMEI_IE,
1025 len := ?,
1026 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +02001027 imei := tr_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +01001028 }
1029}
1030
Oliver Smith936dbe62019-06-04 15:54:17 +02001031template (value) GSUP_IE ts_GSUP_IE_IMEI_Result(GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +01001032 tag := OSMO_GSUP_IMEI_RESULT_IE,
1033 len := 0, /* overwritten */
1034 val := {
1035 imei_result := result
1036 }
1037}
Oliver Smith936dbe62019-06-04 15:54:17 +02001038template GSUP_IE tr_GSUP_IE_IMEI_Result(template GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +01001039 tag := OSMO_GSUP_IMEI_RESULT_IE,
1040 len := ?,
1041 val := {
1042 imei_result := result
1043 }
1044}
1045
Alexander Couzens752f86b2020-01-10 07:56:31 +01001046template (value) GSUP_IE ts_GSUP_IE_NUM_VECTORS_REQ(OCT1 num) := {
1047 tag := OSMO_GSUP_NUM_VECTORS_REQ_IE,
1048 len := 0, /* overwritten */
1049 val := {
1050 num_auth_vectors := num
1051 }
1052}
1053template GSUP_IE tr_GSUP_IE_NUM_VECTORS_REQ(template OCT1 num) := {
1054 tag := OSMO_GSUP_NUM_VECTORS_REQ_IE,
1055 len := ?,
1056 val := {
1057 num_auth_vectors := num
1058 }
1059}
1060
1061
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001062/* Possible identity types for SM-RP-{OA|DA} IEs */
1063type enumerated GSUP_SM_RP_ODA_IdType {
1064 OSMO_GSUP_SM_RP_ODA_ID_NONE ('00'O),
1065 OSMO_GSUP_SM_RP_ODA_ID_IMSI ('01'O),
1066 OSMO_GSUP_SM_RP_ODA_ID_MSISDN ('02'O),
1067 OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR ('03'O),
1068 /* Special value for noSM-RP-DA and noSM-RP-OA */
1069 OSMO_GSUP_SM_RP_ODA_ID_NULL ('FF'O)
1070} with { variant "FIELDLENGTH(8)" };
1071
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001072/* See 3GPP TS 24.011, figures 8.5 and 8.6 */
1073type record GSUP_SM_RP_Addr {
1074 BIT1 ext, /* Extension? */
1075 BIT3 ton, /* Type of Number */
1076 BIT4 npi, /* Numbering Plan Identification */
1077 hexstring number length (1..20)
1078} with {
1079 variant "PADDING(yes)";
1080 variant "PADDING_PATTERN('1111'B)"
1081};
1082
1083private function f_pad_SM_RP_Addr(template hexstring number)
1084return template hexstring {
1085 if (isvalue(number) and not istemplatekind(number, "omit")) {
1086 return f_pad_bcd_number(valueof(number));
1087 } else {
1088 return number;
1089 }
1090}
1091
1092template GSUP_SM_RP_Addr t_GSUP_SM_RP_Addr(template hexstring number,
1093 template BIT4 npi := '0001'B,
1094 template BIT3 ton := '001'B,
1095 template BIT1 ext := '1'B) := {
1096 ext := ext,
1097 ton := ton,
1098 npi := npi,
1099 /* Work around TITAN's padding problems: encoding works fine,
1100 * but it does not consider 'F'H as padding in decoded data. */
1101 number := f_pad_SM_RP_Addr(number)
1102}
1103
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001104/**
1105 * SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
1106 * It can be either of the following:
1107 * - IMSI
1108 * - LMSI (not implemented)
1109 * - MSISDN
1110 * - roaming number (not implemented)
1111 * - service centre address
1112 */
1113type union GSUP_SM_RP_DA_ID {
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001114 hexstring imsi,
1115 GSUP_SM_RP_Addr msisdn,
1116 GSUP_SM_RP_Addr smsc_addr
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001117};
1118
1119type record GSUP_SM_RP_DA {
1120 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001121 GSUP_SM_RP_DA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +07001122} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001123 imsi, id_type = OSMO_GSUP_SM_RP_ODA_ID_IMSI;
1124 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
1125 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
1126 /* FIXME: how to handle noSM-RP-DA? */
1127 )"
1128};
1129
1130template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_IMSI(hexstring imsi) := {
1131 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001132 id_enc := { imsi := imsi }
1133}
1134template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_IMSI(template hexstring imsi) := {
1135 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001136 id_enc := { imsi := imsi }
1137}
1138
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001139template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001140 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001141 id_enc := { msisdn := msisdn }
1142}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001143template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001144 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001145 id_enc := { msisdn := msisdn }
1146}
1147
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001148template (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 +07001149 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001150 id_enc := { smsc_addr := smsc_addr }
1151}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001152template 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 +07001153 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001154 id_enc := { smsc_addr := smsc_addr }
1155}
1156
1157template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_NULL := {
1158 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001159 id_enc := omit
1160}
1161template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_NULL := {
1162 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001163 id_enc := omit
1164}
1165
1166template (value) GSUP_IE ts_GSUP_IE_SM_RP_DA(GSUP_SM_RP_DA val) := {
1167 tag := OSMO_GSUP_SM_RP_DA_IE,
1168 len := 0, /* overwritten */
1169 val := {
1170 sm_rp_da := val
1171 }
1172}
1173template GSUP_IE tr_GSUP_IE_SM_RP_DA(template GSUP_SM_RP_DA val) := {
1174 tag := OSMO_GSUP_SM_RP_DA_IE,
1175 len := ?,
1176 val := {
1177 sm_rp_da := val
1178 }
1179}
1180
1181/**
1182 * SM-RP-OA represents the SM Originating Address, see 7.6.8.2.
1183 * It can be either of the following:
1184 * - MSISDN
1185 * - service centre address
1186 */
1187type union GSUP_SM_RP_OA_ID {
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001188 GSUP_SM_RP_Addr msisdn,
1189 GSUP_SM_RP_Addr smsc_addr
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001190};
1191
1192type record GSUP_SM_RP_OA {
1193 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001194 GSUP_SM_RP_OA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +07001195} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001196 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
1197 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
1198 /* FIXME: how to handle noSM-RP-OA? */
1199 )"
1200};
1201
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001202template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001203 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001204 id_enc := { msisdn := msisdn }
1205}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001206template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001207 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001208 id_enc := { msisdn := msisdn }
1209}
1210
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001211template (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 +07001212 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001213 id_enc := { smsc_addr := smsc_addr }
1214}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001215template 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 +07001216 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001217 id_enc := { smsc_addr := smsc_addr }
1218}
1219
1220template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_NULL := {
1221 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001222 id_enc := omit
1223}
1224template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_NULL := {
1225 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001226 id_enc := omit
1227}
1228
1229template (value) GSUP_IE ts_GSUP_IE_SM_RP_OA(GSUP_SM_RP_OA val) := {
1230 tag := OSMO_GSUP_SM_RP_OA_IE,
1231 len := 0, /* overwritten */
1232 val := {
1233 sm_rp_oa := val
1234 }
1235}
1236template GSUP_IE tr_GSUP_IE_SM_RP_OA(template GSUP_SM_RP_OA val) := {
1237 tag := OSMO_GSUP_SM_RP_OA_IE,
1238 len := ?,
1239 val := {
1240 sm_rp_oa := val
1241 }
1242}
1243
1244/* SM-RP-UI represents the SM TPDU, see 7.6.8.4 */
1245template (value) GSUP_IE ts_GSUP_IE_SM_RP_UI(octetstring val) := {
1246 tag := OSMO_GSUP_SM_RP_UI_IE,
1247 len := 0, /* overwritten */
1248 val := {
1249 sm_rp_ui := val
1250 }
1251}
1252template GSUP_IE tr_GSUP_IE_SM_RP_UI(template octetstring val) := {
1253 tag := OSMO_GSUP_SM_RP_UI_IE,
1254 len := ?,
1255 val := {
1256 sm_rp_ui := val
1257 }
1258}
1259
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001260/* SM Alert Reason types, see 7.6.8.8 */
1261type enumerated GSUP_SM_ALERT_RSN_Type {
1262 GSUP_SM_ALERT_RSN_TYPE_NONE ('00'O),
1263 GSUP_SM_ALERT_RSN_TYPE_MS_PRESENT ('01'O),
1264 GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL ('02'O)
1265} with { variant "FIELDLENGTH(8)" };
1266
1267/* SM Alert Reason IE (used in READY-FOR-SM), see 7.6.8.8 */
1268template (value) GSUP_IE ts_GSUP_IE_SM_ALERT_RSN(GSUP_SM_ALERT_RSN_Type rsn) := {
1269 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1270 len := 0, /* overwritten */
1271 val := {
1272 sm_alert_rsn := rsn
1273 }
1274}
1275template GSUP_IE tr_GSUP_IE_SM_ALERT_RSN(template GSUP_SM_ALERT_RSN_Type rsn) := {
1276 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1277 len := ?,
1278 val := {
1279 sm_alert_rsn := rsn
1280 }
1281}
1282
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001283template (value) GSUP_IE ts_GSUP_IE_SSInfo(octetstring ss) := {
1284 tag := OSMO_GSUP_SS_INFO_IE,
1285 len := 0, /* overwritten */
1286 val := {
1287 ss_info := ss
1288 }
1289}
1290template GSUP_IE tr_GSUP_IE_SSInfo(template octetstring ss) := {
1291 tag := OSMO_GSUP_SS_INFO_IE,
1292 len := ?,
1293 val := {
1294 ss_info := ss
1295 }
1296}
1297
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001298template GSUP_IE tr_GSUP_IE_Message_Class(template GSUP_Message_Class val) := {
1299 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1300 len := ?,
1301 val := {
1302 message_class := val
1303 }
1304}
1305
1306template (value) GSUP_IE ts_GSUP_IE_Message_Class(GSUP_Message_Class val) := {
1307 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1308 len := 0, /* overwritten */
1309 val := {
1310 message_class := val
1311 }
1312}
1313
1314template GSUP_IE tr_GSUP_IE_Source_Name(template octetstring name) := {
1315 tag := OSMO_GSUP_SOURCE_NAME_IE,
1316 len := ?,
1317 val := {
1318 source_name := name
1319 }
1320}
1321
1322template (value) GSUP_IE ts_GSUP_IE_Source_Name(octetstring name) := {
1323 tag := OSMO_GSUP_SOURCE_NAME_IE,
1324 len := 0, /* overwritten */
1325 val := {
1326 source_name := name
1327 }
1328}
1329
1330template GSUP_IE tr_GSUP_IE_Destination_Name(template octetstring name) := {
1331 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1332 len := ?,
1333 val := {
1334 destination_name := name
1335 }
1336}
1337
1338template (value) GSUP_IE ts_GSUP_IE_Destination_Name(octetstring name) := {
1339 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1340 len := 0, /* overwritten */
1341 val := {
1342 destination_name := name
1343 }
1344}
1345
1346template GSUP_IE tr_GSUP_IE_AN_APDU(template GSUP_AN_APDU an_apdu) := {
1347 tag := OSMO_GSUP_AN_APDU_IE,
1348 len := ?,
1349 val := {
1350 an_apdu := an_apdu
1351 }
1352}
1353
1354template (value) GSUP_IE ts_GSUP_IE_AN_APDU(GSUP_AN_APDU an_apdu) := {
1355 tag := OSMO_GSUP_AN_APDU_IE,
1356 len := 0, /* overwritten */
1357 val := {
1358 an_apdu := an_apdu
1359 }
1360}
1361
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001362template (present) GSUP_IE tr_GSUP_IE_SUPPORTED_RAT_TYPES(template (present) GSUP_RatTypes ratt) := {
1363 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
Harald Welte8eebb6c2019-08-22 12:40:03 +02001364 len := ?,
1365 val := {
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001366 supported_rat_types := ratt
Harald Welte8eebb6c2019-08-22 12:40:03 +02001367 }
1368}
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001369template (value) GSUP_IE ts_GSUP_IE_SUPPORTED_RAT_TYPES(GSUP_RatTypes ratt) := {
1370 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
Harald Welte8eebb6c2019-08-22 12:40:03 +02001371 len := 0, /* overwritten */
1372 val := {
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001373 supported_rat_types := ratt
1374 }
1375}
1376
1377template (present) GSUP_IE tr_GSUP_IE_CURRENT_RAT_TYPE(template (present) GSUP_RatType ratt) := {
1378 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1379 len := ?,
1380 val := {
1381 current_rat_type := ratt
1382 }
1383}
1384template (value) GSUP_IE ts_GSUP_IE_CURRENT_RAT_TYPE(GSUP_RatType ratt) := {
1385 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1386 len := 0, /* overwritten */
1387 val := {
1388 current_rat_type := ratt
Harald Welte8eebb6c2019-08-22 12:40:03 +02001389 }
1390}
1391
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001392private function f_gen_ts_ies(hexstring imsi,
1393 template hexstring imei := omit,
1394 template GSUP_CnDomain dom := omit,
1395 template octetstring source_name := omit,
1396 template octetstring destination_name := omit
1397 ) return GSUP_IEs {
1398 var GSUP_IEs ies := {
1399 valueof(ts_GSUP_IE_IMSI(imsi))
1400 };
1401
1402 if (isvalue(dom)) {
1403 ies := ies & { valueof(ts_GSUP_IE_CnDomain(dom)) };
1404 }
1405
1406 if (isvalue(imei)) {
1407 ies := ies & { valueof(ts_GSUP_IE_IMEI(valueof(imei))) };
1408 }
1409
1410 if (isvalue(source_name)) {
1411 ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) };
1412 }
1413
1414 if (isvalue(destination_name)) {
1415 ies := ies & { valueof(ts_GSUP_IE_Destination_Name(valueof(destination_name))) };
1416 }
1417
1418 return ies;
1419}
1420
1421private function f_gen_tr_ies(template hexstring imsi,
1422 template integer cause := omit,
1423 template hexstring msisdn := omit,
1424 template GSUP_IMEIResult imei_result := omit,
1425 template octetstring source_name := omit,
1426 template octetstring destination_name := omit
1427 ) return template GSUP_IEs {
1428 var template GSUP_IEs ies := {
1429 tr_GSUP_IE_IMSI(imsi)
1430 };
1431 var integer idx := 1;
1432
1433 if (isvalue(cause)) {
1434 ies[idx] := tr_GSUP_IE_Cause(cause);
1435 idx := idx + 1;
1436 }
1437
1438 if (isvalue(msisdn)) {
1439 ies[idx] := tr_GSUP_IE_MSISDN(msisdn);
1440 idx := idx + 1;
1441 }
1442
1443 if (isvalue(imei_result)) {
1444 ies[idx] := tr_GSUP_IE_IMEI_Result(imei_result);
1445 idx := idx + 1;
1446 }
1447
1448 if (isvalue(source_name)) {
1449 ies[idx] := tr_GSUP_IE_Source_Name(source_name);
1450 idx := idx + 1;
1451 }
1452
1453 ies[idx] := *;
1454 idx := idx + 1;
1455
1456 if (isvalue(destination_name)) {
1457 ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
1458 idx := idx + 1;
1459 }
1460
1461 return ies;
1462}
Harald Welte8eebb6c2019-08-22 12:40:03 +02001463
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001464private function f_gen_ts_ss_ies(
1465 hexstring imsi,
1466 OCT4 sid,
1467 GSUP_SessionState state,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001468 template (omit) octetstring ss := omit,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001469 template (omit) integer cause := omit,
1470 template octetstring source_name := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001471) return GSUP_IEs {
1472 /* Mandatory IEs */
1473 var GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001474 valueof(ts_GSUP_IE_IMSI(imsi))
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001475 };
1476
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001477 /* Cause IE is needed for PROC_SS_ERR */
1478 if (isvalue(cause)) {
1479 ies := ies & { valueof(ts_GSUP_IE_Cause(valueof(cause))) };
1480 }
1481
1482 /* Mandatory session IEs */
1483 ies := ies & { valueof(ts_GSUP_IE_SessionId(sid)) };
1484 ies := ies & { valueof(ts_GSUP_IE_SessionState(state)) };
1485
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001486 /* Optional SS payload */
1487 if (isvalue(ss)) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001488 ies := ies & { valueof(ts_GSUP_IE_SSInfo(valueof(ss))) };
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001489 }
1490
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001491 if (isvalue(source_name)) {
1492 ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) };
1493 }
1494
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001495 return ies;
1496}
1497private function f_gen_tr_ss_ies(
1498 template hexstring imsi,
1499 template OCT4 sid := ?,
1500 template GSUP_SessionState state := ?,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001501 template octetstring ss := omit,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001502 template integer cause := omit,
1503 template octetstring destination_name := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001504) return template GSUP_IEs {
1505 /* Mandatory IEs */
1506 var template GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001507 tr_GSUP_IE_IMSI(imsi)
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001508 };
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001509 var integer idx := 1;
1510
1511 /* Cause IE is needed for PROC_SS_ERR */
1512 if (istemplatekind(cause, "*")) {
1513 ies[idx] := *;
1514 idx := idx + 1;
1515 } else if (not istemplatekind(cause, "omit")) {
1516 ies[idx] := tr_GSUP_IE_Cause(cause);
1517 idx := idx + 1;
1518 }
1519
1520 /* Mandatory session IEs */
1521 ies[idx] := tr_GSUP_IE_SessionId(sid);
1522 ies[idx + 1] := tr_GSUP_IE_SessionState(state);
1523 idx := idx + 2;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001524
1525 /* Optional SS payload */
1526 if (istemplatekind(ss, "*")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001527 ies[idx] := *;
1528 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001529 } else if (not istemplatekind(ss, "omit")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001530 ies[idx] := tr_GSUP_IE_SSInfo(ss);
1531 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001532 }
1533
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001534 if (isvalue(destination_name)) {
1535 ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
1536 idx := idx + 1;
1537 }
1538
Harald Welte0622a9f2019-05-11 10:58:15 +02001539 /* the GSUP Message Class IE is optional, as old implementations don't have it yet */
1540 var template GSUP_IEs ies2 := ies;
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001541 ies2[idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD);
1542 idx := idx + 1;
Harald Welte0622a9f2019-05-11 10:58:15 +02001543
1544 return (ies, ies2);
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001545}
1546
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001547template (value) GSUP_PDU ts_GSUP_PROC_SS_REQ(
1548 hexstring imsi,
1549 OCT4 sid,
1550 GSUP_SessionState state,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001551 template (omit) octetstring ss := omit,
1552 template (omit) octetstring source_name := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001553) := ts_GSUP(
1554 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001555 f_gen_ts_ss_ies(imsi, sid, state, ss, source_name := source_name)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001556);
1557template GSUP_PDU tr_GSUP_PROC_SS_REQ(
1558 template hexstring imsi,
1559 template OCT4 sid := ?,
1560 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001561 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001562) := tr_GSUP(
1563 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001564 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001565);
1566
1567template (value) GSUP_PDU ts_GSUP_PROC_SS_RES(
1568 hexstring imsi,
1569 OCT4 sid,
1570 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001571 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001572) := ts_GSUP(
1573 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001574 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001575);
1576template GSUP_PDU tr_GSUP_PROC_SS_RES(
1577 template hexstring imsi,
1578 template OCT4 sid := ?,
1579 template GSUP_SessionState state := ?,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001580 template octetstring ss := *,
1581 template octetstring destination_name := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001582) := tr_GSUP(
1583 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001584 f_gen_tr_ss_ies(imsi, sid, state, ss, destination_name := destination_name)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001585);
1586
1587template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR(
1588 hexstring imsi,
1589 OCT4 sid,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001590 GSUP_SessionState state,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001591 integer cause
1592) := ts_GSUP(
1593 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001594 f_gen_ts_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001595);
1596template GSUP_PDU tr_GSUP_PROC_SS_ERR(
1597 template hexstring imsi,
1598 template OCT4 sid := ?,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001599 template GSUP_SessionState state := ?,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001600 template integer cause := ?
1601) := tr_GSUP(
1602 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001603 f_gen_tr_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001604);
Harald Weltedf327232017-12-28 22:51:51 +01001605
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001606template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_REQ(
1607 hexstring imsi,
1608 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1609 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1610 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1611 octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1612) := ts_GSUP(
1613 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1614 {
1615 valueof(ts_GSUP_IE_IMSI(imsi)),
1616 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1617 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1618 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001619 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
1620 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001621 }
1622);
1623template GSUP_PDU tr_GSUP_MO_FORWARD_SM_REQ(
1624 template hexstring imsi := ?,
1625 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1626 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1627 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1628 template octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1629) := tr_GSUP(
1630 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1631 {
1632 tr_GSUP_IE_IMSI(imsi),
1633 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1634 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1635 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001636 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001637 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1638 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001639 }
1640);
1641
1642template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_RES(
1643 hexstring imsi,
1644 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1645) := ts_GSUP(
1646 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1647 {
1648 valueof(ts_GSUP_IE_IMSI(imsi)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001649 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1650 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001651 }
1652);
1653template GSUP_PDU tr_GSUP_MO_FORWARD_SM_RES(
1654 template hexstring imsi := ?,
1655 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1656) := tr_GSUP(
1657 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1658 {
1659 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001660 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001661 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1662 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001663 }
1664);
1665
1666template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_ERR(
1667 hexstring imsi,
1668 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1669 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1670) := ts_GSUP(
1671 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1672 {
1673 valueof(ts_GSUP_IE_IMSI(imsi)),
1674 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001675 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)),
1676 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001677 }
1678);
1679template GSUP_PDU tr_GSUP_MO_FORWARD_SM_ERR(
1680 template hexstring imsi := ?,
1681 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1682 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1683) := tr_GSUP(
1684 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1685 {
1686 tr_GSUP_IE_IMSI(imsi),
1687 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001688 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001689 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1690 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001691 }
1692);
1693
1694template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_REQ(
1695 hexstring imsi,
1696 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1697 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1698 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1699 octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1700 OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1701) := ts_GSUP(
1702 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1703 {
1704 /**
1705 * TODO: add MT-specific fields (and IEs):
1706 * - smDeliveryTimer
1707 * - smDeliveryStartTime
1708 */
1709 valueof(ts_GSUP_IE_IMSI(imsi)),
1710 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1711 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1712 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1713 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001714 valueof(ts_GSUP_IE_SM_RP_MMS(sm_rp_mms)),
1715 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001716 }
1717);
1718template GSUP_PDU tr_GSUP_MT_FORWARD_SM_REQ(
1719 template hexstring imsi := ?,
1720 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1721 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1722 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1723 template octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1724 template OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1725) := tr_GSUP(
1726 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1727 {
1728 /**
1729 * TODO: add MT-specific fields (and IEs):
1730 * - smDeliveryTimer
1731 * - smDeliveryStartTime
1732 */
1733 tr_GSUP_IE_IMSI(imsi),
1734 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1735 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1736 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1737 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001738 tr_GSUP_IE_SM_RP_MMS(sm_rp_mms),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001739 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1740 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001741 }
1742);
1743
1744template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_RES(
1745 hexstring imsi,
1746 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1747) := ts_GSUP(
1748 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1749 {
1750 valueof(ts_GSUP_IE_IMSI(imsi)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001751 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1752 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001753 }
1754);
1755template GSUP_PDU tr_GSUP_MT_FORWARD_SM_RES(
1756 template hexstring imsi := ?,
1757 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1758) := tr_GSUP(
1759 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1760 {
1761 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001762 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001763 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1764 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001765 }
1766);
1767
1768template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_ERR(
1769 hexstring imsi,
1770 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1771 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1772) := ts_GSUP(
1773 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1774 {
1775 valueof(ts_GSUP_IE_IMSI(imsi)),
1776 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001777 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)),
1778 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001779 }
1780);
1781template GSUP_PDU tr_GSUP_MT_FORWARD_SM_ERR(
1782 template hexstring imsi := ?,
1783 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1784 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1785) := tr_GSUP(
1786 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1787 {
1788 tr_GSUP_IE_IMSI(imsi),
1789 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001790 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001791 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1792 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001793 }
1794);
1795
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001796template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_REQ(
1797 hexstring imsi,
1798 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1799 GSUP_SM_ALERT_RSN_Type sm_alert_rsn /* SM Alert Reason, see 7.6.8.8 */
1800) := ts_GSUP(
1801 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1802 {
1803 valueof(ts_GSUP_IE_IMSI(imsi)),
1804 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001805 valueof(ts_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn)),
1806 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001807 }
1808);
1809template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_REQ(
1810 template hexstring imsi := ?,
1811 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1812 template GSUP_SM_ALERT_RSN_Type sm_alert_rsn := ? /* SM Alert Reason, see 7.6.8.8 */
1813) := tr_GSUP(
1814 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1815 {
1816 tr_GSUP_IE_IMSI(imsi),
1817 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001818 tr_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001819 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1820 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001821 }
1822);
1823
1824template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_RES(
1825 hexstring imsi,
1826 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1827) := ts_GSUP(
1828 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1829 {
1830 valueof(ts_GSUP_IE_IMSI(imsi)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001831 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1832 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001833 }
1834);
1835template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_RES(
1836 template hexstring imsi := ?,
1837 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1838) := tr_GSUP(
1839 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1840 {
1841 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001842 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001843 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1844 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001845 }
1846);
1847
1848template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_ERR(
1849 hexstring imsi,
1850 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1851 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1852) := ts_GSUP(
1853 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1854 {
1855 valueof(ts_GSUP_IE_IMSI(imsi)),
1856 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
Vadim Yanitskiy6eb7ac62024-01-09 19:04:46 +07001857 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)),
1858 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001859 }
1860);
1861template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_ERR(
1862 template hexstring imsi := ?,
1863 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1864 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1865) := tr_GSUP(
1866 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1867 {
1868 tr_GSUP_IE_IMSI(imsi),
1869 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001870 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
Vadim Yanitskiy5389e3a2024-01-09 19:18:38 +07001871 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1872 tr_GSUP_IE_Source_Name(?)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001873 }
1874);
1875
Alexander Couzens25d28492023-04-26 19:30:04 +02001876function f_gsup_find_nested_ie_multiple(GSUP_IEs ies, GSUP_IEI iei, integer nth, out GSUP_IeValue ret) return boolean {
1877 var integer current := 0;
1878 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1879 if (ies[i].tag == iei) {
1880 if (current == nth) {
1881 ret := ies[i].val;
1882 return true;
1883 } else {
1884 current := current + 1;
1885 }
1886 }
1887 }
1888 return false;
1889}
1890
Harald Welte8eebb6c2019-08-22 12:40:03 +02001891function f_gsup_find_nested_ie(GSUP_IEs ies, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1892 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1893 if (ies[i].tag == iei) {
1894 ret := ies[i].val;
Harald Weltef9d449e2018-06-24 22:27:47 +02001895 return true;
1896 }
1897 }
Harald Welte8eebb6c2019-08-22 12:40:03 +02001898 return false;
1899}
1900
1901function f_gsup_find_ie(GSUP_PDU msg, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1902 return f_gsup_find_nested_ie(msg.ies, iei, ret);
Harald Weltef9d449e2018-06-24 22:27:47 +02001903}
1904
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001905template GSUP_AN_APDU t_GSUP_AN_APDU(
1906 template GSUP_AN_PROTO an_proto := ?,
1907 template octetstring pdu := ?
1908) := {
1909 proto := an_proto,
1910 pdu := pdu
1911};
1912
1913template GSUP_PDU tr_GSUP_E_AN_APDU(
1914 template GSUP_MessageType msgt,
1915 template hexstring imsi := ?,
1916 template octetstring source_name := ?,
1917 template octetstring destination_name := ?,
1918 template GSUP_AN_APDU an_apdu := ?
1919) := tr_GSUP(
1920 msgt,
1921 {
1922 tr_GSUP_IE_IMSI(imsi),
1923 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1924 tr_GSUP_IE_Source_Name(source_name),
1925 tr_GSUP_IE_Destination_Name(destination_name),
1926 tr_GSUP_IE_AN_APDU(an_apdu)
1927 }
1928);
1929
1930template GSUP_PDU tr_GSUP_E_NO_PDU(
1931 template GSUP_MessageType msgt,
1932 template hexstring imsi := ?,
1933 template octetstring source_name := ?,
1934 template octetstring destination_name := ?
1935) := tr_GSUP(
1936 msgt,
1937 {
1938 tr_GSUP_IE_IMSI(imsi),
1939 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1940 tr_GSUP_IE_Source_Name(source_name),
1941 tr_GSUP_IE_Destination_Name(destination_name)
1942 }
1943);
1944
1945template (value) GSUP_PDU ts_GSUP_E_AN_APDU(
1946 GSUP_MessageType msgt,
1947 hexstring imsi,
1948 octetstring source_name,
1949 octetstring destination_name,
1950 GSUP_AN_APDU an_apdu
1951) := ts_GSUP(
1952 msgt,
1953 {
1954 valueof(ts_GSUP_IE_IMSI(imsi)),
1955 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1956 valueof(ts_GSUP_IE_Source_Name(source_name)),
1957 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1958 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1959 }
1960);
1961
1962template (value) GSUP_PDU ts_GSUP_E_PrepareHandoverResult(
1963 hexstring imsi,
1964 hexstring msisdn,
1965 octetstring source_name,
1966 octetstring destination_name,
1967 GSUP_AN_APDU an_apdu
1968) := ts_GSUP(
1969 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT,
1970 {
1971 valueof(ts_GSUP_IE_IMSI(imsi)),
1972 valueof(ts_GSUP_IE_MSISDN(msisdn)),
1973 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1974 valueof(ts_GSUP_IE_Source_Name(source_name)),
1975 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1976 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1977 }
1978);
Harald Weltef9d449e2018-06-24 22:27:47 +02001979
Harald Weltedf327232017-12-28 22:51:51 +01001980} with { encode "RAW"; variant "FIELDORDER(msb)" }