blob: 818f830cccce5974fb41d17f5d27817680317bd5 [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
382template GSUP_IE ts_GSUP_IE_AuthTuple2G3G(octetstring rand, octetstring sres,
383 octetstring kc, octetstring ik,
384 octetstring ck, octetstring autn,
385 octetstring res) := {
386 tag := OSMO_GSUP_AUTH_TUPLE_IE,
387 len := 0, /* overwritten */
388 val := {
389 auth_tuple := {
390 valueof(ts_GSUP_IE_RAND(rand)),
391 valueof(ts_GSUP_IE_SRES(sres)),
392 valueof(ts_GSUP_IE_Kc(kc)),
393 valueof(ts_GSUP_IE_IK(ik)),
394 valueof(ts_GSUP_IE_CK(ck)),
395 valueof(ts_GSUP_IE_AUTN(autn)),
396 valueof(ts_GSUP_IE_RES(res))
397 }
398 }
399}
400
Harald Welteeded9ad2018-02-17 20:57:34 +0100401template GSUP_IE ts_GSUP_IE_PdpInfo(octetstring apn, octetstring pdp_type, octetstring pdp_qos) := {
402 tag := OSMO_GSUP_PDP_INFO_IE,
403 len := 0, /* overwritten */
404 val := {
405 pdp_info := {
406 valueof(ts_GSUP_IE_APN(apn)),
407 valueof(ts_GSUP_IE_PDP_TYPE(pdp_type)),
408 valueof(ts_GSUP_IE_PDP_QOS(pdp_qos))
409 }
410 }
411}
412
Alexander Couzens25d28492023-04-26 19:30:04 +0200413template (value) GSUP_IE ts_GSUP_IE_PDP_CONTEXT_ID(OCT1 ctx_id) := {
414 tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
415 len := 0,
416 val := {
417 pdp_ctx_id := ctx_id
418 }
419}
420
421template GSUP_IE tr_GSUP_IE_PDP_CONTEXT_ID(template OCT1 ctx_id) := {
422 tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
423 len := ?,
424 val := {
425 pdp_ctx_id := ctx_id
426 }
427}
428
429
Harald Welteeded9ad2018-02-17 20:57:34 +0100430template (value) GSUP_IE ts_GSUP_IE_PDP_TYPE(OCT2 pdp_type) := {
431 tag := OSMO_GSUP_PDP_TYPE_IE,
432 len := 0,
433 val := {
434 pdp_type := pdp_type
435 }
436}
437
438template (value) GSUP_IE ts_GSUP_IE_PDP_QOS(octetstring pdp_qos) := {
439 tag := OSMO_GSUP_PDP_QOS_IE,
440 len := 0,
441 val := {
442 pdp_qos := pdp_qos
443 }
444}
445
446
Harald Weltedf327232017-12-28 22:51:51 +0100447template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
448 msg_type := msgt,
449 ies := ies
450}
451
Harald Welte8a1dd532018-01-27 15:38:18 +0100452template GSUP_PDU tr_GSUP_IMSI(template GSUP_MessageType msgt := ?, template hexstring imsi) := {
453 msg_type := msgt,
454 ies := { tr_GSUP_IE_IMSI(imsi), * }
455}
456
Harald Weltedf327232017-12-28 22:51:51 +0100457template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
458 msg_type := msgt,
459 ies := ies
460}
461
Oliver Smith936dbe62019-06-04 15:54:17 +0200462template (value) GSUP_IMEI ts_GSUP_IMEI(hexstring digits) := {
463 len := 0, /* overwritten */
464 digits := digits
465}
466
467template GSUP_IMEI tr_GSUP_IMEI(template hexstring digits) := {
468 len := ?,
469 digits := digits
470}
471
472
Harald Welte6aa04e32018-01-27 15:35:19 +0100473template (value) GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
Harald Weltedf327232017-12-28 22:51:51 +0100474 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
475
Harald Welte8eebb6c2019-08-22 12:40:03 +0200476template (value) GSUP_PDU ts_GSUP_SAI_REQ_EPS(hexstring imsi) :=
477 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
478 valueof(ts_GSUP_IE_IMSI(imsi)),
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100479 valueof(ts_GSUP_IE_CURRENT_RAT_TYPE(RAT_TYPE_EUTRAN_SGs))
Harald Welte8eebb6c2019-08-22 12:40:03 +0200480 });
481
Alexander Couzens752f86b2020-01-10 07:56:31 +0100482template (value) GSUP_PDU ts_GSUP_SAI_REQ_NUM_AUTH(hexstring imsi, OCT1 num_auth_vectors) :=
483 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
484 valueof(ts_GSUP_IE_IMSI(imsi)),
485 valueof(ts_GSUP_IE_NUM_VECTORS_REQ(num_auth_vectors))
486 });
487
Harald Welteef9fa872018-01-22 03:00:17 +0100488template GSUP_PDU tr_GSUP_SAI_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100489 tr_GSUP_IMSI(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, imsi);
Harald Welteef9fa872018-01-22 03:00:17 +0100490
Alexander Couzensd24973d2018-09-04 16:10:14 +0200491template GSUP_PDU tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC(
492 template hexstring imsi,
493 template octetstring auts,
494 template octetstring rand) :=
495 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
496 tr_GSUP_IE_IMSI(imsi),
497 tr_GSUP_IE_AUTS(auts),
498 tr_GSUP_IE_RAND(rand),
499 *
500 });
501
Harald Welte77a8eba2018-01-22 21:22:32 +0100502template (value) GSUP_PDU ts_GSUP_SAI_RES(hexstring imsi, GSUP_IE auth_tuple) :=
503 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
504 valueof(ts_GSUP_IE_IMSI(imsi)), auth_tuple });
505
Harald Weltedf327232017-12-28 22:51:51 +0100506template GSUP_PDU tr_GSUP_SAI_ERR(template hexstring imsi, template integer cause) :=
Harald Welte071ed732018-01-23 19:53:52 +0100507 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
Harald Weltedf327232017-12-28 22:51:51 +0100508 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
509
Harald Welte6aa04e32018-01-27 15:35:19 +0100510template (value) GSUP_PDU ts_GSUP_SAI_ERR(hexstring imsi, integer cause) :=
511 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
512 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
Harald Welte071ed732018-01-23 19:53:52 +0100513
514
Harald Weltedf327232017-12-28 22:51:51 +0100515template GSUP_PDU tr_GSUP_SAI_RES(template hexstring imsi) :=
Harald Weltec2c52552018-03-01 21:20:39 +0100516 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
Harald Weltedf327232017-12-28 22:51:51 +0100517 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE), * });
518
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100519template GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi, GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS,
520 template octetstring source_name := omit) :=
521 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, f_gen_ts_ies(imsi, dom := dom,
522 source_name := source_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100523
Harald Weltedfe94dd2018-01-21 13:55:22 +0100524template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100525 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, imsi);
Harald Weltedfe94dd2018-01-21 13:55:22 +0100526
Oliver Smith07786da2020-01-29 14:48:19 +0100527template (value) GSUP_PDU ts_GSUP_UL_RES(hexstring imsi, octetstring destination_name := ''O) :=
528 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)),
529 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
Harald Weltedfe94dd2018-01-21 13:55:22 +0100530
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100531template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi, template octetstring destination_name := omit) :=
532 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, f_gen_tr_ies(imsi, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100533
Harald Welte6aa04e32018-01-27 15:35:19 +0100534template (value) GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100535 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
536 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
537
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100538template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?,
539 template octetstring destination_name := omit) :=
540 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR,
541 f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100542
Oliver Smith07786da2020-01-29 14:48:19 +0100543template (value) GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn, octetstring destination_name := ''O) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100544 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
Oliver Smith07786da2020-01-29 14:48:19 +0100545 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)),
546 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
Harald Welte6ff81902018-01-21 19:09:08 +0100547
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100548template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?,
549 template octetstring destination_name := omit) :=
550 tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST,
551 f_gen_tr_ies(imsi, msisdn := msisdn, destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100552
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100553template GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi,
554 template octetstring source_name := omit,
555 template octetstring destination_name := omit) :=
556 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT,
557 f_gen_ts_ies(imsi, source_name := source_name,
558 destination_name := destination_name));
Harald Weltec2c52552018-03-01 21:20:39 +0100559
Harald Welte6ff81902018-01-21 19:09:08 +0100560template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100561 tr_GSUP_IMSI(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100562
Harald Weltec638f4d2018-01-24 22:00:36 +0100563template GSUP_PDU tr_GSUP_AUTH_FAIL_IND(hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100564 tr_GSUP_IMSI(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100565
Harald Welte167458a2018-01-27 15:58:16 +0100566template (value) GSUP_PDU ts_GSUP_CL_REQ(hexstring imsi, GSUP_CancelType ctype) :=
567 ts_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST, {
568 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CancelType(ctype)) });
569
570template GSUP_PDU tr_GSUP_CL_RES(template hexstring imsi) :=
571 tr_GSUP_IMSI(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT, imsi);
572
573template GSUP_PDU tr_GSUP_CL_ERR(template hexstring imsi, template integer cause := ?) :=
574 tr_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR, {
Alexander Couzens4cfff3a2018-05-22 17:08:36 +0200575 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause), * });
Harald Welte167458a2018-01-27 15:58:16 +0100576
Harald Welte958f8b42018-03-01 23:40:17 +0100577template (value) GSUP_PDU ts_GSUP_PURGE_MS_REQ(hexstring imsi, GSUP_CnDomain dom) :=
578 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
579 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CnDomain(dom)) });
580
Harald Welte6abb9fe2018-02-17 15:24:48 +0100581template GSUP_PDU tr_GSUP_PURGE_MS_REQ(template hexstring imsi, template GSUP_CnDomain dom := ?) :=
582 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
583 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_CnDomain(dom) });
584
585template (value) GSUP_PDU ts_GSUP_PURGE_MS_RES(hexstring imsi) :=
586 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
587 valueof(ts_GSUP_IE_IMSI(imsi)) });
588
Harald Welte958f8b42018-03-01 23:40:17 +0100589template GSUP_PDU tr_GSUP_PURGE_MS_RES(template hexstring imsi) :=
590 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
591 tr_GSUP_IE_IMSI(imsi), * });
592
593template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer cause) :=
594 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
595 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
596
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100597template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei,
598 template (omit) octetstring source_name := omit) :=
599 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 +0200600
Oliver Smith1d118ff2019-07-03 10:57:35 +0200601template GSUP_PDU tr_GSUP_CHECK_IMEI_REQ(
602 template hexstring imsi,
603 template hexstring imei
604) := tr_GSUP(
605 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST,
606 {
607 tr_GSUP_IE_IMSI(imsi),
608 tr_GSUP_IE_IMEI(imei),
609 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT)
610 }
611);
612
613template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_RES(hexstring imsi, GSUP_IMEIResult result) :=
614 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
615 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI_Result(result)) });
616
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100617template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result,
618 template octetstring destination_name := omit) :=
619 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT,
620 f_gen_tr_ies(imsi, imei_result := result, destination_name := destination_name));
Oliver Smith936dbe62019-06-04 15:54:17 +0200621
Oliver Smith1d118ff2019-07-03 10:57:35 +0200622template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_ERR(hexstring imsi, integer cause) :=
623 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
624 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
625
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100626template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause,
627 template octetstring destination_name := omit) :=
628 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 +0200629
Harald Welte167458a2018-01-27 15:58:16 +0100630
631template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
632 tag := OSMO_GSUP_CANCEL_TYPE_IE,
633 len := 0, /* overwritten */
634 val := {
635 cancel_type := ctype
636 }
637}
638
639template GSUP_IE tr_GSUP_IE_CancelType(template GSUP_CancelType ctype) :=
640 tr_GSUP_IE(OSMO_GSUP_CANCEL_TYPE_IE, GSUP_IeValue:{cancel_type:=ctype});
641
Harald Welte6abb9fe2018-02-17 15:24:48 +0100642template GSUP_IE tr_GSUP_IE_CnDomain(template GSUP_CnDomain domain) :=
643 tr_GSUP_IE(OSMO_GSUP_CN_DOMAIN_IE, GSUP_IeValue:{cn_domain:=domain});
644
Harald Weltedf327232017-12-28 22:51:51 +0100645template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := {
646 tag := iei,
647 len := ?,
648 val := val
649}
650
651template (value) GSUP_IE ts_GSUP_IE_IMSI(hexstring imsi) := {
652 tag := OSMO_GSUP_IMSI_IE,
653 len := 0, /* overwritten */
654 val := {
655 imsi := imsi
656 }
657}
658
659template GSUP_IE tr_GSUP_IE_IMSI(template hexstring imsi) := {
660 tag := OSMO_GSUP_IMSI_IE,
661 len := ?,
662 val := {
663 imsi := imsi
664 }
665}
666
Harald Welte6ff81902018-01-21 19:09:08 +0100667template (value) GSUP_IE ts_GSUP_IE_MSISDN(hexstring msisdn) := {
668 tag := OSMO_GSUP_MSISDN_IE,
669 len := 0, /* overwritten */
670 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100671 msisdn := ts_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100672 }
673}
674
675template GSUP_IE tr_GSUP_IE_MSISDN(template hexstring msisdn) := {
676 tag := OSMO_GSUP_MSISDN_IE,
677 len := ?,
678 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100679 msisdn := tr_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100680 }
681}
682
683
Harald Weltedf327232017-12-28 22:51:51 +0100684template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := {
685 tag := OSMO_GSUP_CAUSE_IE,
686 len := 0, /* overwritten */
687 val := {
688 cause := cause
689 }
690}
691
692template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := {
693 tag := OSMO_GSUP_CAUSE_IE,
694 len := ?,
695 val := {
696 cause := cause
697 }
698}
699
700template (value) GSUP_IE ts_GSUP_IE_AUTS(octetstring auts) := {
701 tag := OSMO_GSUP_AUTS_IE,
702 len := 0, /* overwritten */
703 val := {
704 auts := auts
705 }
706}
707
Alexander Couzensd24973d2018-09-04 16:10:14 +0200708template GSUP_IE tr_GSUP_IE_AUTS(template octetstring auts) := {
709 tag := OSMO_GSUP_AUTS_IE,
710 len := ?,
711 val := {
712 auts := auts
713 }
714}
715
Harald Weltedf327232017-12-28 22:51:51 +0100716template (value) GSUP_IE ts_GSUP_IE_RAND(octetstring rand) := {
717 tag := OSMO_GSUP_RAND_IE,
718 len := 0, /* overwritten */
719 val := {
720 rand := rand
721 }
722}
723
Alexander Couzensd24973d2018-09-04 16:10:14 +0200724template GSUP_IE tr_GSUP_IE_RAND(template octetstring rand) := {
725 tag := OSMO_GSUP_RAND_IE,
726 len := ?,
727 val := {
728 rand := rand
729 }
730}
731
Harald Welte77a8eba2018-01-22 21:22:32 +0100732template (value) GSUP_IE ts_GSUP_IE_SRES(octetstring sres) := {
733 tag := OSMO_GSUP_SRES_IE,
734 len := 0, /* overwritten */
735 val := {
736 sres := sres
737 }
738}
739
740template (value) GSUP_IE ts_GSUP_IE_Kc(octetstring kc) := {
741 tag := OSMO_GSUP_KC_IE,
742 len := 0, /* overwritten */
743 val := {
744 kc := kc
745 }
746}
747
748template (value) GSUP_IE ts_GSUP_IE_IK(octetstring ik) := {
749 tag := OSMO_GSUP_IK_IE,
750 len := 0, /* overwritten */
751 val := {
752 ik := ik
753 }
754}
755
756template (value) GSUP_IE ts_GSUP_IE_CK(octetstring ck) := {
757 tag := OSMO_GSUP_CK_IE,
758 len := 0, /* overwritten */
759 val := {
760 ck := ck
761 }
762}
763
764template (value) GSUP_IE ts_GSUP_IE_AUTN(octetstring autn) := {
765 tag := OSMO_GSUP_AUTN_IE,
766 len := 0, /* overwritten */
767 val := {
768 autn := autn
769 }
770}
771
772template (value) GSUP_IE ts_GSUP_IE_RES(octetstring res) := {
773 tag := OSMO_GSUP_RES_IE,
774 len := 0, /* overwritten */
775 val := {
776 res := res
777 }
778}
Harald Weltedf327232017-12-28 22:51:51 +0100779
Harald Welteeded9ad2018-02-17 20:57:34 +0100780template (value) GSUP_IE ts_GSUP_IE_APN(octetstring apn) := {
781 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
782 len := 0, /* overwritten */
783 val := {
784 apn := apn
785 }
786}
787
Alexander Couzens25d28492023-04-26 19:30:04 +0200788template GSUP_IE tr_GSUP_IE_APN(template octetstring apn) := {
789 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
790 len := ?,
791 val := {
792 apn := apn
793 }
794}
795
Neels Hofmeyrb2168512019-11-11 03:40:26 +0100796template GSUP_IE ts_GSUP_IE_CnDomain(template GSUP_CnDomain dom) := {
Harald Welte958f8b42018-03-01 23:40:17 +0100797 tag := OSMO_GSUP_CN_DOMAIN_IE,
798 len := 0, /* overwritten */
799 val := {
800 cn_domain := dom
801 }
802}
Harald Weltedf327232017-12-28 22:51:51 +0100803
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700804template (value) GSUP_IE ts_GSUP_IE_SessionId(OCT4 sid) := {
805 tag := OSMO_GSUP_SESSION_ID_IE,
806 len := 0, /* overwritten */
807 val := {
808 session_id := sid
809 }
810}
811template GSUP_IE tr_GSUP_IE_SessionId(template OCT4 sid) := {
812 tag := OSMO_GSUP_SESSION_ID_IE,
813 len := ?,
814 val := {
815 session_id := sid
816 }
817}
818
819template (value) GSUP_IE ts_GSUP_IE_SessionState(GSUP_SessionState state) := {
820 tag := OSMO_GSUP_SESSION_STATE_IE,
821 len := 0, /* overwritten */
822 val := {
823 session_state := state
824 }
825}
826template GSUP_IE tr_GSUP_IE_SessionState(template GSUP_SessionState state) := {
827 tag := OSMO_GSUP_SESSION_STATE_IE,
828 len := ?,
829 val := {
830 session_state := state
831 }
832}
833
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700834template (value) GSUP_IE ts_GSUP_IE_SM_RP_MR(OCT1 ref) := {
835 tag := OSMO_GSUP_SM_RP_MR_IE,
836 len := 0, /* overwritten */
837 val := {
838 sm_rp_mr := ref
839 }
840}
841template GSUP_IE tr_GSUP_IE_SM_RP_MR(template OCT1 ref) := {
842 tag := OSMO_GSUP_SM_RP_MR_IE,
843 len := ?,
844 val := {
845 sm_rp_mr := ref
846 }
847}
848
849template (value) GSUP_IE ts_GSUP_IE_SM_RP_CAUSE(OCT1 cause) := {
850 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
851 len := 0, /* overwritten */
852 val := {
853 sm_rp_cause := cause
854 }
855}
856template GSUP_IE tr_GSUP_IE_SM_RP_CAUSE(template OCT1 cause) := {
857 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
858 len := ?,
859 val := {
860 sm_rp_cause := cause
861 }
862}
863
864template (value) GSUP_IE ts_GSUP_IE_SM_RP_MMS(OCT1 mms) := {
865 tag := OSMO_GSUP_SM_RP_MMS_IE,
866 len := 0, /* overwritten */
867 val := {
868 sm_rp_mms := mms
869 }
870}
871template GSUP_IE tr_GSUP_IE_SM_RP_MMS(template OCT1 mms) := {
872 tag := OSMO_GSUP_SM_RP_MMS_IE,
873 len := ?,
874 val := {
875 sm_rp_mms := mms
876 }
877}
878
Oliver Smith936dbe62019-06-04 15:54:17 +0200879template (value) GSUP_IE ts_GSUP_IE_IMEI(hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100880 tag := OSMO_GSUP_IMEI_IE,
881 len := 0, /* overwritten */
882 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +0200883 imei := ts_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +0100884 }
885}
Oliver Smith936dbe62019-06-04 15:54:17 +0200886template GSUP_IE tr_GSUP_IE_IMEI(template hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100887 tag := OSMO_GSUP_IMEI_IE,
888 len := ?,
889 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +0200890 imei := tr_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +0100891 }
892}
893
Oliver Smith936dbe62019-06-04 15:54:17 +0200894template (value) GSUP_IE ts_GSUP_IE_IMEI_Result(GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100895 tag := OSMO_GSUP_IMEI_RESULT_IE,
896 len := 0, /* overwritten */
897 val := {
898 imei_result := result
899 }
900}
Oliver Smith936dbe62019-06-04 15:54:17 +0200901template GSUP_IE tr_GSUP_IE_IMEI_Result(template GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100902 tag := OSMO_GSUP_IMEI_RESULT_IE,
903 len := ?,
904 val := {
905 imei_result := result
906 }
907}
908
Alexander Couzens752f86b2020-01-10 07:56:31 +0100909template (value) GSUP_IE ts_GSUP_IE_NUM_VECTORS_REQ(OCT1 num) := {
910 tag := OSMO_GSUP_NUM_VECTORS_REQ_IE,
911 len := 0, /* overwritten */
912 val := {
913 num_auth_vectors := num
914 }
915}
916template GSUP_IE tr_GSUP_IE_NUM_VECTORS_REQ(template OCT1 num) := {
917 tag := OSMO_GSUP_NUM_VECTORS_REQ_IE,
918 len := ?,
919 val := {
920 num_auth_vectors := num
921 }
922}
923
924
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700925/* Possible identity types for SM-RP-{OA|DA} IEs */
926type enumerated GSUP_SM_RP_ODA_IdType {
927 OSMO_GSUP_SM_RP_ODA_ID_NONE ('00'O),
928 OSMO_GSUP_SM_RP_ODA_ID_IMSI ('01'O),
929 OSMO_GSUP_SM_RP_ODA_ID_MSISDN ('02'O),
930 OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR ('03'O),
931 /* Special value for noSM-RP-DA and noSM-RP-OA */
932 OSMO_GSUP_SM_RP_ODA_ID_NULL ('FF'O)
933} with { variant "FIELDLENGTH(8)" };
934
Vadim Yanitskiya52347c2019-12-12 17:32:33 +0900935/* See 3GPP TS 24.011, figures 8.5 and 8.6 */
936type record GSUP_SM_RP_Addr {
937 BIT1 ext, /* Extension? */
938 BIT3 ton, /* Type of Number */
939 BIT4 npi, /* Numbering Plan Identification */
940 hexstring number length (1..20)
941} with {
942 variant "PADDING(yes)";
943 variant "PADDING_PATTERN('1111'B)"
944};
945
946private function f_pad_SM_RP_Addr(template hexstring number)
947return template hexstring {
948 if (isvalue(number) and not istemplatekind(number, "omit")) {
949 return f_pad_bcd_number(valueof(number));
950 } else {
951 return number;
952 }
953}
954
955template GSUP_SM_RP_Addr t_GSUP_SM_RP_Addr(template hexstring number,
956 template BIT4 npi := '0001'B,
957 template BIT3 ton := '001'B,
958 template BIT1 ext := '1'B) := {
959 ext := ext,
960 ton := ton,
961 npi := npi,
962 /* Work around TITAN's padding problems: encoding works fine,
963 * but it does not consider 'F'H as padding in decoded data. */
964 number := f_pad_SM_RP_Addr(number)
965}
966
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700967/**
968 * SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
969 * It can be either of the following:
970 * - IMSI
971 * - LMSI (not implemented)
972 * - MSISDN
973 * - roaming number (not implemented)
974 * - service centre address
975 */
976type union GSUP_SM_RP_DA_ID {
Vadim Yanitskiya52347c2019-12-12 17:32:33 +0900977 hexstring imsi,
978 GSUP_SM_RP_Addr msisdn,
979 GSUP_SM_RP_Addr smsc_addr
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700980};
981
982type record GSUP_SM_RP_DA {
983 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700984 GSUP_SM_RP_DA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +0700985} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700986 imsi, id_type = OSMO_GSUP_SM_RP_ODA_ID_IMSI;
987 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
988 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
989 /* FIXME: how to handle noSM-RP-DA? */
990 )"
991};
992
993template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_IMSI(hexstring imsi) := {
994 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700995 id_enc := { imsi := imsi }
996}
997template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_IMSI(template hexstring imsi) := {
998 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700999 id_enc := { imsi := imsi }
1000}
1001
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001002template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001003 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001004 id_enc := { msisdn := msisdn }
1005}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001006template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001007 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001008 id_enc := { msisdn := msisdn }
1009}
1010
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001011template (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 +07001012 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001013 id_enc := { smsc_addr := smsc_addr }
1014}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001015template 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 +07001016 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001017 id_enc := { smsc_addr := smsc_addr }
1018}
1019
1020template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_NULL := {
1021 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001022 id_enc := omit
1023}
1024template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_NULL := {
1025 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001026 id_enc := omit
1027}
1028
1029template (value) GSUP_IE ts_GSUP_IE_SM_RP_DA(GSUP_SM_RP_DA val) := {
1030 tag := OSMO_GSUP_SM_RP_DA_IE,
1031 len := 0, /* overwritten */
1032 val := {
1033 sm_rp_da := val
1034 }
1035}
1036template GSUP_IE tr_GSUP_IE_SM_RP_DA(template GSUP_SM_RP_DA val) := {
1037 tag := OSMO_GSUP_SM_RP_DA_IE,
1038 len := ?,
1039 val := {
1040 sm_rp_da := val
1041 }
1042}
1043
1044/**
1045 * SM-RP-OA represents the SM Originating Address, see 7.6.8.2.
1046 * It can be either of the following:
1047 * - MSISDN
1048 * - service centre address
1049 */
1050type union GSUP_SM_RP_OA_ID {
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001051 GSUP_SM_RP_Addr msisdn,
1052 GSUP_SM_RP_Addr smsc_addr
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001053};
1054
1055type record GSUP_SM_RP_OA {
1056 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001057 GSUP_SM_RP_OA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +07001058} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001059 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
1060 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
1061 /* FIXME: how to handle noSM-RP-OA? */
1062 )"
1063};
1064
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001065template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001066 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001067 id_enc := { msisdn := msisdn }
1068}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001069template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001070 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001071 id_enc := { msisdn := msisdn }
1072}
1073
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001074template (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 +07001075 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001076 id_enc := { smsc_addr := smsc_addr }
1077}
Vadim Yanitskiya52347c2019-12-12 17:32:33 +09001078template 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 +07001079 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001080 id_enc := { smsc_addr := smsc_addr }
1081}
1082
1083template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_NULL := {
1084 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001085 id_enc := omit
1086}
1087template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_NULL := {
1088 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001089 id_enc := omit
1090}
1091
1092template (value) GSUP_IE ts_GSUP_IE_SM_RP_OA(GSUP_SM_RP_OA val) := {
1093 tag := OSMO_GSUP_SM_RP_OA_IE,
1094 len := 0, /* overwritten */
1095 val := {
1096 sm_rp_oa := val
1097 }
1098}
1099template GSUP_IE tr_GSUP_IE_SM_RP_OA(template GSUP_SM_RP_OA val) := {
1100 tag := OSMO_GSUP_SM_RP_OA_IE,
1101 len := ?,
1102 val := {
1103 sm_rp_oa := val
1104 }
1105}
1106
1107/* SM-RP-UI represents the SM TPDU, see 7.6.8.4 */
1108template (value) GSUP_IE ts_GSUP_IE_SM_RP_UI(octetstring val) := {
1109 tag := OSMO_GSUP_SM_RP_UI_IE,
1110 len := 0, /* overwritten */
1111 val := {
1112 sm_rp_ui := val
1113 }
1114}
1115template GSUP_IE tr_GSUP_IE_SM_RP_UI(template octetstring val) := {
1116 tag := OSMO_GSUP_SM_RP_UI_IE,
1117 len := ?,
1118 val := {
1119 sm_rp_ui := val
1120 }
1121}
1122
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001123/* SM Alert Reason types, see 7.6.8.8 */
1124type enumerated GSUP_SM_ALERT_RSN_Type {
1125 GSUP_SM_ALERT_RSN_TYPE_NONE ('00'O),
1126 GSUP_SM_ALERT_RSN_TYPE_MS_PRESENT ('01'O),
1127 GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL ('02'O)
1128} with { variant "FIELDLENGTH(8)" };
1129
1130/* SM Alert Reason IE (used in READY-FOR-SM), see 7.6.8.8 */
1131template (value) GSUP_IE ts_GSUP_IE_SM_ALERT_RSN(GSUP_SM_ALERT_RSN_Type rsn) := {
1132 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1133 len := 0, /* overwritten */
1134 val := {
1135 sm_alert_rsn := rsn
1136 }
1137}
1138template GSUP_IE tr_GSUP_IE_SM_ALERT_RSN(template GSUP_SM_ALERT_RSN_Type rsn) := {
1139 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1140 len := ?,
1141 val := {
1142 sm_alert_rsn := rsn
1143 }
1144}
1145
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001146template (value) GSUP_IE ts_GSUP_IE_SSInfo(octetstring ss) := {
1147 tag := OSMO_GSUP_SS_INFO_IE,
1148 len := 0, /* overwritten */
1149 val := {
1150 ss_info := ss
1151 }
1152}
1153template GSUP_IE tr_GSUP_IE_SSInfo(template octetstring ss) := {
1154 tag := OSMO_GSUP_SS_INFO_IE,
1155 len := ?,
1156 val := {
1157 ss_info := ss
1158 }
1159}
1160
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001161template GSUP_IE tr_GSUP_IE_Message_Class(template GSUP_Message_Class val) := {
1162 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1163 len := ?,
1164 val := {
1165 message_class := val
1166 }
1167}
1168
1169template (value) GSUP_IE ts_GSUP_IE_Message_Class(GSUP_Message_Class val) := {
1170 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1171 len := 0, /* overwritten */
1172 val := {
1173 message_class := val
1174 }
1175}
1176
1177template GSUP_IE tr_GSUP_IE_Source_Name(template octetstring name) := {
1178 tag := OSMO_GSUP_SOURCE_NAME_IE,
1179 len := ?,
1180 val := {
1181 source_name := name
1182 }
1183}
1184
1185template (value) GSUP_IE ts_GSUP_IE_Source_Name(octetstring name) := {
1186 tag := OSMO_GSUP_SOURCE_NAME_IE,
1187 len := 0, /* overwritten */
1188 val := {
1189 source_name := name
1190 }
1191}
1192
1193template GSUP_IE tr_GSUP_IE_Destination_Name(template octetstring name) := {
1194 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1195 len := ?,
1196 val := {
1197 destination_name := name
1198 }
1199}
1200
1201template (value) GSUP_IE ts_GSUP_IE_Destination_Name(octetstring name) := {
1202 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1203 len := 0, /* overwritten */
1204 val := {
1205 destination_name := name
1206 }
1207}
1208
1209template GSUP_IE tr_GSUP_IE_AN_APDU(template GSUP_AN_APDU an_apdu) := {
1210 tag := OSMO_GSUP_AN_APDU_IE,
1211 len := ?,
1212 val := {
1213 an_apdu := an_apdu
1214 }
1215}
1216
1217template (value) GSUP_IE ts_GSUP_IE_AN_APDU(GSUP_AN_APDU an_apdu) := {
1218 tag := OSMO_GSUP_AN_APDU_IE,
1219 len := 0, /* overwritten */
1220 val := {
1221 an_apdu := an_apdu
1222 }
1223}
1224
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001225template (present) GSUP_IE tr_GSUP_IE_SUPPORTED_RAT_TYPES(template (present) GSUP_RatTypes ratt) := {
1226 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
Harald Welte8eebb6c2019-08-22 12:40:03 +02001227 len := ?,
1228 val := {
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001229 supported_rat_types := ratt
Harald Welte8eebb6c2019-08-22 12:40:03 +02001230 }
1231}
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001232template (value) GSUP_IE ts_GSUP_IE_SUPPORTED_RAT_TYPES(GSUP_RatTypes ratt) := {
1233 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
Harald Welte8eebb6c2019-08-22 12:40:03 +02001234 len := 0, /* overwritten */
1235 val := {
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001236 supported_rat_types := ratt
1237 }
1238}
1239
1240template (present) GSUP_IE tr_GSUP_IE_CURRENT_RAT_TYPE(template (present) GSUP_RatType ratt) := {
1241 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1242 len := ?,
1243 val := {
1244 current_rat_type := ratt
1245 }
1246}
1247template (value) GSUP_IE ts_GSUP_IE_CURRENT_RAT_TYPE(GSUP_RatType ratt) := {
1248 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1249 len := 0, /* overwritten */
1250 val := {
1251 current_rat_type := ratt
Harald Welte8eebb6c2019-08-22 12:40:03 +02001252 }
1253}
1254
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001255private function f_gen_ts_ies(hexstring imsi,
1256 template hexstring imei := omit,
1257 template GSUP_CnDomain dom := omit,
1258 template octetstring source_name := omit,
1259 template octetstring destination_name := omit
1260 ) return GSUP_IEs {
1261 var GSUP_IEs ies := {
1262 valueof(ts_GSUP_IE_IMSI(imsi))
1263 };
1264
1265 if (isvalue(dom)) {
1266 ies := ies & { valueof(ts_GSUP_IE_CnDomain(dom)) };
1267 }
1268
1269 if (isvalue(imei)) {
1270 ies := ies & { valueof(ts_GSUP_IE_IMEI(valueof(imei))) };
1271 }
1272
1273 if (isvalue(source_name)) {
1274 ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) };
1275 }
1276
1277 if (isvalue(destination_name)) {
1278 ies := ies & { valueof(ts_GSUP_IE_Destination_Name(valueof(destination_name))) };
1279 }
1280
1281 return ies;
1282}
1283
1284private function f_gen_tr_ies(template hexstring imsi,
1285 template integer cause := omit,
1286 template hexstring msisdn := omit,
1287 template GSUP_IMEIResult imei_result := omit,
1288 template octetstring source_name := omit,
1289 template octetstring destination_name := omit
1290 ) return template GSUP_IEs {
1291 var template GSUP_IEs ies := {
1292 tr_GSUP_IE_IMSI(imsi)
1293 };
1294 var integer idx := 1;
1295
1296 if (isvalue(cause)) {
1297 ies[idx] := tr_GSUP_IE_Cause(cause);
1298 idx := idx + 1;
1299 }
1300
1301 if (isvalue(msisdn)) {
1302 ies[idx] := tr_GSUP_IE_MSISDN(msisdn);
1303 idx := idx + 1;
1304 }
1305
1306 if (isvalue(imei_result)) {
1307 ies[idx] := tr_GSUP_IE_IMEI_Result(imei_result);
1308 idx := idx + 1;
1309 }
1310
1311 if (isvalue(source_name)) {
1312 ies[idx] := tr_GSUP_IE_Source_Name(source_name);
1313 idx := idx + 1;
1314 }
1315
1316 ies[idx] := *;
1317 idx := idx + 1;
1318
1319 if (isvalue(destination_name)) {
1320 ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
1321 idx := idx + 1;
1322 }
1323
1324 return ies;
1325}
Harald Welte8eebb6c2019-08-22 12:40:03 +02001326
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001327private function f_gen_ts_ss_ies(
1328 hexstring imsi,
1329 OCT4 sid,
1330 GSUP_SessionState state,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001331 template (omit) octetstring ss := omit,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001332 template (omit) integer cause := omit,
1333 template octetstring source_name := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001334) return GSUP_IEs {
1335 /* Mandatory IEs */
1336 var GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001337 valueof(ts_GSUP_IE_IMSI(imsi))
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001338 };
1339
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001340 /* Cause IE is needed for PROC_SS_ERR */
1341 if (isvalue(cause)) {
1342 ies := ies & { valueof(ts_GSUP_IE_Cause(valueof(cause))) };
1343 }
1344
1345 /* Mandatory session IEs */
1346 ies := ies & { valueof(ts_GSUP_IE_SessionId(sid)) };
1347 ies := ies & { valueof(ts_GSUP_IE_SessionState(state)) };
1348
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001349 /* Optional SS payload */
1350 if (isvalue(ss)) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001351 ies := ies & { valueof(ts_GSUP_IE_SSInfo(valueof(ss))) };
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001352 }
1353
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001354 if (isvalue(source_name)) {
1355 ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) };
1356 }
1357
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001358 return ies;
1359}
1360private function f_gen_tr_ss_ies(
1361 template hexstring imsi,
1362 template OCT4 sid := ?,
1363 template GSUP_SessionState state := ?,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001364 template octetstring ss := omit,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001365 template integer cause := omit,
1366 template octetstring destination_name := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001367) return template GSUP_IEs {
1368 /* Mandatory IEs */
1369 var template GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001370 tr_GSUP_IE_IMSI(imsi)
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001371 };
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001372 var integer idx := 1;
1373
1374 /* Cause IE is needed for PROC_SS_ERR */
1375 if (istemplatekind(cause, "*")) {
1376 ies[idx] := *;
1377 idx := idx + 1;
1378 } else if (not istemplatekind(cause, "omit")) {
1379 ies[idx] := tr_GSUP_IE_Cause(cause);
1380 idx := idx + 1;
1381 }
1382
1383 /* Mandatory session IEs */
1384 ies[idx] := tr_GSUP_IE_SessionId(sid);
1385 ies[idx + 1] := tr_GSUP_IE_SessionState(state);
1386 idx := idx + 2;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001387
1388 /* Optional SS payload */
1389 if (istemplatekind(ss, "*")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001390 ies[idx] := *;
1391 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001392 } else if (not istemplatekind(ss, "omit")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001393 ies[idx] := tr_GSUP_IE_SSInfo(ss);
1394 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001395 }
1396
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001397 if (isvalue(destination_name)) {
1398 ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
1399 idx := idx + 1;
1400 }
1401
Harald Welte0622a9f2019-05-11 10:58:15 +02001402 /* the GSUP Message Class IE is optional, as old implementations don't have it yet */
1403 var template GSUP_IEs ies2 := ies;
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001404 ies2[idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD);
1405 idx := idx + 1;
Harald Welte0622a9f2019-05-11 10:58:15 +02001406
1407 return (ies, ies2);
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001408}
1409
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001410template (value) GSUP_PDU ts_GSUP_PROC_SS_REQ(
1411 hexstring imsi,
1412 OCT4 sid,
1413 GSUP_SessionState state,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001414 template (omit) octetstring ss := omit,
1415 template (omit) octetstring source_name := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001416) := ts_GSUP(
1417 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001418 f_gen_ts_ss_ies(imsi, sid, state, ss, source_name := source_name)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001419);
1420template GSUP_PDU tr_GSUP_PROC_SS_REQ(
1421 template hexstring imsi,
1422 template OCT4 sid := ?,
1423 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001424 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001425) := tr_GSUP(
1426 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001427 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001428);
1429
1430template (value) GSUP_PDU ts_GSUP_PROC_SS_RES(
1431 hexstring imsi,
1432 OCT4 sid,
1433 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001434 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001435) := ts_GSUP(
1436 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001437 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001438);
1439template GSUP_PDU tr_GSUP_PROC_SS_RES(
1440 template hexstring imsi,
1441 template OCT4 sid := ?,
1442 template GSUP_SessionState state := ?,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001443 template octetstring ss := *,
1444 template octetstring destination_name := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001445) := tr_GSUP(
1446 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Neels Hofmeyrb2168512019-11-11 03:40:26 +01001447 f_gen_tr_ss_ies(imsi, sid, state, ss, destination_name := destination_name)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001448);
1449
1450template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR(
1451 hexstring imsi,
1452 OCT4 sid,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001453 GSUP_SessionState state,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001454 integer cause
1455) := ts_GSUP(
1456 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001457 f_gen_ts_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001458);
1459template GSUP_PDU tr_GSUP_PROC_SS_ERR(
1460 template hexstring imsi,
1461 template OCT4 sid := ?,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001462 template GSUP_SessionState state := ?,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001463 template integer cause := ?
1464) := tr_GSUP(
1465 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001466 f_gen_tr_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001467);
Harald Weltedf327232017-12-28 22:51:51 +01001468
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001469template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_REQ(
1470 hexstring imsi,
1471 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1472 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1473 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1474 octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1475) := ts_GSUP(
1476 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1477 {
1478 valueof(ts_GSUP_IE_IMSI(imsi)),
1479 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1480 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1481 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1482 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui))
1483 }
1484);
1485template GSUP_PDU tr_GSUP_MO_FORWARD_SM_REQ(
1486 template hexstring imsi := ?,
1487 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1488 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1489 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1490 template octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1491) := tr_GSUP(
1492 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1493 {
1494 tr_GSUP_IE_IMSI(imsi),
1495 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1496 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1497 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001498 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
1499 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001500 }
1501);
1502
1503template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_RES(
1504 hexstring imsi,
1505 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1506) := ts_GSUP(
1507 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1508 {
1509 valueof(ts_GSUP_IE_IMSI(imsi)),
1510 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1511 }
1512);
1513template GSUP_PDU tr_GSUP_MO_FORWARD_SM_RES(
1514 template hexstring imsi := ?,
1515 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1516) := tr_GSUP(
1517 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1518 {
1519 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001520 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1521 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001522 }
1523);
1524
1525template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_ERR(
1526 hexstring imsi,
1527 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1528 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1529) := ts_GSUP(
1530 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1531 {
1532 valueof(ts_GSUP_IE_IMSI(imsi)),
1533 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1534 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1535 }
1536);
1537template GSUP_PDU tr_GSUP_MO_FORWARD_SM_ERR(
1538 template hexstring imsi := ?,
1539 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1540 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1541) := tr_GSUP(
1542 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1543 {
1544 tr_GSUP_IE_IMSI(imsi),
1545 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001546 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1547 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001548 }
1549);
1550
1551template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_REQ(
1552 hexstring imsi,
1553 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1554 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1555 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1556 octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1557 OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1558) := ts_GSUP(
1559 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1560 {
1561 /**
1562 * TODO: add MT-specific fields (and IEs):
1563 * - smDeliveryTimer
1564 * - smDeliveryStartTime
1565 */
1566 valueof(ts_GSUP_IE_IMSI(imsi)),
1567 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1568 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1569 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1570 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
1571 valueof(ts_GSUP_IE_SM_RP_MMS(sm_rp_mms))
1572 }
1573);
1574template GSUP_PDU tr_GSUP_MT_FORWARD_SM_REQ(
1575 template hexstring imsi := ?,
1576 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1577 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1578 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1579 template octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1580 template OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1581) := tr_GSUP(
1582 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1583 {
1584 /**
1585 * TODO: add MT-specific fields (and IEs):
1586 * - smDeliveryTimer
1587 * - smDeliveryStartTime
1588 */
1589 tr_GSUP_IE_IMSI(imsi),
1590 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1591 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1592 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1593 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001594 tr_GSUP_IE_SM_RP_MMS(sm_rp_mms),
1595 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001596 }
1597);
1598
1599template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_RES(
1600 hexstring imsi,
1601 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1602) := ts_GSUP(
1603 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1604 {
1605 valueof(ts_GSUP_IE_IMSI(imsi)),
1606 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1607 }
1608);
1609template GSUP_PDU tr_GSUP_MT_FORWARD_SM_RES(
1610 template hexstring imsi := ?,
1611 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1612) := tr_GSUP(
1613 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1614 {
1615 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001616 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1617 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001618 }
1619);
1620
1621template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_ERR(
1622 hexstring imsi,
1623 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1624 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1625) := ts_GSUP(
1626 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1627 {
1628 valueof(ts_GSUP_IE_IMSI(imsi)),
1629 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1630 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1631 }
1632);
1633template GSUP_PDU tr_GSUP_MT_FORWARD_SM_ERR(
1634 template hexstring imsi := ?,
1635 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1636 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1637) := tr_GSUP(
1638 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1639 {
1640 tr_GSUP_IE_IMSI(imsi),
1641 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001642 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1643 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001644 }
1645);
1646
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001647template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_REQ(
1648 hexstring imsi,
1649 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1650 GSUP_SM_ALERT_RSN_Type sm_alert_rsn /* SM Alert Reason, see 7.6.8.8 */
1651) := ts_GSUP(
1652 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1653 {
1654 valueof(ts_GSUP_IE_IMSI(imsi)),
1655 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1656 valueof(ts_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn))
1657 }
1658);
1659template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_REQ(
1660 template hexstring imsi := ?,
1661 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1662 template GSUP_SM_ALERT_RSN_Type sm_alert_rsn := ? /* SM Alert Reason, see 7.6.8.8 */
1663) := tr_GSUP(
1664 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1665 {
1666 tr_GSUP_IE_IMSI(imsi),
1667 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001668 tr_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn),
1669 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001670 }
1671);
1672
1673template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_RES(
1674 hexstring imsi,
1675 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1676) := ts_GSUP(
1677 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1678 {
1679 valueof(ts_GSUP_IE_IMSI(imsi)),
1680 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1681 }
1682);
1683template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_RES(
1684 template hexstring imsi := ?,
1685 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1686) := tr_GSUP(
1687 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1688 {
1689 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001690 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1691 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001692 }
1693);
1694
1695template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_ERR(
1696 hexstring imsi,
1697 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1698 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1699) := ts_GSUP(
1700 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1701 {
1702 valueof(ts_GSUP_IE_IMSI(imsi)),
1703 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1704 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1705 }
1706);
1707template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_ERR(
1708 template hexstring imsi := ?,
1709 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1710 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1711) := tr_GSUP(
1712 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1713 {
1714 tr_GSUP_IE_IMSI(imsi),
1715 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001716 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1717 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001718 }
1719);
1720
Alexander Couzens25d28492023-04-26 19:30:04 +02001721function f_gsup_find_nested_ie_multiple(GSUP_IEs ies, GSUP_IEI iei, integer nth, out GSUP_IeValue ret) return boolean {
1722 var integer current := 0;
1723 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1724 if (ies[i].tag == iei) {
1725 if (current == nth) {
1726 ret := ies[i].val;
1727 return true;
1728 } else {
1729 current := current + 1;
1730 }
1731 }
1732 }
1733 return false;
1734}
1735
Harald Welte8eebb6c2019-08-22 12:40:03 +02001736function f_gsup_find_nested_ie(GSUP_IEs ies, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1737 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1738 if (ies[i].tag == iei) {
1739 ret := ies[i].val;
Harald Weltef9d449e2018-06-24 22:27:47 +02001740 return true;
1741 }
1742 }
Harald Welte8eebb6c2019-08-22 12:40:03 +02001743 return false;
1744}
1745
1746function f_gsup_find_ie(GSUP_PDU msg, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1747 return f_gsup_find_nested_ie(msg.ies, iei, ret);
Harald Weltef9d449e2018-06-24 22:27:47 +02001748}
1749
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001750template GSUP_AN_APDU t_GSUP_AN_APDU(
1751 template GSUP_AN_PROTO an_proto := ?,
1752 template octetstring pdu := ?
1753) := {
1754 proto := an_proto,
1755 pdu := pdu
1756};
1757
1758template GSUP_PDU tr_GSUP_E_AN_APDU(
1759 template GSUP_MessageType msgt,
1760 template hexstring imsi := ?,
1761 template octetstring source_name := ?,
1762 template octetstring destination_name := ?,
1763 template GSUP_AN_APDU an_apdu := ?
1764) := tr_GSUP(
1765 msgt,
1766 {
1767 tr_GSUP_IE_IMSI(imsi),
1768 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1769 tr_GSUP_IE_Source_Name(source_name),
1770 tr_GSUP_IE_Destination_Name(destination_name),
1771 tr_GSUP_IE_AN_APDU(an_apdu)
1772 }
1773);
1774
1775template GSUP_PDU tr_GSUP_E_NO_PDU(
1776 template GSUP_MessageType msgt,
1777 template hexstring imsi := ?,
1778 template octetstring source_name := ?,
1779 template octetstring destination_name := ?
1780) := tr_GSUP(
1781 msgt,
1782 {
1783 tr_GSUP_IE_IMSI(imsi),
1784 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1785 tr_GSUP_IE_Source_Name(source_name),
1786 tr_GSUP_IE_Destination_Name(destination_name)
1787 }
1788);
1789
1790template (value) GSUP_PDU ts_GSUP_E_AN_APDU(
1791 GSUP_MessageType msgt,
1792 hexstring imsi,
1793 octetstring source_name,
1794 octetstring destination_name,
1795 GSUP_AN_APDU an_apdu
1796) := ts_GSUP(
1797 msgt,
1798 {
1799 valueof(ts_GSUP_IE_IMSI(imsi)),
1800 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1801 valueof(ts_GSUP_IE_Source_Name(source_name)),
1802 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1803 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1804 }
1805);
1806
1807template (value) GSUP_PDU ts_GSUP_E_PrepareHandoverResult(
1808 hexstring imsi,
1809 hexstring msisdn,
1810 octetstring source_name,
1811 octetstring destination_name,
1812 GSUP_AN_APDU an_apdu
1813) := ts_GSUP(
1814 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT,
1815 {
1816 valueof(ts_GSUP_IE_IMSI(imsi)),
1817 valueof(ts_GSUP_IE_MSISDN(msisdn)),
1818 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1819 valueof(ts_GSUP_IE_Source_Name(source_name)),
1820 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1821 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1822 }
1823);
Harald Weltef9d449e2018-06-24 22:27:47 +02001824
Harald Weltedf327232017-12-28 22:51:51 +01001825} with { encode "RAW"; variant "FIELDORDER(msb)" }