blob: 8977d9f777f3a4e287df12b8fe8e22308710087b [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),
64
65 OSMO_GSUP_MESSAGE_CLASS_IE ('0a'O),
66
67 OSMO_GSUP_SOURCE_NAME_IE ('60'O),
68 OSMO_GSUP_DESTINATION_NAME_IE ('61'O),
69 OSMO_GSUP_AN_APDU_IE ('62'O),
70 OSMO_GSUP_CAUSE_RR_IE ('63'O),
71 OSMO_GSUP_CAUSE_BSSAP_IE ('64'O),
72 OSMO_GSUP_CAUSE_SM_IE ('65'O)
Harald Weltedf327232017-12-28 22:51:51 +010073} with { variant "FIELDLENGTH(8)" };
74
75type enumerated GSUP_MessageType {
76 OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST ('00000100'B),
77 OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR ('00000101'B),
78 OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT ('00000110'B),
79
80 OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST ('00001000'B),
81 OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR ('00001001'B),
82 OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT ('00001010'B),
83
84 OSMO_GSUP_MSGT_AUTH_FAIL_REPORT ('00001011'B),
85
86 OSMO_GSUP_MSGT_PURGE_MS_REQUEST ('00001100'B),
87 OSMO_GSUP_MSGT_PURGE_MS_ERROR ('00001101'B),
88 OSMO_GSUP_MSGT_PURGE_MS_RESULT ('00001110'B),
89
90 OSMO_GSUP_MSGT_INSERT_DATA_REQUEST ('00010000'B),
91 OSMO_GSUP_MSGT_INSERT_DATA_ERROR ('00010001'B),
92 OSMO_GSUP_MSGT_INSERT_DATA_RESULT ('00010010'B),
93
94 OSMO_GSUP_MSGT_DELETE_DATA_REQUEST ('00010100'B),
95 OSMO_GSUP_MSGT_DELETE_DATA_ERROR ('00010101'B),
96 OSMO_GSUP_MSGT_DELETE_DATA_RESULT ('00010110'B),
97
98 OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST ('00011100'B),
99 OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR ('00011101'B),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700100 OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT ('00011110'B),
101
102 OSMO_GSUP_MSGT_PROC_SS_REQUEST ('00100000'B),
103 OSMO_GSUP_MSGT_PROC_SS_ERROR ('00100001'B),
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700104 OSMO_GSUP_MSGT_PROC_SS_RESULT ('00100010'B),
105
106 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST ('00100100'B),
107 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR ('00100101'B),
108 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT ('00100110'B),
109
110 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST ('00101000'B),
111 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR ('00101001'B),
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700112 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT ('00101010'B),
113
114 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST ('00101100'B),
115 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR ('00101101'B),
Oliver Smithc5748292019-02-22 15:02:48 +0100116 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT ('00101110'B),
117
118 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST ('00110000'B),
119 OSMO_GSUP_MSGT_CHECK_IMEI_ERROR ('00110001'B),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200120 OSMO_GSUP_MSGT_CHECK_IMEI_RESULT ('00110010'B),
121
122 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST ('00110100'B),
123 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_ERROR ('00110101'B),
124 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT ('00110110'B),
125
126 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST ('00111000'B),
127 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_ERROR ('00111001'B),
128 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT ('00111010'B),
129
130 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST ('00111100'B),
131 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_ERROR ('00111101'B),
132 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_RESULT ('00111110'B),
133
134 OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST ('01000000'B),
135 OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST ('01000100'B),
136
137 OSMO_GSUP_MSGT_E_CLOSE ('01000111'B),
138 OSMO_GSUP_MSGT_E_ABORT ('01001011'B),
139
140 OSMO_GSUP_MSGT_E_ROUTING_ERROR ('01001110'B)
Harald Weltedf327232017-12-28 22:51:51 +0100141} with { variant "FIELDLENGTH(8)" };
142
143type enumerated GSUP_CancelType {
Alexander Couzens4786b3f2018-09-16 03:33:30 +0200144 OSMO_GSUP_CANCEL_TYPE_UPDATE (0),
145 OSMO_GSUP_CANCEL_TYPE_WITHDRAW (1)
Harald Weltedf327232017-12-28 22:51:51 +0100146} with { variant "FIELDLENGTH(8)" };
147
148type enumerated GSUP_CnDomain {
149 OSMO_GSUP_CN_DOMAIN_PS (1),
150 OSMO_GSUP_CN_DOMAIN_CS (2)
151} with { variant "FIELDLENGTH(8)" };
152
Oliver Smithc5748292019-02-22 15:02:48 +0100153type enumerated GSUP_IMEIResult {
154 OSMO_GSUP_IMEI_RESULT_ACK (0),
155 OSMO_GSUP_IMEI_RESULT_NACK (1)
156} with { variant "FIELDLENGTH(8)" };
157
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700158type enumerated GSUP_SessionState {
159 OSMO_GSUP_SESSION_STATE_NONE (0),
160 OSMO_GSUP_SESSION_STATE_BEGIN (1),
161 OSMO_GSUP_SESSION_STATE_CONTINUE (2),
162 OSMO_GSUP_SESSION_STATE_END (3)
163} with { variant "FIELDLENGTH(8)" };
164
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200165type enumerated GSUP_Message_Class {
166 OSMO_GSUP_MESSAGE_CLASS_UNSET (0),
167 OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT (1),
168 OSMO_GSUP_MESSAGE_CLASS_SMS (2),
169 OSMO_GSUP_MESSAGE_CLASS_USSD (3),
170 OSMO_GSUP_MESSAGE_CLASS_INTER_MSC (4)
171} with { variant "FIELDLENGTH(8)" };
172
Harald Welte3f95be82018-01-27 00:48:13 +0100173type record GSUP_MSISDN {
174 uint8_t len,
175 hexstring digits optional
176} with { variant (len) "LENGTHTO(digits)" };
177
Oliver Smithc5748292019-02-22 15:02:48 +0100178type record GSUP_IMEI {
179 uint8_t len,
180 hexstring digits optional
181} with { variant (len) "LENGTHTO(digits)" };
182
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200183type enumerated GSUP_AN_PROTO {
184 OSMO_GSUP_AN_PROTO_48006 (1),
185 OSMO_GSUP_AN_PROTO_25413 (2)
186} with { variant "FIELDLENGTH(8)" };
187
188type record GSUP_AN_APDU {
189 GSUP_AN_PROTO proto,
190 octetstring pdu
191};
192
Harald Weltedf327232017-12-28 22:51:51 +0100193type record GSUP_IE {
194 GSUP_IEI tag,
195 uint8_t len,
196 GSUP_IeValue val
197} with { variant (len) "LENGTHTO(val)"
198 variant (val) "CROSSTAG(imsi, tag = OSMO_GSUP_IMSI_IE;
199 cause, tag = OSMO_GSUP_CAUSE_IE;
200 cancel_type, tag = OSMO_GSUP_CANCEL_TYPE_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100201 auth_tuple, tag = OSMO_GSUP_AUTH_TUPLE_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100202 auts, tag = OSMO_GSUP_AUTS_IE;
203 rand, tag = OSMO_GSUP_RAND_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100204 sres, tag = OSMO_GSUP_SRES_IE;
205 kc, tag = OSMO_GSUP_KC_IE;
206 ik, tag = OSMO_GSUP_IK_IE;
207 ck, tag = OSMO_GSUP_CK_IE;
208 autn, tag = OSMO_GSUP_AUTN_IE;
209 res, tag = OSMO_GSUP_RES_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100210 msisdn, tag = OSMO_GSUP_MSISDN_IE;
211 hlr_number, tag = OSMO_GSUP_HLR_NUMBER_IE;
212 cn_domain, tag = OSMO_GSUP_CN_DOMAIN_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100213 pdp_info, tag = OSMO_GSUP_PDP_INFO_IE;
214 apn, tag = OSMO_GSUP_ACCESS_POINT_NAME_IE;
215 pdp_qos, tag = OSMO_GSUP_PDP_QOS_IE;
216 pdp_type, tag = OSMO_GSUP_PDP_TYPE_IE;
217 charg_char, tag = OSMO_GSUP_CHARG_CHAR_IE;
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700218 session_state, tag = OSMO_GSUP_SESSION_STATE_IE;
219 session_id, tag = OSMO_GSUP_SESSION_ID_IE;
220 ss_info, tag = OSMO_GSUP_SS_INFO_IE;
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700221 sm_rp_mr, tag = OSMO_GSUP_SM_RP_MR_IE;
222 sm_rp_da, tag = OSMO_GSUP_SM_RP_DA_IE;
223 sm_rp_oa, tag = OSMO_GSUP_SM_RP_OA_IE;
224 sm_rp_ui, tag = OSMO_GSUP_SM_RP_UI_IE;
225 sm_rp_cause, tag = OSMO_GSUP_SM_RP_CAUSE_IE;
226 sm_rp_mms, tag = OSMO_GSUP_SM_RP_MMS_IE;
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700227 sm_alert_rsn, tag = OSMO_GSUP_SM_ALERT_RSN_IE;
Oliver Smithc5748292019-02-22 15:02:48 +0100228 imei, tag = OSMO_GSUP_IMEI_IE;
229 imei_result, tag = OSMO_GSUP_IMEI_RESULT_IE;
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200230 message_class, tag = OSMO_GSUP_MESSAGE_CLASS_IE;
231 source_name, tag = OSMO_GSUP_SOURCE_NAME_IE;
232 destination_name, tag = OSMO_GSUP_DESTINATION_NAME_IE;
233 an_apdu, tag = OSMO_GSUP_AN_APDU_IE;
234 cause_rr, tag = OSMO_GSUP_CAUSE_RR_IE;
235 cause_bssap, tag = OSMO_GSUP_CAUSE_BSSAP_IE;
236 cause_sm, tag = OSMO_GSUP_CAUSE_SM_IE;
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100237 supported_rat_types, tag = OSMO_GSUP_SUPPORTED_RAT_TYPES_IE;
238 current_rat_type, tag = OSMO_GSUP_CURRENT_RAT_TYPE_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100239 )"
Harald Weltedf327232017-12-28 22:51:51 +0100240};
241
242type record of GSUP_IE GSUP_IEs;
243
Harald Welte8eebb6c2019-08-22 12:40:03 +0200244type enumerated GSUP_RatType {
245 RAT_TYPE_UNKNOWN (0),
246 RAT_TYPE_GERAN_A (1),
247 RAT_TYPE_UTRAN_Iu (2),
248 RAT_TYPE_EUTRAN_SGs (3)
249} with { variant "FIELDLENGTH(8)" };
250
251type record of GSUP_RatType GSUP_RatTypes;
252
Harald Weltedf327232017-12-28 22:51:51 +0100253type union GSUP_IeValue {
254 hexstring imsi,
255 integer cause,
256 GSUP_CancelType cancel_type,
257 //boolean pdp_info_compl,
258 //boolean freeze_ptmsi,
Harald Weltedf327232017-12-28 22:51:51 +0100259 GSUP_IEs auth_tuple,
260 octetstring auts,
261 octetstring rand,
Harald Welte77a8eba2018-01-22 21:22:32 +0100262 octetstring sres,
263 octetstring kc,
264 octetstring ik,
265 octetstring ck,
266 octetstring autn,
267 octetstring res,
Harald Welte3f95be82018-01-27 00:48:13 +0100268 GSUP_MSISDN msisdn,
Harald Weltedf327232017-12-28 22:51:51 +0100269 octetstring hlr_number,
270 GSUP_CnDomain cn_domain,
Harald Welteeded9ad2018-02-17 20:57:34 +0100271 /* PDP context + nested IEs */
272 GSUP_IEs pdp_info,
273 octetstring apn,
274 octetstring pdp_qos,
275 OCT2 pdp_type,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700276 octetstring charg_char,
277 /* Session information */
278 GSUP_SessionState session_state,
279 OCT4 session_id,
280 /* Supplementary Services */
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700281 octetstring ss_info,
282 /* Short Message Service */
283 OCT1 sm_rp_mr,
284 GSUP_SM_RP_DA sm_rp_da,
285 GSUP_SM_RP_OA sm_rp_oa,
286 octetstring sm_rp_ui,
287 OCT1 sm_rp_cause,
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700288 OCT1 sm_rp_mms,
Oliver Smithc5748292019-02-22 15:02:48 +0100289 GSUP_SM_ALERT_RSN_Type sm_alert_rsn,
290
291 GSUP_IMEI imei,
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200292 GSUP_IMEIResult imei_result,
293
294 GSUP_Message_Class message_class,
295
296 octetstring source_name,
297 octetstring destination_name,
298
299 GSUP_AN_APDU an_apdu,
300
301 OCT1 cause_rr,
302 OCT1 cause_bssap,
Harald Welte8eebb6c2019-08-22 12:40:03 +0200303 OCT1 cause_sm,
304
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100305 GSUP_RatTypes supported_rat_types,
306 GSUP_RatType current_rat_type
Harald Weltedf327232017-12-28 22:51:51 +0100307};
308
309type record GSUP_PDU {
310 GSUP_MessageType msg_type,
311 GSUP_IEs ies
312};
313
314external function enc_GSUP_PDU(in GSUP_PDU msg) return octetstring
315 with { extension "prototype(convert) encode(RAW)" };
316
317external function dec_GSUP_PDU(in octetstring msg) return GSUP_PDU
318 with { extension "prototype(convert) decode(RAW)" };
319
Harald Welte2f562b12018-01-24 20:52:38 +0100320function f_gsup_postprocess_decoded(inout GSUP_PDU gsup) {
321 if (gsup.ies[0].tag == OSMO_GSUP_IMSI_IE) {
322 /* if last digit is 'F', then there's an odd number of digits and we must strip the F */
323 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
324 if (gsup.ies[0].val.imsi[num_digits-1] == 'F'H) {
325 gsup.ies[0].val.imsi := substr(gsup.ies[0].val.imsi, 0, num_digits-1);
326 }
327 }
328}
329
330function f_gsup_preprocess_encoded(inout GSUP_PDU gsup) {
331 if (ischosen(gsup.ies[0].val.imsi)) {
332 /* if number of digits is odd, add a 'F' as padding at the end */
333 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
334 if (num_digits rem 2 == 1) {
335 gsup.ies[0].val.imsi := gsup.ies[0].val.imsi & 'F'H;
336 }
337 }
338}
339
Harald Welte3f95be82018-01-27 00:48:13 +0100340template (value) GSUP_MSISDN ts_GSUP_MSISDN(hexstring digits,
341 BIT3 ton := '000'B,
342 BIT4 npi := '0000'B) := {
343 len := 0, /* overwritten */
344 /* numberingPlanIdentification := npi,
345 typeOfNumber := ton,
346 ext1 := '0'B, */
347 digits := digits
348}
349
350template GSUP_MSISDN tr_GSUP_MSISDN(template hexstring digits,
351 template BIT3 ton := ?,
352 template BIT4 npi := ?) := {
353 len := ?,
354 /* numberingPlanIdentification := npi,
355 typeOfNumber := ton,
356 ext1 := '0'B, */
357 digits := digits
358}
359
360
Harald Weltedf327232017-12-28 22:51:51 +0100361
Harald Welte77a8eba2018-01-22 21:22:32 +0100362template GSUP_IE ts_GSUP_IE_AuthTuple2G(octetstring rand, octetstring sres,
363 octetstring kc) := {
364 tag := OSMO_GSUP_AUTH_TUPLE_IE,
365 len := 0, /* overwritten */
366 val := {
367 auth_tuple := {
368 valueof(ts_GSUP_IE_RAND(rand)),
369 valueof(ts_GSUP_IE_SRES(sres)),
370 valueof(ts_GSUP_IE_Kc(kc))
371 }
372 }
373}
374
375template GSUP_IE ts_GSUP_IE_AuthTuple2G3G(octetstring rand, octetstring sres,
376 octetstring kc, octetstring ik,
377 octetstring ck, octetstring autn,
378 octetstring res) := {
379 tag := OSMO_GSUP_AUTH_TUPLE_IE,
380 len := 0, /* overwritten */
381 val := {
382 auth_tuple := {
383 valueof(ts_GSUP_IE_RAND(rand)),
384 valueof(ts_GSUP_IE_SRES(sres)),
385 valueof(ts_GSUP_IE_Kc(kc)),
386 valueof(ts_GSUP_IE_IK(ik)),
387 valueof(ts_GSUP_IE_CK(ck)),
388 valueof(ts_GSUP_IE_AUTN(autn)),
389 valueof(ts_GSUP_IE_RES(res))
390 }
391 }
392}
393
Harald Welteeded9ad2018-02-17 20:57:34 +0100394template GSUP_IE ts_GSUP_IE_PdpInfo(octetstring apn, octetstring pdp_type, octetstring pdp_qos) := {
395 tag := OSMO_GSUP_PDP_INFO_IE,
396 len := 0, /* overwritten */
397 val := {
398 pdp_info := {
399 valueof(ts_GSUP_IE_APN(apn)),
400 valueof(ts_GSUP_IE_PDP_TYPE(pdp_type)),
401 valueof(ts_GSUP_IE_PDP_QOS(pdp_qos))
402 }
403 }
404}
405
406template (value) GSUP_IE ts_GSUP_IE_PDP_TYPE(OCT2 pdp_type) := {
407 tag := OSMO_GSUP_PDP_TYPE_IE,
408 len := 0,
409 val := {
410 pdp_type := pdp_type
411 }
412}
413
414template (value) GSUP_IE ts_GSUP_IE_PDP_QOS(octetstring pdp_qos) := {
415 tag := OSMO_GSUP_PDP_QOS_IE,
416 len := 0,
417 val := {
418 pdp_qos := pdp_qos
419 }
420}
421
422
Harald Weltedf327232017-12-28 22:51:51 +0100423template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
424 msg_type := msgt,
425 ies := ies
426}
427
Harald Welte8a1dd532018-01-27 15:38:18 +0100428template GSUP_PDU tr_GSUP_IMSI(template GSUP_MessageType msgt := ?, template hexstring imsi) := {
429 msg_type := msgt,
430 ies := { tr_GSUP_IE_IMSI(imsi), * }
431}
432
Harald Weltedf327232017-12-28 22:51:51 +0100433template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
434 msg_type := msgt,
435 ies := ies
436}
437
Oliver Smith936dbe62019-06-04 15:54:17 +0200438template (value) GSUP_IMEI ts_GSUP_IMEI(hexstring digits) := {
439 len := 0, /* overwritten */
440 digits := digits
441}
442
443template GSUP_IMEI tr_GSUP_IMEI(template hexstring digits) := {
444 len := ?,
445 digits := digits
446}
447
448
Harald Welte6aa04e32018-01-27 15:35:19 +0100449template (value) GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
Harald Weltedf327232017-12-28 22:51:51 +0100450 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
451
Harald Welte8eebb6c2019-08-22 12:40:03 +0200452template (value) GSUP_PDU ts_GSUP_SAI_REQ_EPS(hexstring imsi) :=
453 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
454 valueof(ts_GSUP_IE_IMSI(imsi)),
Harald Welte0a1fd0e2019-12-03 20:01:08 +0100455 valueof(ts_GSUP_IE_CURRENT_RAT_TYPE(RAT_TYPE_EUTRAN_SGs))
Harald Welte8eebb6c2019-08-22 12:40:03 +0200456 });
457
Harald Welteef9fa872018-01-22 03:00:17 +0100458template GSUP_PDU tr_GSUP_SAI_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100459 tr_GSUP_IMSI(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, imsi);
Harald Welteef9fa872018-01-22 03:00:17 +0100460
Alexander Couzensd24973d2018-09-04 16:10:14 +0200461template GSUP_PDU tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC(
462 template hexstring imsi,
463 template octetstring auts,
464 template octetstring rand) :=
465 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
466 tr_GSUP_IE_IMSI(imsi),
467 tr_GSUP_IE_AUTS(auts),
468 tr_GSUP_IE_RAND(rand),
469 *
470 });
471
Harald Welte77a8eba2018-01-22 21:22:32 +0100472template (value) GSUP_PDU ts_GSUP_SAI_RES(hexstring imsi, GSUP_IE auth_tuple) :=
473 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
474 valueof(ts_GSUP_IE_IMSI(imsi)), auth_tuple });
475
Harald Weltedf327232017-12-28 22:51:51 +0100476template GSUP_PDU tr_GSUP_SAI_ERR(template hexstring imsi, template integer cause) :=
Harald Welte071ed732018-01-23 19:53:52 +0100477 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
Harald Weltedf327232017-12-28 22:51:51 +0100478 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
479
Harald Welte6aa04e32018-01-27 15:35:19 +0100480template (value) GSUP_PDU ts_GSUP_SAI_ERR(hexstring imsi, integer cause) :=
481 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
482 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
Harald Welte071ed732018-01-23 19:53:52 +0100483
484
Harald Weltedf327232017-12-28 22:51:51 +0100485template GSUP_PDU tr_GSUP_SAI_RES(template hexstring imsi) :=
Harald Weltec2c52552018-03-01 21:20:39 +0100486 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
Harald Weltedf327232017-12-28 22:51:51 +0100487 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE), * });
488
Harald Weltec2c52552018-03-01 21:20:39 +0100489template (value) GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi) :=
490 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, {
491 valueof(ts_GSUP_IE_IMSI(imsi)) });
492
Harald Weltedfe94dd2018-01-21 13:55:22 +0100493template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100494 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, imsi);
Harald Weltedfe94dd2018-01-21 13:55:22 +0100495
Harald Welte6aa04e32018-01-27 15:35:19 +0100496template (value) GSUP_PDU ts_GSUP_UL_RES(hexstring imsi) :=
Harald Weltedfe94dd2018-01-21 13:55:22 +0100497 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)) });
498
Harald Weltec2c52552018-03-01 21:20:39 +0100499template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi) :=
500 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, imsi);
501
Harald Welte6aa04e32018-01-27 15:35:19 +0100502template (value) GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100503 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
504 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
505
Harald Weltec2c52552018-03-01 21:20:39 +0100506template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?) :=
507 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
508 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
509
Harald Welte6aa04e32018-01-27 15:35:19 +0100510template (value) GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100511 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
512 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)) });
513
Harald Weltec2c52552018-03-01 21:20:39 +0100514template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?) :=
515 tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
Harald Welte8f6ac162018-03-01 22:43:28 +0100516 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_MSISDN(msisdn), * });
Harald Weltec2c52552018-03-01 21:20:39 +0100517
518template (value) GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi) :=
519 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, {
520 valueof(ts_GSUP_IE_IMSI(imsi)) });
521
Harald Welte6ff81902018-01-21 19:09:08 +0100522template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100523 tr_GSUP_IMSI(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100524
Harald Weltec638f4d2018-01-24 22:00:36 +0100525template GSUP_PDU tr_GSUP_AUTH_FAIL_IND(hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100526 tr_GSUP_IMSI(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100527
Harald Welte167458a2018-01-27 15:58:16 +0100528template (value) GSUP_PDU ts_GSUP_CL_REQ(hexstring imsi, GSUP_CancelType ctype) :=
529 ts_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST, {
530 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CancelType(ctype)) });
531
532template GSUP_PDU tr_GSUP_CL_RES(template hexstring imsi) :=
533 tr_GSUP_IMSI(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT, imsi);
534
535template GSUP_PDU tr_GSUP_CL_ERR(template hexstring imsi, template integer cause := ?) :=
536 tr_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR, {
Alexander Couzens4cfff3a2018-05-22 17:08:36 +0200537 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause), * });
Harald Welte167458a2018-01-27 15:58:16 +0100538
Harald Welte958f8b42018-03-01 23:40:17 +0100539template (value) GSUP_PDU ts_GSUP_PURGE_MS_REQ(hexstring imsi, GSUP_CnDomain dom) :=
540 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
541 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CnDomain(dom)) });
542
Harald Welte6abb9fe2018-02-17 15:24:48 +0100543template GSUP_PDU tr_GSUP_PURGE_MS_REQ(template hexstring imsi, template GSUP_CnDomain dom := ?) :=
544 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
545 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_CnDomain(dom) });
546
547template (value) GSUP_PDU ts_GSUP_PURGE_MS_RES(hexstring imsi) :=
548 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
549 valueof(ts_GSUP_IE_IMSI(imsi)) });
550
Harald Welte958f8b42018-03-01 23:40:17 +0100551template GSUP_PDU tr_GSUP_PURGE_MS_RES(template hexstring imsi) :=
552 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
553 tr_GSUP_IE_IMSI(imsi), * });
554
555template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer cause) :=
556 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
557 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
558
Oliver Smith936dbe62019-06-04 15:54:17 +0200559template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei) :=
560 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST, {
561 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI(imei)) });
562
Oliver Smith1d118ff2019-07-03 10:57:35 +0200563template GSUP_PDU tr_GSUP_CHECK_IMEI_REQ(
564 template hexstring imsi,
565 template hexstring imei
566) := tr_GSUP(
567 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST,
568 {
569 tr_GSUP_IE_IMSI(imsi),
570 tr_GSUP_IE_IMEI(imei),
571 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT)
572 }
573);
574
575template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_RES(hexstring imsi, GSUP_IMEIResult result) :=
576 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
577 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI_Result(result)) });
578
Oliver Smith936dbe62019-06-04 15:54:17 +0200579template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result) :=
580 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
581 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_IMEI_Result(result) });
582
Oliver Smith1d118ff2019-07-03 10:57:35 +0200583template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_ERR(hexstring imsi, integer cause) :=
584 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
585 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
586
Oliver Smith936dbe62019-06-04 15:54:17 +0200587template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause) :=
588 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
589 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
590
Harald Welte167458a2018-01-27 15:58:16 +0100591
592template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
593 tag := OSMO_GSUP_CANCEL_TYPE_IE,
594 len := 0, /* overwritten */
595 val := {
596 cancel_type := ctype
597 }
598}
599
600template GSUP_IE tr_GSUP_IE_CancelType(template GSUP_CancelType ctype) :=
601 tr_GSUP_IE(OSMO_GSUP_CANCEL_TYPE_IE, GSUP_IeValue:{cancel_type:=ctype});
602
Harald Welte6abb9fe2018-02-17 15:24:48 +0100603template GSUP_IE tr_GSUP_IE_CnDomain(template GSUP_CnDomain domain) :=
604 tr_GSUP_IE(OSMO_GSUP_CN_DOMAIN_IE, GSUP_IeValue:{cn_domain:=domain});
605
Harald Weltedf327232017-12-28 22:51:51 +0100606template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := {
607 tag := iei,
608 len := ?,
609 val := val
610}
611
612template (value) GSUP_IE ts_GSUP_IE_IMSI(hexstring imsi) := {
613 tag := OSMO_GSUP_IMSI_IE,
614 len := 0, /* overwritten */
615 val := {
616 imsi := imsi
617 }
618}
619
620template GSUP_IE tr_GSUP_IE_IMSI(template hexstring imsi) := {
621 tag := OSMO_GSUP_IMSI_IE,
622 len := ?,
623 val := {
624 imsi := imsi
625 }
626}
627
Harald Welte6ff81902018-01-21 19:09:08 +0100628template (value) GSUP_IE ts_GSUP_IE_MSISDN(hexstring msisdn) := {
629 tag := OSMO_GSUP_MSISDN_IE,
630 len := 0, /* overwritten */
631 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100632 msisdn := ts_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100633 }
634}
635
636template GSUP_IE tr_GSUP_IE_MSISDN(template hexstring msisdn) := {
637 tag := OSMO_GSUP_MSISDN_IE,
638 len := ?,
639 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100640 msisdn := tr_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100641 }
642}
643
644
Harald Weltedf327232017-12-28 22:51:51 +0100645template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := {
646 tag := OSMO_GSUP_CAUSE_IE,
647 len := 0, /* overwritten */
648 val := {
649 cause := cause
650 }
651}
652
653template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := {
654 tag := OSMO_GSUP_CAUSE_IE,
655 len := ?,
656 val := {
657 cause := cause
658 }
659}
660
661template (value) GSUP_IE ts_GSUP_IE_AUTS(octetstring auts) := {
662 tag := OSMO_GSUP_AUTS_IE,
663 len := 0, /* overwritten */
664 val := {
665 auts := auts
666 }
667}
668
Alexander Couzensd24973d2018-09-04 16:10:14 +0200669template GSUP_IE tr_GSUP_IE_AUTS(template octetstring auts) := {
670 tag := OSMO_GSUP_AUTS_IE,
671 len := ?,
672 val := {
673 auts := auts
674 }
675}
676
Harald Weltedf327232017-12-28 22:51:51 +0100677template (value) GSUP_IE ts_GSUP_IE_RAND(octetstring rand) := {
678 tag := OSMO_GSUP_RAND_IE,
679 len := 0, /* overwritten */
680 val := {
681 rand := rand
682 }
683}
684
Alexander Couzensd24973d2018-09-04 16:10:14 +0200685template GSUP_IE tr_GSUP_IE_RAND(template octetstring rand) := {
686 tag := OSMO_GSUP_RAND_IE,
687 len := ?,
688 val := {
689 rand := rand
690 }
691}
692
Harald Welte77a8eba2018-01-22 21:22:32 +0100693template (value) GSUP_IE ts_GSUP_IE_SRES(octetstring sres) := {
694 tag := OSMO_GSUP_SRES_IE,
695 len := 0, /* overwritten */
696 val := {
697 sres := sres
698 }
699}
700
701template (value) GSUP_IE ts_GSUP_IE_Kc(octetstring kc) := {
702 tag := OSMO_GSUP_KC_IE,
703 len := 0, /* overwritten */
704 val := {
705 kc := kc
706 }
707}
708
709template (value) GSUP_IE ts_GSUP_IE_IK(octetstring ik) := {
710 tag := OSMO_GSUP_IK_IE,
711 len := 0, /* overwritten */
712 val := {
713 ik := ik
714 }
715}
716
717template (value) GSUP_IE ts_GSUP_IE_CK(octetstring ck) := {
718 tag := OSMO_GSUP_CK_IE,
719 len := 0, /* overwritten */
720 val := {
721 ck := ck
722 }
723}
724
725template (value) GSUP_IE ts_GSUP_IE_AUTN(octetstring autn) := {
726 tag := OSMO_GSUP_AUTN_IE,
727 len := 0, /* overwritten */
728 val := {
729 autn := autn
730 }
731}
732
733template (value) GSUP_IE ts_GSUP_IE_RES(octetstring res) := {
734 tag := OSMO_GSUP_RES_IE,
735 len := 0, /* overwritten */
736 val := {
737 res := res
738 }
739}
Harald Weltedf327232017-12-28 22:51:51 +0100740
Harald Welteeded9ad2018-02-17 20:57:34 +0100741template (value) GSUP_IE ts_GSUP_IE_APN(octetstring apn) := {
742 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
743 len := 0, /* overwritten */
744 val := {
745 apn := apn
746 }
747}
748
Harald Welte958f8b42018-03-01 23:40:17 +0100749template (value) GSUP_IE ts_GSUP_IE_CnDomain(GSUP_CnDomain dom) := {
750 tag := OSMO_GSUP_CN_DOMAIN_IE,
751 len := 0, /* overwritten */
752 val := {
753 cn_domain := dom
754 }
755}
Harald Weltedf327232017-12-28 22:51:51 +0100756
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700757template (value) GSUP_IE ts_GSUP_IE_SessionId(OCT4 sid) := {
758 tag := OSMO_GSUP_SESSION_ID_IE,
759 len := 0, /* overwritten */
760 val := {
761 session_id := sid
762 }
763}
764template GSUP_IE tr_GSUP_IE_SessionId(template OCT4 sid) := {
765 tag := OSMO_GSUP_SESSION_ID_IE,
766 len := ?,
767 val := {
768 session_id := sid
769 }
770}
771
772template (value) GSUP_IE ts_GSUP_IE_SessionState(GSUP_SessionState state) := {
773 tag := OSMO_GSUP_SESSION_STATE_IE,
774 len := 0, /* overwritten */
775 val := {
776 session_state := state
777 }
778}
779template GSUP_IE tr_GSUP_IE_SessionState(template GSUP_SessionState state) := {
780 tag := OSMO_GSUP_SESSION_STATE_IE,
781 len := ?,
782 val := {
783 session_state := state
784 }
785}
786
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700787template (value) GSUP_IE ts_GSUP_IE_SM_RP_MR(OCT1 ref) := {
788 tag := OSMO_GSUP_SM_RP_MR_IE,
789 len := 0, /* overwritten */
790 val := {
791 sm_rp_mr := ref
792 }
793}
794template GSUP_IE tr_GSUP_IE_SM_RP_MR(template OCT1 ref) := {
795 tag := OSMO_GSUP_SM_RP_MR_IE,
796 len := ?,
797 val := {
798 sm_rp_mr := ref
799 }
800}
801
802template (value) GSUP_IE ts_GSUP_IE_SM_RP_CAUSE(OCT1 cause) := {
803 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
804 len := 0, /* overwritten */
805 val := {
806 sm_rp_cause := cause
807 }
808}
809template GSUP_IE tr_GSUP_IE_SM_RP_CAUSE(template OCT1 cause) := {
810 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
811 len := ?,
812 val := {
813 sm_rp_cause := cause
814 }
815}
816
817template (value) GSUP_IE ts_GSUP_IE_SM_RP_MMS(OCT1 mms) := {
818 tag := OSMO_GSUP_SM_RP_MMS_IE,
819 len := 0, /* overwritten */
820 val := {
821 sm_rp_mms := mms
822 }
823}
824template GSUP_IE tr_GSUP_IE_SM_RP_MMS(template OCT1 mms) := {
825 tag := OSMO_GSUP_SM_RP_MMS_IE,
826 len := ?,
827 val := {
828 sm_rp_mms := mms
829 }
830}
831
Oliver Smith936dbe62019-06-04 15:54:17 +0200832template (value) GSUP_IE ts_GSUP_IE_IMEI(hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100833 tag := OSMO_GSUP_IMEI_IE,
834 len := 0, /* overwritten */
835 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +0200836 imei := ts_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +0100837 }
838}
Oliver Smith936dbe62019-06-04 15:54:17 +0200839template GSUP_IE tr_GSUP_IE_IMEI(template hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100840 tag := OSMO_GSUP_IMEI_IE,
841 len := ?,
842 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +0200843 imei := tr_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +0100844 }
845}
846
Oliver Smith936dbe62019-06-04 15:54:17 +0200847template (value) GSUP_IE ts_GSUP_IE_IMEI_Result(GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100848 tag := OSMO_GSUP_IMEI_RESULT_IE,
849 len := 0, /* overwritten */
850 val := {
851 imei_result := result
852 }
853}
Oliver Smith936dbe62019-06-04 15:54:17 +0200854template GSUP_IE tr_GSUP_IE_IMEI_Result(template GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100855 tag := OSMO_GSUP_IMEI_RESULT_IE,
856 len := ?,
857 val := {
858 imei_result := result
859 }
860}
861
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700862/* Possible identity types for SM-RP-{OA|DA} IEs */
863type enumerated GSUP_SM_RP_ODA_IdType {
864 OSMO_GSUP_SM_RP_ODA_ID_NONE ('00'O),
865 OSMO_GSUP_SM_RP_ODA_ID_IMSI ('01'O),
866 OSMO_GSUP_SM_RP_ODA_ID_MSISDN ('02'O),
867 OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR ('03'O),
868 /* Special value for noSM-RP-DA and noSM-RP-OA */
869 OSMO_GSUP_SM_RP_ODA_ID_NULL ('FF'O)
870} with { variant "FIELDLENGTH(8)" };
871
872/**
873 * SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
874 * It can be either of the following:
875 * - IMSI
876 * - LMSI (not implemented)
877 * - MSISDN
878 * - roaming number (not implemented)
879 * - service centre address
880 */
881type union GSUP_SM_RP_DA_ID {
882 hexstring imsi,
883 hexstring msisdn,
884 hexstring smsc_addr
885};
886
887type record GSUP_SM_RP_DA {
888 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700889 GSUP_SM_RP_DA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +0700890} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700891 imsi, id_type = OSMO_GSUP_SM_RP_ODA_ID_IMSI;
892 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
893 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
894 /* FIXME: how to handle noSM-RP-DA? */
895 )"
896};
897
898template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_IMSI(hexstring imsi) := {
899 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700900 id_enc := { imsi := imsi }
901}
902template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_IMSI(template hexstring imsi) := {
903 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700904 id_enc := { imsi := imsi }
905}
906
907template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(hexstring msisdn) := {
908 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700909 id_enc := { msisdn := msisdn }
910}
911template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template hexstring msisdn) := {
912 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700913 id_enc := { msisdn := msisdn }
914}
915
916template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(hexstring smsc_addr) := {
917 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700918 id_enc := { smsc_addr := smsc_addr }
919}
920template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template hexstring smsc_addr) := {
921 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700922 id_enc := { smsc_addr := smsc_addr }
923}
924
925template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_NULL := {
926 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700927 id_enc := omit
928}
929template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_NULL := {
930 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700931 id_enc := omit
932}
933
934template (value) GSUP_IE ts_GSUP_IE_SM_RP_DA(GSUP_SM_RP_DA val) := {
935 tag := OSMO_GSUP_SM_RP_DA_IE,
936 len := 0, /* overwritten */
937 val := {
938 sm_rp_da := val
939 }
940}
941template GSUP_IE tr_GSUP_IE_SM_RP_DA(template GSUP_SM_RP_DA val) := {
942 tag := OSMO_GSUP_SM_RP_DA_IE,
943 len := ?,
944 val := {
945 sm_rp_da := val
946 }
947}
948
949/**
950 * SM-RP-OA represents the SM Originating Address, see 7.6.8.2.
951 * It can be either of the following:
952 * - MSISDN
953 * - service centre address
954 */
955type union GSUP_SM_RP_OA_ID {
956 hexstring msisdn,
957 hexstring smsc_addr
958};
959
960type record GSUP_SM_RP_OA {
961 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700962 GSUP_SM_RP_OA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +0700963} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700964 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
965 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
966 /* FIXME: how to handle noSM-RP-OA? */
967 )"
968};
969
970template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(hexstring msisdn) := {
971 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700972 id_enc := { msisdn := msisdn }
973}
974template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template hexstring msisdn) := {
975 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700976 id_enc := { msisdn := msisdn }
977}
978
979template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(hexstring smsc_addr) := {
980 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700981 id_enc := { smsc_addr := smsc_addr }
982}
983template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template hexstring smsc_addr) := {
984 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700985 id_enc := { smsc_addr := smsc_addr }
986}
987
988template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_NULL := {
989 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700990 id_enc := omit
991}
992template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_NULL := {
993 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700994 id_enc := omit
995}
996
997template (value) GSUP_IE ts_GSUP_IE_SM_RP_OA(GSUP_SM_RP_OA val) := {
998 tag := OSMO_GSUP_SM_RP_OA_IE,
999 len := 0, /* overwritten */
1000 val := {
1001 sm_rp_oa := val
1002 }
1003}
1004template GSUP_IE tr_GSUP_IE_SM_RP_OA(template GSUP_SM_RP_OA val) := {
1005 tag := OSMO_GSUP_SM_RP_OA_IE,
1006 len := ?,
1007 val := {
1008 sm_rp_oa := val
1009 }
1010}
1011
1012/* SM-RP-UI represents the SM TPDU, see 7.6.8.4 */
1013template (value) GSUP_IE ts_GSUP_IE_SM_RP_UI(octetstring val) := {
1014 tag := OSMO_GSUP_SM_RP_UI_IE,
1015 len := 0, /* overwritten */
1016 val := {
1017 sm_rp_ui := val
1018 }
1019}
1020template GSUP_IE tr_GSUP_IE_SM_RP_UI(template octetstring val) := {
1021 tag := OSMO_GSUP_SM_RP_UI_IE,
1022 len := ?,
1023 val := {
1024 sm_rp_ui := val
1025 }
1026}
1027
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001028/* SM Alert Reason types, see 7.6.8.8 */
1029type enumerated GSUP_SM_ALERT_RSN_Type {
1030 GSUP_SM_ALERT_RSN_TYPE_NONE ('00'O),
1031 GSUP_SM_ALERT_RSN_TYPE_MS_PRESENT ('01'O),
1032 GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL ('02'O)
1033} with { variant "FIELDLENGTH(8)" };
1034
1035/* SM Alert Reason IE (used in READY-FOR-SM), see 7.6.8.8 */
1036template (value) GSUP_IE ts_GSUP_IE_SM_ALERT_RSN(GSUP_SM_ALERT_RSN_Type rsn) := {
1037 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1038 len := 0, /* overwritten */
1039 val := {
1040 sm_alert_rsn := rsn
1041 }
1042}
1043template GSUP_IE tr_GSUP_IE_SM_ALERT_RSN(template GSUP_SM_ALERT_RSN_Type rsn) := {
1044 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1045 len := ?,
1046 val := {
1047 sm_alert_rsn := rsn
1048 }
1049}
1050
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001051template (value) GSUP_IE ts_GSUP_IE_SSInfo(octetstring ss) := {
1052 tag := OSMO_GSUP_SS_INFO_IE,
1053 len := 0, /* overwritten */
1054 val := {
1055 ss_info := ss
1056 }
1057}
1058template GSUP_IE tr_GSUP_IE_SSInfo(template octetstring ss) := {
1059 tag := OSMO_GSUP_SS_INFO_IE,
1060 len := ?,
1061 val := {
1062 ss_info := ss
1063 }
1064}
1065
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001066template GSUP_IE tr_GSUP_IE_Message_Class(template GSUP_Message_Class val) := {
1067 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1068 len := ?,
1069 val := {
1070 message_class := val
1071 }
1072}
1073
1074template (value) GSUP_IE ts_GSUP_IE_Message_Class(GSUP_Message_Class val) := {
1075 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1076 len := 0, /* overwritten */
1077 val := {
1078 message_class := val
1079 }
1080}
1081
1082template GSUP_IE tr_GSUP_IE_Source_Name(template octetstring name) := {
1083 tag := OSMO_GSUP_SOURCE_NAME_IE,
1084 len := ?,
1085 val := {
1086 source_name := name
1087 }
1088}
1089
1090template (value) GSUP_IE ts_GSUP_IE_Source_Name(octetstring name) := {
1091 tag := OSMO_GSUP_SOURCE_NAME_IE,
1092 len := 0, /* overwritten */
1093 val := {
1094 source_name := name
1095 }
1096}
1097
1098template GSUP_IE tr_GSUP_IE_Destination_Name(template octetstring name) := {
1099 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1100 len := ?,
1101 val := {
1102 destination_name := name
1103 }
1104}
1105
1106template (value) GSUP_IE ts_GSUP_IE_Destination_Name(octetstring name) := {
1107 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1108 len := 0, /* overwritten */
1109 val := {
1110 destination_name := name
1111 }
1112}
1113
1114template GSUP_IE tr_GSUP_IE_AN_APDU(template GSUP_AN_APDU an_apdu) := {
1115 tag := OSMO_GSUP_AN_APDU_IE,
1116 len := ?,
1117 val := {
1118 an_apdu := an_apdu
1119 }
1120}
1121
1122template (value) GSUP_IE ts_GSUP_IE_AN_APDU(GSUP_AN_APDU an_apdu) := {
1123 tag := OSMO_GSUP_AN_APDU_IE,
1124 len := 0, /* overwritten */
1125 val := {
1126 an_apdu := an_apdu
1127 }
1128}
1129
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001130template (present) GSUP_IE tr_GSUP_IE_SUPPORTED_RAT_TYPES(template (present) GSUP_RatTypes ratt) := {
1131 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
Harald Welte8eebb6c2019-08-22 12:40:03 +02001132 len := ?,
1133 val := {
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001134 supported_rat_types := ratt
Harald Welte8eebb6c2019-08-22 12:40:03 +02001135 }
1136}
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001137template (value) GSUP_IE ts_GSUP_IE_SUPPORTED_RAT_TYPES(GSUP_RatTypes ratt) := {
1138 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
Harald Welte8eebb6c2019-08-22 12:40:03 +02001139 len := 0, /* overwritten */
1140 val := {
Harald Welte0a1fd0e2019-12-03 20:01:08 +01001141 supported_rat_types := ratt
1142 }
1143}
1144
1145template (present) GSUP_IE tr_GSUP_IE_CURRENT_RAT_TYPE(template (present) GSUP_RatType ratt) := {
1146 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1147 len := ?,
1148 val := {
1149 current_rat_type := ratt
1150 }
1151}
1152template (value) GSUP_IE ts_GSUP_IE_CURRENT_RAT_TYPE(GSUP_RatType ratt) := {
1153 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1154 len := 0, /* overwritten */
1155 val := {
1156 current_rat_type := ratt
Harald Welte8eebb6c2019-08-22 12:40:03 +02001157 }
1158}
1159
1160
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001161private function f_gen_ts_ss_ies(
1162 hexstring imsi,
1163 OCT4 sid,
1164 GSUP_SessionState state,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001165 template (omit) octetstring ss := omit,
1166 template (omit) integer cause := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001167) return GSUP_IEs {
1168 /* Mandatory IEs */
1169 var GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001170 valueof(ts_GSUP_IE_IMSI(imsi))
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001171 };
1172
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001173 /* Cause IE is needed for PROC_SS_ERR */
1174 if (isvalue(cause)) {
1175 ies := ies & { valueof(ts_GSUP_IE_Cause(valueof(cause))) };
1176 }
1177
1178 /* Mandatory session IEs */
1179 ies := ies & { valueof(ts_GSUP_IE_SessionId(sid)) };
1180 ies := ies & { valueof(ts_GSUP_IE_SessionState(state)) };
1181
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001182 /* Optional SS payload */
1183 if (isvalue(ss)) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001184 ies := ies & { valueof(ts_GSUP_IE_SSInfo(valueof(ss))) };
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001185 }
1186
1187 return ies;
1188}
1189private function f_gen_tr_ss_ies(
1190 template hexstring imsi,
1191 template OCT4 sid := ?,
1192 template GSUP_SessionState state := ?,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001193 template octetstring ss := omit,
1194 template integer cause := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001195) return template GSUP_IEs {
1196 /* Mandatory IEs */
1197 var template GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001198 tr_GSUP_IE_IMSI(imsi)
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001199 };
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001200 var integer idx := 1;
1201
1202 /* Cause IE is needed for PROC_SS_ERR */
1203 if (istemplatekind(cause, "*")) {
1204 ies[idx] := *;
1205 idx := idx + 1;
1206 } else if (not istemplatekind(cause, "omit")) {
1207 ies[idx] := tr_GSUP_IE_Cause(cause);
1208 idx := idx + 1;
1209 }
1210
1211 /* Mandatory session IEs */
1212 ies[idx] := tr_GSUP_IE_SessionId(sid);
1213 ies[idx + 1] := tr_GSUP_IE_SessionState(state);
1214 idx := idx + 2;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001215
1216 /* Optional SS payload */
1217 if (istemplatekind(ss, "*")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001218 ies[idx] := *;
1219 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001220 } else if (not istemplatekind(ss, "omit")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001221 ies[idx] := tr_GSUP_IE_SSInfo(ss);
1222 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001223 }
1224
Harald Welte0622a9f2019-05-11 10:58:15 +02001225 /* the GSUP Message Class IE is optional, as old implementations don't have it yet */
1226 var template GSUP_IEs ies2 := ies;
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001227 ies2[idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD);
1228 idx := idx + 1;
Harald Welte0622a9f2019-05-11 10:58:15 +02001229
1230 return (ies, ies2);
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001231}
1232
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001233template (value) GSUP_PDU ts_GSUP_PROC_SS_REQ(
1234 hexstring imsi,
1235 OCT4 sid,
1236 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001237 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001238) := ts_GSUP(
1239 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001240 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001241);
1242template GSUP_PDU tr_GSUP_PROC_SS_REQ(
1243 template hexstring imsi,
1244 template OCT4 sid := ?,
1245 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001246 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001247) := tr_GSUP(
1248 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001249 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001250);
1251
1252template (value) GSUP_PDU ts_GSUP_PROC_SS_RES(
1253 hexstring imsi,
1254 OCT4 sid,
1255 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001256 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001257) := ts_GSUP(
1258 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001259 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001260);
1261template GSUP_PDU tr_GSUP_PROC_SS_RES(
1262 template hexstring imsi,
1263 template OCT4 sid := ?,
1264 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001265 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001266) := tr_GSUP(
1267 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001268 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001269);
1270
1271template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR(
1272 hexstring imsi,
1273 OCT4 sid,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001274 GSUP_SessionState state,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001275 integer cause
1276) := ts_GSUP(
1277 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001278 f_gen_ts_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001279);
1280template GSUP_PDU tr_GSUP_PROC_SS_ERR(
1281 template hexstring imsi,
1282 template OCT4 sid := ?,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001283 template GSUP_SessionState state := ?,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001284 template integer cause := ?
1285) := tr_GSUP(
1286 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001287 f_gen_tr_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001288);
Harald Weltedf327232017-12-28 22:51:51 +01001289
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001290template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_REQ(
1291 hexstring imsi,
1292 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1293 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1294 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1295 octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1296) := ts_GSUP(
1297 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1298 {
1299 valueof(ts_GSUP_IE_IMSI(imsi)),
1300 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1301 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1302 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1303 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui))
1304 }
1305);
1306template GSUP_PDU tr_GSUP_MO_FORWARD_SM_REQ(
1307 template hexstring imsi := ?,
1308 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1309 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1310 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1311 template octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1312) := tr_GSUP(
1313 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1314 {
1315 tr_GSUP_IE_IMSI(imsi),
1316 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1317 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1318 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001319 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
1320 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001321 }
1322);
1323
1324template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_RES(
1325 hexstring imsi,
1326 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1327) := ts_GSUP(
1328 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1329 {
1330 valueof(ts_GSUP_IE_IMSI(imsi)),
1331 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1332 }
1333);
1334template GSUP_PDU tr_GSUP_MO_FORWARD_SM_RES(
1335 template hexstring imsi := ?,
1336 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1337) := tr_GSUP(
1338 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1339 {
1340 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001341 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1342 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001343 }
1344);
1345
1346template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_ERR(
1347 hexstring imsi,
1348 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1349 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1350) := ts_GSUP(
1351 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1352 {
1353 valueof(ts_GSUP_IE_IMSI(imsi)),
1354 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1355 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1356 }
1357);
1358template GSUP_PDU tr_GSUP_MO_FORWARD_SM_ERR(
1359 template hexstring imsi := ?,
1360 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1361 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1362) := tr_GSUP(
1363 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1364 {
1365 tr_GSUP_IE_IMSI(imsi),
1366 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001367 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1368 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001369 }
1370);
1371
1372template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_REQ(
1373 hexstring imsi,
1374 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1375 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1376 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1377 octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1378 OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1379) := ts_GSUP(
1380 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1381 {
1382 /**
1383 * TODO: add MT-specific fields (and IEs):
1384 * - smDeliveryTimer
1385 * - smDeliveryStartTime
1386 */
1387 valueof(ts_GSUP_IE_IMSI(imsi)),
1388 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1389 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1390 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1391 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
1392 valueof(ts_GSUP_IE_SM_RP_MMS(sm_rp_mms))
1393 }
1394);
1395template GSUP_PDU tr_GSUP_MT_FORWARD_SM_REQ(
1396 template hexstring imsi := ?,
1397 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1398 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1399 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1400 template octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1401 template OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1402) := tr_GSUP(
1403 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1404 {
1405 /**
1406 * TODO: add MT-specific fields (and IEs):
1407 * - smDeliveryTimer
1408 * - smDeliveryStartTime
1409 */
1410 tr_GSUP_IE_IMSI(imsi),
1411 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1412 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1413 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1414 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001415 tr_GSUP_IE_SM_RP_MMS(sm_rp_mms),
1416 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001417 }
1418);
1419
1420template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_RES(
1421 hexstring imsi,
1422 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1423) := ts_GSUP(
1424 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1425 {
1426 valueof(ts_GSUP_IE_IMSI(imsi)),
1427 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1428 }
1429);
1430template GSUP_PDU tr_GSUP_MT_FORWARD_SM_RES(
1431 template hexstring imsi := ?,
1432 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1433) := tr_GSUP(
1434 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1435 {
1436 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001437 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1438 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001439 }
1440);
1441
1442template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_ERR(
1443 hexstring imsi,
1444 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1445 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1446) := ts_GSUP(
1447 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1448 {
1449 valueof(ts_GSUP_IE_IMSI(imsi)),
1450 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1451 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1452 }
1453);
1454template GSUP_PDU tr_GSUP_MT_FORWARD_SM_ERR(
1455 template hexstring imsi := ?,
1456 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1457 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1458) := tr_GSUP(
1459 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1460 {
1461 tr_GSUP_IE_IMSI(imsi),
1462 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001463 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1464 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001465 }
1466);
1467
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001468template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_REQ(
1469 hexstring imsi,
1470 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1471 GSUP_SM_ALERT_RSN_Type sm_alert_rsn /* SM Alert Reason, see 7.6.8.8 */
1472) := ts_GSUP(
1473 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1474 {
1475 valueof(ts_GSUP_IE_IMSI(imsi)),
1476 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1477 valueof(ts_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn))
1478 }
1479);
1480template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_REQ(
1481 template hexstring imsi := ?,
1482 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1483 template GSUP_SM_ALERT_RSN_Type sm_alert_rsn := ? /* SM Alert Reason, see 7.6.8.8 */
1484) := tr_GSUP(
1485 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1486 {
1487 tr_GSUP_IE_IMSI(imsi),
1488 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001489 tr_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn),
1490 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001491 }
1492);
1493
1494template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_RES(
1495 hexstring imsi,
1496 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1497) := ts_GSUP(
1498 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1499 {
1500 valueof(ts_GSUP_IE_IMSI(imsi)),
1501 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1502 }
1503);
1504template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_RES(
1505 template hexstring imsi := ?,
1506 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1507) := tr_GSUP(
1508 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1509 {
1510 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001511 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1512 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001513 }
1514);
1515
1516template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_ERR(
1517 hexstring imsi,
1518 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1519 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1520) := ts_GSUP(
1521 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1522 {
1523 valueof(ts_GSUP_IE_IMSI(imsi)),
1524 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1525 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1526 }
1527);
1528template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_ERR(
1529 template hexstring imsi := ?,
1530 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1531 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1532) := tr_GSUP(
1533 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1534 {
1535 tr_GSUP_IE_IMSI(imsi),
1536 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001537 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1538 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001539 }
1540);
1541
Harald Welte8eebb6c2019-08-22 12:40:03 +02001542function f_gsup_find_nested_ie(GSUP_IEs ies, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1543 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1544 if (ies[i].tag == iei) {
1545 ret := ies[i].val;
Harald Weltef9d449e2018-06-24 22:27:47 +02001546 return true;
1547 }
1548 }
Harald Welte8eebb6c2019-08-22 12:40:03 +02001549 return false;
1550}
1551
1552function f_gsup_find_ie(GSUP_PDU msg, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1553 return f_gsup_find_nested_ie(msg.ies, iei, ret);
Harald Weltef9d449e2018-06-24 22:27:47 +02001554}
1555
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001556template GSUP_AN_APDU t_GSUP_AN_APDU(
1557 template GSUP_AN_PROTO an_proto := ?,
1558 template octetstring pdu := ?
1559) := {
1560 proto := an_proto,
1561 pdu := pdu
1562};
1563
1564template GSUP_PDU tr_GSUP_E_AN_APDU(
1565 template GSUP_MessageType msgt,
1566 template hexstring imsi := ?,
1567 template octetstring source_name := ?,
1568 template octetstring destination_name := ?,
1569 template GSUP_AN_APDU an_apdu := ?
1570) := tr_GSUP(
1571 msgt,
1572 {
1573 tr_GSUP_IE_IMSI(imsi),
1574 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1575 tr_GSUP_IE_Source_Name(source_name),
1576 tr_GSUP_IE_Destination_Name(destination_name),
1577 tr_GSUP_IE_AN_APDU(an_apdu)
1578 }
1579);
1580
1581template GSUP_PDU tr_GSUP_E_NO_PDU(
1582 template GSUP_MessageType msgt,
1583 template hexstring imsi := ?,
1584 template octetstring source_name := ?,
1585 template octetstring destination_name := ?
1586) := tr_GSUP(
1587 msgt,
1588 {
1589 tr_GSUP_IE_IMSI(imsi),
1590 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1591 tr_GSUP_IE_Source_Name(source_name),
1592 tr_GSUP_IE_Destination_Name(destination_name)
1593 }
1594);
1595
1596template (value) GSUP_PDU ts_GSUP_E_AN_APDU(
1597 GSUP_MessageType msgt,
1598 hexstring imsi,
1599 octetstring source_name,
1600 octetstring destination_name,
1601 GSUP_AN_APDU an_apdu
1602) := ts_GSUP(
1603 msgt,
1604 {
1605 valueof(ts_GSUP_IE_IMSI(imsi)),
1606 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1607 valueof(ts_GSUP_IE_Source_Name(source_name)),
1608 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1609 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1610 }
1611);
1612
1613template (value) GSUP_PDU ts_GSUP_E_PrepareHandoverResult(
1614 hexstring imsi,
1615 hexstring msisdn,
1616 octetstring source_name,
1617 octetstring destination_name,
1618 GSUP_AN_APDU an_apdu
1619) := ts_GSUP(
1620 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT,
1621 {
1622 valueof(ts_GSUP_IE_IMSI(imsi)),
1623 valueof(ts_GSUP_IE_MSISDN(msisdn)),
1624 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1625 valueof(ts_GSUP_IE_Source_Name(source_name)),
1626 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1627 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1628 }
1629);
Harald Weltef9d449e2018-06-24 22:27:47 +02001630
Harald Weltedf327232017-12-28 22:51:51 +01001631} with { encode "RAW"; variant "FIELDORDER(msb)" }