blob: e1aa24c131ac96c01b2451eb3438277a63a21de9 [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 Welte8eebb6c2019-08-22 12:40:03 +020046 OSMO_GSUP_RAT_TYPE_IE ('29'O),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +070047
48 OSMO_GSUP_SESSION_ID_IE ('30'O),
49 OSMO_GSUP_SESSION_STATE_IE ('31'O),
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +070050 OSMO_GSUP_SS_INFO_IE ('35'O),
51
52 /* SM related IEs (see 3GPP TS 29.002, section 7.6.8) */
53 OSMO_GSUP_SM_RP_MR_IE ('40'O),
54 OSMO_GSUP_SM_RP_DA_IE ('41'O),
55 OSMO_GSUP_SM_RP_OA_IE ('42'O),
56 OSMO_GSUP_SM_RP_UI_IE ('43'O),
57 OSMO_GSUP_SM_RP_CAUSE_IE ('44'O),
Vadim Yanitskiy88e23232018-11-13 03:04:02 +070058 OSMO_GSUP_SM_RP_MMS_IE ('45'O),
Oliver Smithc5748292019-02-22 15:02:48 +010059 OSMO_GSUP_SM_ALERT_RSN_IE ('46'O),
60
61 OSMO_GSUP_IMEI_IE ('50'O),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +020062 OSMO_GSUP_IMEI_RESULT_IE ('51'O),
63
64 OSMO_GSUP_MESSAGE_CLASS_IE ('0a'O),
65
66 OSMO_GSUP_SOURCE_NAME_IE ('60'O),
67 OSMO_GSUP_DESTINATION_NAME_IE ('61'O),
68 OSMO_GSUP_AN_APDU_IE ('62'O),
69 OSMO_GSUP_CAUSE_RR_IE ('63'O),
70 OSMO_GSUP_CAUSE_BSSAP_IE ('64'O),
71 OSMO_GSUP_CAUSE_SM_IE ('65'O)
Harald Weltedf327232017-12-28 22:51:51 +010072} with { variant "FIELDLENGTH(8)" };
73
74type enumerated GSUP_MessageType {
75 OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST ('00000100'B),
76 OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR ('00000101'B),
77 OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT ('00000110'B),
78
79 OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST ('00001000'B),
80 OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR ('00001001'B),
81 OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT ('00001010'B),
82
83 OSMO_GSUP_MSGT_AUTH_FAIL_REPORT ('00001011'B),
84
85 OSMO_GSUP_MSGT_PURGE_MS_REQUEST ('00001100'B),
86 OSMO_GSUP_MSGT_PURGE_MS_ERROR ('00001101'B),
87 OSMO_GSUP_MSGT_PURGE_MS_RESULT ('00001110'B),
88
89 OSMO_GSUP_MSGT_INSERT_DATA_REQUEST ('00010000'B),
90 OSMO_GSUP_MSGT_INSERT_DATA_ERROR ('00010001'B),
91 OSMO_GSUP_MSGT_INSERT_DATA_RESULT ('00010010'B),
92
93 OSMO_GSUP_MSGT_DELETE_DATA_REQUEST ('00010100'B),
94 OSMO_GSUP_MSGT_DELETE_DATA_ERROR ('00010101'B),
95 OSMO_GSUP_MSGT_DELETE_DATA_RESULT ('00010110'B),
96
97 OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST ('00011100'B),
98 OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR ('00011101'B),
Vadim Yanitskiyb761d142018-06-02 21:05:04 +070099 OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT ('00011110'B),
100
101 OSMO_GSUP_MSGT_PROC_SS_REQUEST ('00100000'B),
102 OSMO_GSUP_MSGT_PROC_SS_ERROR ('00100001'B),
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700103 OSMO_GSUP_MSGT_PROC_SS_RESULT ('00100010'B),
104
105 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST ('00100100'B),
106 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR ('00100101'B),
107 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT ('00100110'B),
108
109 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST ('00101000'B),
110 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR ('00101001'B),
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700111 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT ('00101010'B),
112
113 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST ('00101100'B),
114 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR ('00101101'B),
Oliver Smithc5748292019-02-22 15:02:48 +0100115 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT ('00101110'B),
116
117 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST ('00110000'B),
118 OSMO_GSUP_MSGT_CHECK_IMEI_ERROR ('00110001'B),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200119 OSMO_GSUP_MSGT_CHECK_IMEI_RESULT ('00110010'B),
120
121 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST ('00110100'B),
122 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_ERROR ('00110101'B),
123 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT ('00110110'B),
124
125 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST ('00111000'B),
126 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_ERROR ('00111001'B),
127 OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT ('00111010'B),
128
129 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST ('00111100'B),
130 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_ERROR ('00111101'B),
131 OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_RESULT ('00111110'B),
132
133 OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST ('01000000'B),
134 OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST ('01000100'B),
135
136 OSMO_GSUP_MSGT_E_CLOSE ('01000111'B),
137 OSMO_GSUP_MSGT_E_ABORT ('01001011'B),
138
139 OSMO_GSUP_MSGT_E_ROUTING_ERROR ('01001110'B)
Harald Weltedf327232017-12-28 22:51:51 +0100140} with { variant "FIELDLENGTH(8)" };
141
142type enumerated GSUP_CancelType {
Alexander Couzens4786b3f2018-09-16 03:33:30 +0200143 OSMO_GSUP_CANCEL_TYPE_UPDATE (0),
144 OSMO_GSUP_CANCEL_TYPE_WITHDRAW (1)
Harald Weltedf327232017-12-28 22:51:51 +0100145} with { variant "FIELDLENGTH(8)" };
146
147type enumerated GSUP_CnDomain {
148 OSMO_GSUP_CN_DOMAIN_PS (1),
149 OSMO_GSUP_CN_DOMAIN_CS (2)
150} with { variant "FIELDLENGTH(8)" };
151
Oliver Smithc5748292019-02-22 15:02:48 +0100152type enumerated GSUP_IMEIResult {
153 OSMO_GSUP_IMEI_RESULT_ACK (0),
154 OSMO_GSUP_IMEI_RESULT_NACK (1)
155} with { variant "FIELDLENGTH(8)" };
156
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700157type enumerated GSUP_SessionState {
158 OSMO_GSUP_SESSION_STATE_NONE (0),
159 OSMO_GSUP_SESSION_STATE_BEGIN (1),
160 OSMO_GSUP_SESSION_STATE_CONTINUE (2),
161 OSMO_GSUP_SESSION_STATE_END (3)
162} with { variant "FIELDLENGTH(8)" };
163
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200164type enumerated GSUP_Message_Class {
165 OSMO_GSUP_MESSAGE_CLASS_UNSET (0),
166 OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT (1),
167 OSMO_GSUP_MESSAGE_CLASS_SMS (2),
168 OSMO_GSUP_MESSAGE_CLASS_USSD (3),
169 OSMO_GSUP_MESSAGE_CLASS_INTER_MSC (4)
170} with { variant "FIELDLENGTH(8)" };
171
Harald Welte3f95be82018-01-27 00:48:13 +0100172type record GSUP_MSISDN {
173 uint8_t len,
174 hexstring digits optional
175} with { variant (len) "LENGTHTO(digits)" };
176
Oliver Smithc5748292019-02-22 15:02:48 +0100177type record GSUP_IMEI {
178 uint8_t len,
179 hexstring digits optional
180} with { variant (len) "LENGTHTO(digits)" };
181
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200182type enumerated GSUP_AN_PROTO {
183 OSMO_GSUP_AN_PROTO_48006 (1),
184 OSMO_GSUP_AN_PROTO_25413 (2)
185} with { variant "FIELDLENGTH(8)" };
186
187type record GSUP_AN_APDU {
188 GSUP_AN_PROTO proto,
189 octetstring pdu
190};
191
Harald Weltedf327232017-12-28 22:51:51 +0100192type record GSUP_IE {
193 GSUP_IEI tag,
194 uint8_t len,
195 GSUP_IeValue val
196} with { variant (len) "LENGTHTO(val)"
197 variant (val) "CROSSTAG(imsi, tag = OSMO_GSUP_IMSI_IE;
198 cause, tag = OSMO_GSUP_CAUSE_IE;
199 cancel_type, tag = OSMO_GSUP_CANCEL_TYPE_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100200 auth_tuple, tag = OSMO_GSUP_AUTH_TUPLE_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100201 auts, tag = OSMO_GSUP_AUTS_IE;
202 rand, tag = OSMO_GSUP_RAND_IE;
Harald Welte77a8eba2018-01-22 21:22:32 +0100203 sres, tag = OSMO_GSUP_SRES_IE;
204 kc, tag = OSMO_GSUP_KC_IE;
205 ik, tag = OSMO_GSUP_IK_IE;
206 ck, tag = OSMO_GSUP_CK_IE;
207 autn, tag = OSMO_GSUP_AUTN_IE;
208 res, tag = OSMO_GSUP_RES_IE;
Harald Weltedf327232017-12-28 22:51:51 +0100209 msisdn, tag = OSMO_GSUP_MSISDN_IE;
210 hlr_number, tag = OSMO_GSUP_HLR_NUMBER_IE;
211 cn_domain, tag = OSMO_GSUP_CN_DOMAIN_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100212 pdp_info, tag = OSMO_GSUP_PDP_INFO_IE;
213 apn, tag = OSMO_GSUP_ACCESS_POINT_NAME_IE;
214 pdp_qos, tag = OSMO_GSUP_PDP_QOS_IE;
215 pdp_type, tag = OSMO_GSUP_PDP_TYPE_IE;
216 charg_char, tag = OSMO_GSUP_CHARG_CHAR_IE;
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700217 session_state, tag = OSMO_GSUP_SESSION_STATE_IE;
218 session_id, tag = OSMO_GSUP_SESSION_ID_IE;
219 ss_info, tag = OSMO_GSUP_SS_INFO_IE;
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700220 sm_rp_mr, tag = OSMO_GSUP_SM_RP_MR_IE;
221 sm_rp_da, tag = OSMO_GSUP_SM_RP_DA_IE;
222 sm_rp_oa, tag = OSMO_GSUP_SM_RP_OA_IE;
223 sm_rp_ui, tag = OSMO_GSUP_SM_RP_UI_IE;
224 sm_rp_cause, tag = OSMO_GSUP_SM_RP_CAUSE_IE;
225 sm_rp_mms, tag = OSMO_GSUP_SM_RP_MMS_IE;
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700226 sm_alert_rsn, tag = OSMO_GSUP_SM_ALERT_RSN_IE;
Oliver Smithc5748292019-02-22 15:02:48 +0100227 imei, tag = OSMO_GSUP_IMEI_IE;
228 imei_result, tag = OSMO_GSUP_IMEI_RESULT_IE;
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200229 message_class, tag = OSMO_GSUP_MESSAGE_CLASS_IE;
230 source_name, tag = OSMO_GSUP_SOURCE_NAME_IE;
231 destination_name, tag = OSMO_GSUP_DESTINATION_NAME_IE;
232 an_apdu, tag = OSMO_GSUP_AN_APDU_IE;
233 cause_rr, tag = OSMO_GSUP_CAUSE_RR_IE;
234 cause_bssap, tag = OSMO_GSUP_CAUSE_BSSAP_IE;
235 cause_sm, tag = OSMO_GSUP_CAUSE_SM_IE;
Harald Welte8eebb6c2019-08-22 12:40:03 +0200236 rat_type, tag = OSMO_GSUP_RAT_TYPE_IE;
Harald Welteeded9ad2018-02-17 20:57:34 +0100237 )"
Harald Weltedf327232017-12-28 22:51:51 +0100238};
239
240type record of GSUP_IE GSUP_IEs;
241
Harald Welte8eebb6c2019-08-22 12:40:03 +0200242type enumerated GSUP_RatType {
243 RAT_TYPE_UNKNOWN (0),
244 RAT_TYPE_GERAN_A (1),
245 RAT_TYPE_UTRAN_Iu (2),
246 RAT_TYPE_EUTRAN_SGs (3)
247} with { variant "FIELDLENGTH(8)" };
248
249type record of GSUP_RatType GSUP_RatTypes;
250
Harald Weltedf327232017-12-28 22:51:51 +0100251type union GSUP_IeValue {
252 hexstring imsi,
253 integer cause,
254 GSUP_CancelType cancel_type,
255 //boolean pdp_info_compl,
256 //boolean freeze_ptmsi,
Harald Weltedf327232017-12-28 22:51:51 +0100257 GSUP_IEs auth_tuple,
258 octetstring auts,
259 octetstring rand,
Harald Welte77a8eba2018-01-22 21:22:32 +0100260 octetstring sres,
261 octetstring kc,
262 octetstring ik,
263 octetstring ck,
264 octetstring autn,
265 octetstring res,
Harald Welte3f95be82018-01-27 00:48:13 +0100266 GSUP_MSISDN msisdn,
Harald Weltedf327232017-12-28 22:51:51 +0100267 octetstring hlr_number,
268 GSUP_CnDomain cn_domain,
Harald Welteeded9ad2018-02-17 20:57:34 +0100269 /* PDP context + nested IEs */
270 GSUP_IEs pdp_info,
271 octetstring apn,
272 octetstring pdp_qos,
273 OCT2 pdp_type,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700274 octetstring charg_char,
275 /* Session information */
276 GSUP_SessionState session_state,
277 OCT4 session_id,
278 /* Supplementary Services */
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700279 octetstring ss_info,
280 /* Short Message Service */
281 OCT1 sm_rp_mr,
282 GSUP_SM_RP_DA sm_rp_da,
283 GSUP_SM_RP_OA sm_rp_oa,
284 octetstring sm_rp_ui,
285 OCT1 sm_rp_cause,
Vadim Yanitskiy88e23232018-11-13 03:04:02 +0700286 OCT1 sm_rp_mms,
Oliver Smithc5748292019-02-22 15:02:48 +0100287 GSUP_SM_ALERT_RSN_Type sm_alert_rsn,
288
289 GSUP_IMEI imei,
Neels Hofmeyr0ac63152019-05-07 01:20:17 +0200290 GSUP_IMEIResult imei_result,
291
292 GSUP_Message_Class message_class,
293
294 octetstring source_name,
295 octetstring destination_name,
296
297 GSUP_AN_APDU an_apdu,
298
299 OCT1 cause_rr,
300 OCT1 cause_bssap,
Harald Welte8eebb6c2019-08-22 12:40:03 +0200301 OCT1 cause_sm,
302
303 GSUP_RatTypes rat_type
Harald Weltedf327232017-12-28 22:51:51 +0100304};
305
306type record GSUP_PDU {
307 GSUP_MessageType msg_type,
308 GSUP_IEs ies
309};
310
311external function enc_GSUP_PDU(in GSUP_PDU msg) return octetstring
312 with { extension "prototype(convert) encode(RAW)" };
313
314external function dec_GSUP_PDU(in octetstring msg) return GSUP_PDU
315 with { extension "prototype(convert) decode(RAW)" };
316
Harald Welte2f562b12018-01-24 20:52:38 +0100317function f_gsup_postprocess_decoded(inout GSUP_PDU gsup) {
318 if (gsup.ies[0].tag == OSMO_GSUP_IMSI_IE) {
319 /* if last digit is 'F', then there's an odd number of digits and we must strip the F */
320 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
321 if (gsup.ies[0].val.imsi[num_digits-1] == 'F'H) {
322 gsup.ies[0].val.imsi := substr(gsup.ies[0].val.imsi, 0, num_digits-1);
323 }
324 }
325}
326
327function f_gsup_preprocess_encoded(inout GSUP_PDU gsup) {
328 if (ischosen(gsup.ies[0].val.imsi)) {
329 /* if number of digits is odd, add a 'F' as padding at the end */
330 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
331 if (num_digits rem 2 == 1) {
332 gsup.ies[0].val.imsi := gsup.ies[0].val.imsi & 'F'H;
333 }
334 }
335}
336
Harald Welte3f95be82018-01-27 00:48:13 +0100337template (value) GSUP_MSISDN ts_GSUP_MSISDN(hexstring digits,
338 BIT3 ton := '000'B,
339 BIT4 npi := '0000'B) := {
340 len := 0, /* overwritten */
341 /* numberingPlanIdentification := npi,
342 typeOfNumber := ton,
343 ext1 := '0'B, */
344 digits := digits
345}
346
347template GSUP_MSISDN tr_GSUP_MSISDN(template hexstring digits,
348 template BIT3 ton := ?,
349 template BIT4 npi := ?) := {
350 len := ?,
351 /* numberingPlanIdentification := npi,
352 typeOfNumber := ton,
353 ext1 := '0'B, */
354 digits := digits
355}
356
357
Harald Weltedf327232017-12-28 22:51:51 +0100358
Harald Welte77a8eba2018-01-22 21:22:32 +0100359template GSUP_IE ts_GSUP_IE_AuthTuple2G(octetstring rand, octetstring sres,
360 octetstring kc) := {
361 tag := OSMO_GSUP_AUTH_TUPLE_IE,
362 len := 0, /* overwritten */
363 val := {
364 auth_tuple := {
365 valueof(ts_GSUP_IE_RAND(rand)),
366 valueof(ts_GSUP_IE_SRES(sres)),
367 valueof(ts_GSUP_IE_Kc(kc))
368 }
369 }
370}
371
372template GSUP_IE ts_GSUP_IE_AuthTuple2G3G(octetstring rand, octetstring sres,
373 octetstring kc, octetstring ik,
374 octetstring ck, octetstring autn,
375 octetstring res) := {
376 tag := OSMO_GSUP_AUTH_TUPLE_IE,
377 len := 0, /* overwritten */
378 val := {
379 auth_tuple := {
380 valueof(ts_GSUP_IE_RAND(rand)),
381 valueof(ts_GSUP_IE_SRES(sres)),
382 valueof(ts_GSUP_IE_Kc(kc)),
383 valueof(ts_GSUP_IE_IK(ik)),
384 valueof(ts_GSUP_IE_CK(ck)),
385 valueof(ts_GSUP_IE_AUTN(autn)),
386 valueof(ts_GSUP_IE_RES(res))
387 }
388 }
389}
390
Harald Welteeded9ad2018-02-17 20:57:34 +0100391template GSUP_IE ts_GSUP_IE_PdpInfo(octetstring apn, octetstring pdp_type, octetstring pdp_qos) := {
392 tag := OSMO_GSUP_PDP_INFO_IE,
393 len := 0, /* overwritten */
394 val := {
395 pdp_info := {
396 valueof(ts_GSUP_IE_APN(apn)),
397 valueof(ts_GSUP_IE_PDP_TYPE(pdp_type)),
398 valueof(ts_GSUP_IE_PDP_QOS(pdp_qos))
399 }
400 }
401}
402
403template (value) GSUP_IE ts_GSUP_IE_PDP_TYPE(OCT2 pdp_type) := {
404 tag := OSMO_GSUP_PDP_TYPE_IE,
405 len := 0,
406 val := {
407 pdp_type := pdp_type
408 }
409}
410
411template (value) GSUP_IE ts_GSUP_IE_PDP_QOS(octetstring pdp_qos) := {
412 tag := OSMO_GSUP_PDP_QOS_IE,
413 len := 0,
414 val := {
415 pdp_qos := pdp_qos
416 }
417}
418
419
Harald Weltedf327232017-12-28 22:51:51 +0100420template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
421 msg_type := msgt,
422 ies := ies
423}
424
Harald Welte8a1dd532018-01-27 15:38:18 +0100425template GSUP_PDU tr_GSUP_IMSI(template GSUP_MessageType msgt := ?, template hexstring imsi) := {
426 msg_type := msgt,
427 ies := { tr_GSUP_IE_IMSI(imsi), * }
428}
429
Harald Weltedf327232017-12-28 22:51:51 +0100430template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
431 msg_type := msgt,
432 ies := ies
433}
434
Oliver Smith936dbe62019-06-04 15:54:17 +0200435template (value) GSUP_IMEI ts_GSUP_IMEI(hexstring digits) := {
436 len := 0, /* overwritten */
437 digits := digits
438}
439
440template GSUP_IMEI tr_GSUP_IMEI(template hexstring digits) := {
441 len := ?,
442 digits := digits
443}
444
445
Harald Welte6aa04e32018-01-27 15:35:19 +0100446template (value) GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
Harald Weltedf327232017-12-28 22:51:51 +0100447 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
448
Harald Welte8eebb6c2019-08-22 12:40:03 +0200449template (value) GSUP_PDU ts_GSUP_SAI_REQ_EPS(hexstring imsi) :=
450 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
451 valueof(ts_GSUP_IE_IMSI(imsi)),
452 valueof(ts_GSUP_IE_RAT_TYPE({RAT_TYPE_EUTRAN_SGs}))
453 });
454
Harald Welteef9fa872018-01-22 03:00:17 +0100455template GSUP_PDU tr_GSUP_SAI_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100456 tr_GSUP_IMSI(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, imsi);
Harald Welteef9fa872018-01-22 03:00:17 +0100457
Alexander Couzensd24973d2018-09-04 16:10:14 +0200458template GSUP_PDU tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC(
459 template hexstring imsi,
460 template octetstring auts,
461 template octetstring rand) :=
462 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
463 tr_GSUP_IE_IMSI(imsi),
464 tr_GSUP_IE_AUTS(auts),
465 tr_GSUP_IE_RAND(rand),
466 *
467 });
468
Harald Welte77a8eba2018-01-22 21:22:32 +0100469template (value) GSUP_PDU ts_GSUP_SAI_RES(hexstring imsi, GSUP_IE auth_tuple) :=
470 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
471 valueof(ts_GSUP_IE_IMSI(imsi)), auth_tuple });
472
Harald Weltedf327232017-12-28 22:51:51 +0100473template GSUP_PDU tr_GSUP_SAI_ERR(template hexstring imsi, template integer cause) :=
Harald Welte071ed732018-01-23 19:53:52 +0100474 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
Harald Weltedf327232017-12-28 22:51:51 +0100475 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
476
Harald Welte6aa04e32018-01-27 15:35:19 +0100477template (value) GSUP_PDU ts_GSUP_SAI_ERR(hexstring imsi, integer cause) :=
478 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
479 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
Harald Welte071ed732018-01-23 19:53:52 +0100480
481
Harald Weltedf327232017-12-28 22:51:51 +0100482template GSUP_PDU tr_GSUP_SAI_RES(template hexstring imsi) :=
Harald Weltec2c52552018-03-01 21:20:39 +0100483 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
Harald Weltedf327232017-12-28 22:51:51 +0100484 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE), * });
485
Harald Weltec2c52552018-03-01 21:20:39 +0100486template (value) GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi) :=
487 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, {
488 valueof(ts_GSUP_IE_IMSI(imsi)) });
489
Harald Weltedfe94dd2018-01-21 13:55:22 +0100490template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100491 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, imsi);
Harald Weltedfe94dd2018-01-21 13:55:22 +0100492
Harald Welte6aa04e32018-01-27 15:35:19 +0100493template (value) GSUP_PDU ts_GSUP_UL_RES(hexstring imsi) :=
Harald Weltedfe94dd2018-01-21 13:55:22 +0100494 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)) });
495
Harald Weltec2c52552018-03-01 21:20:39 +0100496template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi) :=
497 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, imsi);
498
Harald Welte6aa04e32018-01-27 15:35:19 +0100499template (value) GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100500 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
501 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
502
Harald Weltec2c52552018-03-01 21:20:39 +0100503template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?) :=
504 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
505 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
506
Harald Welte6aa04e32018-01-27 15:35:19 +0100507template (value) GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn) :=
Harald Welte6ff81902018-01-21 19:09:08 +0100508 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
509 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)) });
510
Harald Weltec2c52552018-03-01 21:20:39 +0100511template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?) :=
512 tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
Harald Welte8f6ac162018-03-01 22:43:28 +0100513 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_MSISDN(msisdn), * });
Harald Weltec2c52552018-03-01 21:20:39 +0100514
515template (value) GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi) :=
516 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, {
517 valueof(ts_GSUP_IE_IMSI(imsi)) });
518
Harald Welte6ff81902018-01-21 19:09:08 +0100519template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100520 tr_GSUP_IMSI(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100521
Harald Weltec638f4d2018-01-24 22:00:36 +0100522template GSUP_PDU tr_GSUP_AUTH_FAIL_IND(hexstring imsi) :=
Harald Welte8a1dd532018-01-27 15:38:18 +0100523 tr_GSUP_IMSI(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT, imsi);
Harald Weltedf327232017-12-28 22:51:51 +0100524
Harald Welte167458a2018-01-27 15:58:16 +0100525template (value) GSUP_PDU ts_GSUP_CL_REQ(hexstring imsi, GSUP_CancelType ctype) :=
526 ts_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST, {
527 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CancelType(ctype)) });
528
529template GSUP_PDU tr_GSUP_CL_RES(template hexstring imsi) :=
530 tr_GSUP_IMSI(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT, imsi);
531
532template GSUP_PDU tr_GSUP_CL_ERR(template hexstring imsi, template integer cause := ?) :=
533 tr_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR, {
Alexander Couzens4cfff3a2018-05-22 17:08:36 +0200534 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause), * });
Harald Welte167458a2018-01-27 15:58:16 +0100535
Harald Welte958f8b42018-03-01 23:40:17 +0100536template (value) GSUP_PDU ts_GSUP_PURGE_MS_REQ(hexstring imsi, GSUP_CnDomain dom) :=
537 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
538 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CnDomain(dom)) });
539
Harald Welte6abb9fe2018-02-17 15:24:48 +0100540template GSUP_PDU tr_GSUP_PURGE_MS_REQ(template hexstring imsi, template GSUP_CnDomain dom := ?) :=
541 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
542 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_CnDomain(dom) });
543
544template (value) GSUP_PDU ts_GSUP_PURGE_MS_RES(hexstring imsi) :=
545 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
546 valueof(ts_GSUP_IE_IMSI(imsi)) });
547
Harald Welte958f8b42018-03-01 23:40:17 +0100548template GSUP_PDU tr_GSUP_PURGE_MS_RES(template hexstring imsi) :=
549 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
550 tr_GSUP_IE_IMSI(imsi), * });
551
552template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer cause) :=
553 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
554 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
555
Oliver Smith936dbe62019-06-04 15:54:17 +0200556template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei) :=
557 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST, {
558 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI(imei)) });
559
Oliver Smith1d118ff2019-07-03 10:57:35 +0200560template GSUP_PDU tr_GSUP_CHECK_IMEI_REQ(
561 template hexstring imsi,
562 template hexstring imei
563) := tr_GSUP(
564 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST,
565 {
566 tr_GSUP_IE_IMSI(imsi),
567 tr_GSUP_IE_IMEI(imei),
568 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT)
569 }
570);
571
572template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_RES(hexstring imsi, GSUP_IMEIResult result) :=
573 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
574 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI_Result(result)) });
575
Oliver Smith936dbe62019-06-04 15:54:17 +0200576template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result) :=
577 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
578 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_IMEI_Result(result) });
579
Oliver Smith1d118ff2019-07-03 10:57:35 +0200580template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_ERR(hexstring imsi, integer cause) :=
581 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
582 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
583
Oliver Smith936dbe62019-06-04 15:54:17 +0200584template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause) :=
585 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
586 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
587
Harald Welte167458a2018-01-27 15:58:16 +0100588
589template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
590 tag := OSMO_GSUP_CANCEL_TYPE_IE,
591 len := 0, /* overwritten */
592 val := {
593 cancel_type := ctype
594 }
595}
596
597template GSUP_IE tr_GSUP_IE_CancelType(template GSUP_CancelType ctype) :=
598 tr_GSUP_IE(OSMO_GSUP_CANCEL_TYPE_IE, GSUP_IeValue:{cancel_type:=ctype});
599
Harald Welte6abb9fe2018-02-17 15:24:48 +0100600template GSUP_IE tr_GSUP_IE_CnDomain(template GSUP_CnDomain domain) :=
601 tr_GSUP_IE(OSMO_GSUP_CN_DOMAIN_IE, GSUP_IeValue:{cn_domain:=domain});
602
Harald Weltedf327232017-12-28 22:51:51 +0100603template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := {
604 tag := iei,
605 len := ?,
606 val := val
607}
608
609template (value) GSUP_IE ts_GSUP_IE_IMSI(hexstring imsi) := {
610 tag := OSMO_GSUP_IMSI_IE,
611 len := 0, /* overwritten */
612 val := {
613 imsi := imsi
614 }
615}
616
617template GSUP_IE tr_GSUP_IE_IMSI(template hexstring imsi) := {
618 tag := OSMO_GSUP_IMSI_IE,
619 len := ?,
620 val := {
621 imsi := imsi
622 }
623}
624
Harald Welte6ff81902018-01-21 19:09:08 +0100625template (value) GSUP_IE ts_GSUP_IE_MSISDN(hexstring msisdn) := {
626 tag := OSMO_GSUP_MSISDN_IE,
627 len := 0, /* overwritten */
628 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100629 msisdn := ts_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100630 }
631}
632
633template GSUP_IE tr_GSUP_IE_MSISDN(template hexstring msisdn) := {
634 tag := OSMO_GSUP_MSISDN_IE,
635 len := ?,
636 val := {
Harald Welte3f95be82018-01-27 00:48:13 +0100637 msisdn := tr_GSUP_MSISDN(msisdn)
Harald Welte6ff81902018-01-21 19:09:08 +0100638 }
639}
640
641
Harald Weltedf327232017-12-28 22:51:51 +0100642template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := {
643 tag := OSMO_GSUP_CAUSE_IE,
644 len := 0, /* overwritten */
645 val := {
646 cause := cause
647 }
648}
649
650template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := {
651 tag := OSMO_GSUP_CAUSE_IE,
652 len := ?,
653 val := {
654 cause := cause
655 }
656}
657
658template (value) GSUP_IE ts_GSUP_IE_AUTS(octetstring auts) := {
659 tag := OSMO_GSUP_AUTS_IE,
660 len := 0, /* overwritten */
661 val := {
662 auts := auts
663 }
664}
665
Alexander Couzensd24973d2018-09-04 16:10:14 +0200666template GSUP_IE tr_GSUP_IE_AUTS(template octetstring auts) := {
667 tag := OSMO_GSUP_AUTS_IE,
668 len := ?,
669 val := {
670 auts := auts
671 }
672}
673
Harald Weltedf327232017-12-28 22:51:51 +0100674template (value) GSUP_IE ts_GSUP_IE_RAND(octetstring rand) := {
675 tag := OSMO_GSUP_RAND_IE,
676 len := 0, /* overwritten */
677 val := {
678 rand := rand
679 }
680}
681
Alexander Couzensd24973d2018-09-04 16:10:14 +0200682template GSUP_IE tr_GSUP_IE_RAND(template octetstring rand) := {
683 tag := OSMO_GSUP_RAND_IE,
684 len := ?,
685 val := {
686 rand := rand
687 }
688}
689
Harald Welte77a8eba2018-01-22 21:22:32 +0100690template (value) GSUP_IE ts_GSUP_IE_SRES(octetstring sres) := {
691 tag := OSMO_GSUP_SRES_IE,
692 len := 0, /* overwritten */
693 val := {
694 sres := sres
695 }
696}
697
698template (value) GSUP_IE ts_GSUP_IE_Kc(octetstring kc) := {
699 tag := OSMO_GSUP_KC_IE,
700 len := 0, /* overwritten */
701 val := {
702 kc := kc
703 }
704}
705
706template (value) GSUP_IE ts_GSUP_IE_IK(octetstring ik) := {
707 tag := OSMO_GSUP_IK_IE,
708 len := 0, /* overwritten */
709 val := {
710 ik := ik
711 }
712}
713
714template (value) GSUP_IE ts_GSUP_IE_CK(octetstring ck) := {
715 tag := OSMO_GSUP_CK_IE,
716 len := 0, /* overwritten */
717 val := {
718 ck := ck
719 }
720}
721
722template (value) GSUP_IE ts_GSUP_IE_AUTN(octetstring autn) := {
723 tag := OSMO_GSUP_AUTN_IE,
724 len := 0, /* overwritten */
725 val := {
726 autn := autn
727 }
728}
729
730template (value) GSUP_IE ts_GSUP_IE_RES(octetstring res) := {
731 tag := OSMO_GSUP_RES_IE,
732 len := 0, /* overwritten */
733 val := {
734 res := res
735 }
736}
Harald Weltedf327232017-12-28 22:51:51 +0100737
Harald Welteeded9ad2018-02-17 20:57:34 +0100738template (value) GSUP_IE ts_GSUP_IE_APN(octetstring apn) := {
739 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
740 len := 0, /* overwritten */
741 val := {
742 apn := apn
743 }
744}
745
Harald Welte958f8b42018-03-01 23:40:17 +0100746template (value) GSUP_IE ts_GSUP_IE_CnDomain(GSUP_CnDomain dom) := {
747 tag := OSMO_GSUP_CN_DOMAIN_IE,
748 len := 0, /* overwritten */
749 val := {
750 cn_domain := dom
751 }
752}
Harald Weltedf327232017-12-28 22:51:51 +0100753
Vadim Yanitskiyb761d142018-06-02 21:05:04 +0700754template (value) GSUP_IE ts_GSUP_IE_SessionId(OCT4 sid) := {
755 tag := OSMO_GSUP_SESSION_ID_IE,
756 len := 0, /* overwritten */
757 val := {
758 session_id := sid
759 }
760}
761template GSUP_IE tr_GSUP_IE_SessionId(template OCT4 sid) := {
762 tag := OSMO_GSUP_SESSION_ID_IE,
763 len := ?,
764 val := {
765 session_id := sid
766 }
767}
768
769template (value) GSUP_IE ts_GSUP_IE_SessionState(GSUP_SessionState state) := {
770 tag := OSMO_GSUP_SESSION_STATE_IE,
771 len := 0, /* overwritten */
772 val := {
773 session_state := state
774 }
775}
776template GSUP_IE tr_GSUP_IE_SessionState(template GSUP_SessionState state) := {
777 tag := OSMO_GSUP_SESSION_STATE_IE,
778 len := ?,
779 val := {
780 session_state := state
781 }
782}
783
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700784template (value) GSUP_IE ts_GSUP_IE_SM_RP_MR(OCT1 ref) := {
785 tag := OSMO_GSUP_SM_RP_MR_IE,
786 len := 0, /* overwritten */
787 val := {
788 sm_rp_mr := ref
789 }
790}
791template GSUP_IE tr_GSUP_IE_SM_RP_MR(template OCT1 ref) := {
792 tag := OSMO_GSUP_SM_RP_MR_IE,
793 len := ?,
794 val := {
795 sm_rp_mr := ref
796 }
797}
798
799template (value) GSUP_IE ts_GSUP_IE_SM_RP_CAUSE(OCT1 cause) := {
800 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
801 len := 0, /* overwritten */
802 val := {
803 sm_rp_cause := cause
804 }
805}
806template GSUP_IE tr_GSUP_IE_SM_RP_CAUSE(template OCT1 cause) := {
807 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
808 len := ?,
809 val := {
810 sm_rp_cause := cause
811 }
812}
813
814template (value) GSUP_IE ts_GSUP_IE_SM_RP_MMS(OCT1 mms) := {
815 tag := OSMO_GSUP_SM_RP_MMS_IE,
816 len := 0, /* overwritten */
817 val := {
818 sm_rp_mms := mms
819 }
820}
821template GSUP_IE tr_GSUP_IE_SM_RP_MMS(template OCT1 mms) := {
822 tag := OSMO_GSUP_SM_RP_MMS_IE,
823 len := ?,
824 val := {
825 sm_rp_mms := mms
826 }
827}
828
Oliver Smith936dbe62019-06-04 15:54:17 +0200829template (value) GSUP_IE ts_GSUP_IE_IMEI(hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100830 tag := OSMO_GSUP_IMEI_IE,
831 len := 0, /* overwritten */
832 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +0200833 imei := ts_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +0100834 }
835}
Oliver Smith936dbe62019-06-04 15:54:17 +0200836template GSUP_IE tr_GSUP_IE_IMEI(template hexstring imei) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100837 tag := OSMO_GSUP_IMEI_IE,
838 len := ?,
839 val := {
Oliver Smith936dbe62019-06-04 15:54:17 +0200840 imei := tr_GSUP_IMEI(imei)
Oliver Smithc5748292019-02-22 15:02:48 +0100841 }
842}
843
Oliver Smith936dbe62019-06-04 15:54:17 +0200844template (value) GSUP_IE ts_GSUP_IE_IMEI_Result(GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100845 tag := OSMO_GSUP_IMEI_RESULT_IE,
846 len := 0, /* overwritten */
847 val := {
848 imei_result := result
849 }
850}
Oliver Smith936dbe62019-06-04 15:54:17 +0200851template GSUP_IE tr_GSUP_IE_IMEI_Result(template GSUP_IMEIResult result) := {
Oliver Smithc5748292019-02-22 15:02:48 +0100852 tag := OSMO_GSUP_IMEI_RESULT_IE,
853 len := ?,
854 val := {
855 imei_result := result
856 }
857}
858
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700859/* Possible identity types for SM-RP-{OA|DA} IEs */
860type enumerated GSUP_SM_RP_ODA_IdType {
861 OSMO_GSUP_SM_RP_ODA_ID_NONE ('00'O),
862 OSMO_GSUP_SM_RP_ODA_ID_IMSI ('01'O),
863 OSMO_GSUP_SM_RP_ODA_ID_MSISDN ('02'O),
864 OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR ('03'O),
865 /* Special value for noSM-RP-DA and noSM-RP-OA */
866 OSMO_GSUP_SM_RP_ODA_ID_NULL ('FF'O)
867} with { variant "FIELDLENGTH(8)" };
868
869/**
870 * SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
871 * It can be either of the following:
872 * - IMSI
873 * - LMSI (not implemented)
874 * - MSISDN
875 * - roaming number (not implemented)
876 * - service centre address
877 */
878type union GSUP_SM_RP_DA_ID {
879 hexstring imsi,
880 hexstring msisdn,
881 hexstring smsc_addr
882};
883
884type record GSUP_SM_RP_DA {
885 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700886 GSUP_SM_RP_DA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +0700887} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700888 imsi, id_type = OSMO_GSUP_SM_RP_ODA_ID_IMSI;
889 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
890 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
891 /* FIXME: how to handle noSM-RP-DA? */
892 )"
893};
894
895template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_IMSI(hexstring imsi) := {
896 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700897 id_enc := { imsi := imsi }
898}
899template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_IMSI(template hexstring imsi) := {
900 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700901 id_enc := { imsi := imsi }
902}
903
904template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(hexstring msisdn) := {
905 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700906 id_enc := { msisdn := msisdn }
907}
908template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template hexstring msisdn) := {
909 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700910 id_enc := { msisdn := msisdn }
911}
912
913template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(hexstring smsc_addr) := {
914 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700915 id_enc := { smsc_addr := smsc_addr }
916}
917template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template hexstring smsc_addr) := {
918 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700919 id_enc := { smsc_addr := smsc_addr }
920}
921
922template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_NULL := {
923 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700924 id_enc := omit
925}
926template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_NULL := {
927 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700928 id_enc := omit
929}
930
931template (value) GSUP_IE ts_GSUP_IE_SM_RP_DA(GSUP_SM_RP_DA val) := {
932 tag := OSMO_GSUP_SM_RP_DA_IE,
933 len := 0, /* overwritten */
934 val := {
935 sm_rp_da := val
936 }
937}
938template GSUP_IE tr_GSUP_IE_SM_RP_DA(template GSUP_SM_RP_DA val) := {
939 tag := OSMO_GSUP_SM_RP_DA_IE,
940 len := ?,
941 val := {
942 sm_rp_da := val
943 }
944}
945
946/**
947 * SM-RP-OA represents the SM Originating Address, see 7.6.8.2.
948 * It can be either of the following:
949 * - MSISDN
950 * - service centre address
951 */
952type union GSUP_SM_RP_OA_ID {
953 hexstring msisdn,
954 hexstring smsc_addr
955};
956
957type record GSUP_SM_RP_OA {
958 GSUP_SM_RP_ODA_IdType id_type,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700959 GSUP_SM_RP_OA_ID id_enc optional
Vadim Yanitskiyf1f39bd2018-12-14 08:00:33 +0700960} with { variant (id_enc) "CROSSTAG(
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700961 msisdn, id_type = OSMO_GSUP_SM_RP_ODA_ID_MSISDN;
962 smsc_addr, id_type = OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR;
963 /* FIXME: how to handle noSM-RP-OA? */
964 )"
965};
966
967template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(hexstring msisdn) := {
968 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700969 id_enc := { msisdn := msisdn }
970}
971template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template hexstring msisdn) := {
972 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700973 id_enc := { msisdn := msisdn }
974}
975
976template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(hexstring smsc_addr) := {
977 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700978 id_enc := { smsc_addr := smsc_addr }
979}
980template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template hexstring smsc_addr) := {
981 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700982 id_enc := { smsc_addr := smsc_addr }
983}
984
985template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_NULL := {
986 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700987 id_enc := omit
988}
989template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_NULL := {
990 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +0700991 id_enc := omit
992}
993
994template (value) GSUP_IE ts_GSUP_IE_SM_RP_OA(GSUP_SM_RP_OA val) := {
995 tag := OSMO_GSUP_SM_RP_OA_IE,
996 len := 0, /* overwritten */
997 val := {
998 sm_rp_oa := val
999 }
1000}
1001template GSUP_IE tr_GSUP_IE_SM_RP_OA(template GSUP_SM_RP_OA val) := {
1002 tag := OSMO_GSUP_SM_RP_OA_IE,
1003 len := ?,
1004 val := {
1005 sm_rp_oa := val
1006 }
1007}
1008
1009/* SM-RP-UI represents the SM TPDU, see 7.6.8.4 */
1010template (value) GSUP_IE ts_GSUP_IE_SM_RP_UI(octetstring val) := {
1011 tag := OSMO_GSUP_SM_RP_UI_IE,
1012 len := 0, /* overwritten */
1013 val := {
1014 sm_rp_ui := val
1015 }
1016}
1017template GSUP_IE tr_GSUP_IE_SM_RP_UI(template octetstring val) := {
1018 tag := OSMO_GSUP_SM_RP_UI_IE,
1019 len := ?,
1020 val := {
1021 sm_rp_ui := val
1022 }
1023}
1024
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001025/* SM Alert Reason types, see 7.6.8.8 */
1026type enumerated GSUP_SM_ALERT_RSN_Type {
1027 GSUP_SM_ALERT_RSN_TYPE_NONE ('00'O),
1028 GSUP_SM_ALERT_RSN_TYPE_MS_PRESENT ('01'O),
1029 GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL ('02'O)
1030} with { variant "FIELDLENGTH(8)" };
1031
1032/* SM Alert Reason IE (used in READY-FOR-SM), see 7.6.8.8 */
1033template (value) GSUP_IE ts_GSUP_IE_SM_ALERT_RSN(GSUP_SM_ALERT_RSN_Type rsn) := {
1034 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1035 len := 0, /* overwritten */
1036 val := {
1037 sm_alert_rsn := rsn
1038 }
1039}
1040template GSUP_IE tr_GSUP_IE_SM_ALERT_RSN(template GSUP_SM_ALERT_RSN_Type rsn) := {
1041 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1042 len := ?,
1043 val := {
1044 sm_alert_rsn := rsn
1045 }
1046}
1047
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001048template (value) GSUP_IE ts_GSUP_IE_SSInfo(octetstring ss) := {
1049 tag := OSMO_GSUP_SS_INFO_IE,
1050 len := 0, /* overwritten */
1051 val := {
1052 ss_info := ss
1053 }
1054}
1055template GSUP_IE tr_GSUP_IE_SSInfo(template octetstring ss) := {
1056 tag := OSMO_GSUP_SS_INFO_IE,
1057 len := ?,
1058 val := {
1059 ss_info := ss
1060 }
1061}
1062
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001063template GSUP_IE tr_GSUP_IE_Message_Class(template GSUP_Message_Class val) := {
1064 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1065 len := ?,
1066 val := {
1067 message_class := val
1068 }
1069}
1070
1071template (value) GSUP_IE ts_GSUP_IE_Message_Class(GSUP_Message_Class val) := {
1072 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1073 len := 0, /* overwritten */
1074 val := {
1075 message_class := val
1076 }
1077}
1078
1079template GSUP_IE tr_GSUP_IE_Source_Name(template octetstring name) := {
1080 tag := OSMO_GSUP_SOURCE_NAME_IE,
1081 len := ?,
1082 val := {
1083 source_name := name
1084 }
1085}
1086
1087template (value) GSUP_IE ts_GSUP_IE_Source_Name(octetstring name) := {
1088 tag := OSMO_GSUP_SOURCE_NAME_IE,
1089 len := 0, /* overwritten */
1090 val := {
1091 source_name := name
1092 }
1093}
1094
1095template GSUP_IE tr_GSUP_IE_Destination_Name(template octetstring name) := {
1096 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1097 len := ?,
1098 val := {
1099 destination_name := name
1100 }
1101}
1102
1103template (value) GSUP_IE ts_GSUP_IE_Destination_Name(octetstring name) := {
1104 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1105 len := 0, /* overwritten */
1106 val := {
1107 destination_name := name
1108 }
1109}
1110
1111template GSUP_IE tr_GSUP_IE_AN_APDU(template GSUP_AN_APDU an_apdu) := {
1112 tag := OSMO_GSUP_AN_APDU_IE,
1113 len := ?,
1114 val := {
1115 an_apdu := an_apdu
1116 }
1117}
1118
1119template (value) GSUP_IE ts_GSUP_IE_AN_APDU(GSUP_AN_APDU an_apdu) := {
1120 tag := OSMO_GSUP_AN_APDU_IE,
1121 len := 0, /* overwritten */
1122 val := {
1123 an_apdu := an_apdu
1124 }
1125}
1126
Harald Welte8eebb6c2019-08-22 12:40:03 +02001127
1128template (present) GSUP_IE tr_GSUP_IE_RAT_TYPE(template (present) GSUP_RatTypes ratt) := {
1129 tag := OSMO_GSUP_RAT_TYPE_IE,
1130 len := ?,
1131 val := {
1132 rat_type := ratt
1133 }
1134}
1135template (value) GSUP_IE ts_GSUP_IE_RAT_TYPE(GSUP_RatTypes ratt) := {
1136 tag := OSMO_GSUP_RAT_TYPE_IE,
1137 len := 0, /* overwritten */
1138 val := {
1139 rat_type := ratt
1140 }
1141}
1142
1143
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001144private function f_gen_ts_ss_ies(
1145 hexstring imsi,
1146 OCT4 sid,
1147 GSUP_SessionState state,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001148 template (omit) octetstring ss := omit,
1149 template (omit) integer cause := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001150) return GSUP_IEs {
1151 /* Mandatory IEs */
1152 var GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001153 valueof(ts_GSUP_IE_IMSI(imsi))
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001154 };
1155
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001156 /* Cause IE is needed for PROC_SS_ERR */
1157 if (isvalue(cause)) {
1158 ies := ies & { valueof(ts_GSUP_IE_Cause(valueof(cause))) };
1159 }
1160
1161 /* Mandatory session IEs */
1162 ies := ies & { valueof(ts_GSUP_IE_SessionId(sid)) };
1163 ies := ies & { valueof(ts_GSUP_IE_SessionState(state)) };
1164
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001165 /* Optional SS payload */
1166 if (isvalue(ss)) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001167 ies := ies & { valueof(ts_GSUP_IE_SSInfo(valueof(ss))) };
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001168 }
1169
1170 return ies;
1171}
1172private function f_gen_tr_ss_ies(
1173 template hexstring imsi,
1174 template OCT4 sid := ?,
1175 template GSUP_SessionState state := ?,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001176 template octetstring ss := omit,
1177 template integer cause := omit
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001178) return template GSUP_IEs {
1179 /* Mandatory IEs */
1180 var template GSUP_IEs ies := {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001181 tr_GSUP_IE_IMSI(imsi)
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001182 };
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001183 var integer idx := 1;
1184
1185 /* Cause IE is needed for PROC_SS_ERR */
1186 if (istemplatekind(cause, "*")) {
1187 ies[idx] := *;
1188 idx := idx + 1;
1189 } else if (not istemplatekind(cause, "omit")) {
1190 ies[idx] := tr_GSUP_IE_Cause(cause);
1191 idx := idx + 1;
1192 }
1193
1194 /* Mandatory session IEs */
1195 ies[idx] := tr_GSUP_IE_SessionId(sid);
1196 ies[idx + 1] := tr_GSUP_IE_SessionState(state);
1197 idx := idx + 2;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001198
1199 /* Optional SS payload */
1200 if (istemplatekind(ss, "*")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001201 ies[idx] := *;
1202 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001203 } else if (not istemplatekind(ss, "omit")) {
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001204 ies[idx] := tr_GSUP_IE_SSInfo(ss);
1205 idx := idx + 1;
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001206 }
1207
Harald Welte0622a9f2019-05-11 10:58:15 +02001208 /* the GSUP Message Class IE is optional, as old implementations don't have it yet */
1209 var template GSUP_IEs ies2 := ies;
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001210 ies2[idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD);
1211 idx := idx + 1;
Harald Welte0622a9f2019-05-11 10:58:15 +02001212
1213 return (ies, ies2);
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001214}
1215
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001216template (value) GSUP_PDU ts_GSUP_PROC_SS_REQ(
1217 hexstring imsi,
1218 OCT4 sid,
1219 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001220 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001221) := ts_GSUP(
1222 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001223 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001224);
1225template GSUP_PDU tr_GSUP_PROC_SS_REQ(
1226 template hexstring imsi,
1227 template OCT4 sid := ?,
1228 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001229 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001230) := tr_GSUP(
1231 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001232 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001233);
1234
1235template (value) GSUP_PDU ts_GSUP_PROC_SS_RES(
1236 hexstring imsi,
1237 OCT4 sid,
1238 GSUP_SessionState state,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001239 template (omit) octetstring ss := omit
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001240) := ts_GSUP(
1241 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001242 f_gen_ts_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001243);
1244template GSUP_PDU tr_GSUP_PROC_SS_RES(
1245 template hexstring imsi,
1246 template OCT4 sid := ?,
1247 template GSUP_SessionState state := ?,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001248 template octetstring ss := *
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001249) := tr_GSUP(
1250 OSMO_GSUP_MSGT_PROC_SS_RESULT,
Vadim Yanitskiy911257e2018-06-21 04:18:54 +07001251 f_gen_tr_ss_ies(imsi, sid, state, ss)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001252);
1253
1254template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR(
1255 hexstring imsi,
1256 OCT4 sid,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001257 GSUP_SessionState state,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001258 integer cause
1259) := ts_GSUP(
1260 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001261 f_gen_ts_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001262);
1263template GSUP_PDU tr_GSUP_PROC_SS_ERR(
1264 template hexstring imsi,
1265 template OCT4 sid := ?,
Vadim Yanitskiy21c42332018-11-29 00:18:05 +07001266 template GSUP_SessionState state := ?,
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001267 template integer cause := ?
1268) := tr_GSUP(
1269 OSMO_GSUP_MSGT_PROC_SS_ERROR,
Vadim Yanitskiy6c9fafc2019-06-15 02:51:22 +07001270 f_gen_tr_ss_ies(imsi, sid, state, cause := cause)
Vadim Yanitskiyb761d142018-06-02 21:05:04 +07001271);
Harald Weltedf327232017-12-28 22:51:51 +01001272
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001273template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_REQ(
1274 hexstring imsi,
1275 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1276 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1277 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1278 octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1279) := ts_GSUP(
1280 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1281 {
1282 valueof(ts_GSUP_IE_IMSI(imsi)),
1283 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1284 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1285 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1286 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui))
1287 }
1288);
1289template GSUP_PDU tr_GSUP_MO_FORWARD_SM_REQ(
1290 template hexstring imsi := ?,
1291 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1292 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1293 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1294 template octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1295) := tr_GSUP(
1296 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1297 {
1298 tr_GSUP_IE_IMSI(imsi),
1299 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1300 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1301 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001302 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
1303 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001304 }
1305);
1306
1307template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_RES(
1308 hexstring imsi,
1309 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1310) := ts_GSUP(
1311 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1312 {
1313 valueof(ts_GSUP_IE_IMSI(imsi)),
1314 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1315 }
1316);
1317template GSUP_PDU tr_GSUP_MO_FORWARD_SM_RES(
1318 template hexstring imsi := ?,
1319 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1320) := tr_GSUP(
1321 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1322 {
1323 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001324 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1325 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001326 }
1327);
1328
1329template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_ERR(
1330 hexstring imsi,
1331 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1332 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1333) := ts_GSUP(
1334 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1335 {
1336 valueof(ts_GSUP_IE_IMSI(imsi)),
1337 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1338 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1339 }
1340);
1341template GSUP_PDU tr_GSUP_MO_FORWARD_SM_ERR(
1342 template hexstring imsi := ?,
1343 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1344 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1345) := tr_GSUP(
1346 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1347 {
1348 tr_GSUP_IE_IMSI(imsi),
1349 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001350 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1351 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001352 }
1353);
1354
1355template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_REQ(
1356 hexstring imsi,
1357 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1358 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1359 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1360 octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1361 OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1362) := ts_GSUP(
1363 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1364 {
1365 /**
1366 * TODO: add MT-specific fields (and IEs):
1367 * - smDeliveryTimer
1368 * - smDeliveryStartTime
1369 */
1370 valueof(ts_GSUP_IE_IMSI(imsi)),
1371 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1372 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1373 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1374 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
1375 valueof(ts_GSUP_IE_SM_RP_MMS(sm_rp_mms))
1376 }
1377);
1378template GSUP_PDU tr_GSUP_MT_FORWARD_SM_REQ(
1379 template hexstring imsi := ?,
1380 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1381 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1382 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1383 template octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1384 template OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1385) := tr_GSUP(
1386 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1387 {
1388 /**
1389 * TODO: add MT-specific fields (and IEs):
1390 * - smDeliveryTimer
1391 * - smDeliveryStartTime
1392 */
1393 tr_GSUP_IE_IMSI(imsi),
1394 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1395 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1396 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1397 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001398 tr_GSUP_IE_SM_RP_MMS(sm_rp_mms),
1399 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001400 }
1401);
1402
1403template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_RES(
1404 hexstring imsi,
1405 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1406) := ts_GSUP(
1407 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1408 {
1409 valueof(ts_GSUP_IE_IMSI(imsi)),
1410 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1411 }
1412);
1413template GSUP_PDU tr_GSUP_MT_FORWARD_SM_RES(
1414 template hexstring imsi := ?,
1415 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1416) := tr_GSUP(
1417 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1418 {
1419 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001420 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1421 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001422 }
1423);
1424
1425template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_ERR(
1426 hexstring imsi,
1427 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1428 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1429) := ts_GSUP(
1430 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1431 {
1432 valueof(ts_GSUP_IE_IMSI(imsi)),
1433 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1434 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1435 }
1436);
1437template GSUP_PDU tr_GSUP_MT_FORWARD_SM_ERR(
1438 template hexstring imsi := ?,
1439 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1440 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1441) := tr_GSUP(
1442 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1443 {
1444 tr_GSUP_IE_IMSI(imsi),
1445 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001446 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1447 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy8a1d4b62018-09-23 20:28:23 +07001448 }
1449);
1450
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001451template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_REQ(
1452 hexstring imsi,
1453 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1454 GSUP_SM_ALERT_RSN_Type sm_alert_rsn /* SM Alert Reason, see 7.6.8.8 */
1455) := ts_GSUP(
1456 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1457 {
1458 valueof(ts_GSUP_IE_IMSI(imsi)),
1459 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1460 valueof(ts_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn))
1461 }
1462);
1463template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_REQ(
1464 template hexstring imsi := ?,
1465 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1466 template GSUP_SM_ALERT_RSN_Type sm_alert_rsn := ? /* SM Alert Reason, see 7.6.8.8 */
1467) := tr_GSUP(
1468 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1469 {
1470 tr_GSUP_IE_IMSI(imsi),
1471 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001472 tr_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn),
1473 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001474 }
1475);
1476
1477template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_RES(
1478 hexstring imsi,
1479 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1480) := ts_GSUP(
1481 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1482 {
1483 valueof(ts_GSUP_IE_IMSI(imsi)),
1484 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr))
1485 }
1486);
1487template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_RES(
1488 template hexstring imsi := ?,
1489 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1490) := tr_GSUP(
1491 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1492 {
1493 tr_GSUP_IE_IMSI(imsi),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001494 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1495 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001496 }
1497);
1498
1499template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_ERR(
1500 hexstring imsi,
1501 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1502 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1503) := ts_GSUP(
1504 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1505 {
1506 valueof(ts_GSUP_IE_IMSI(imsi)),
1507 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1508 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause))
1509 }
1510);
1511template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_ERR(
1512 template hexstring imsi := ?,
1513 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1514 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1515) := tr_GSUP(
1516 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1517 {
1518 tr_GSUP_IE_IMSI(imsi),
1519 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001520 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1521 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS)
Vadim Yanitskiy88e23232018-11-13 03:04:02 +07001522 }
1523);
1524
Harald Welte8eebb6c2019-08-22 12:40:03 +02001525function f_gsup_find_nested_ie(GSUP_IEs ies, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1526 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1527 if (ies[i].tag == iei) {
1528 ret := ies[i].val;
Harald Weltef9d449e2018-06-24 22:27:47 +02001529 return true;
1530 }
1531 }
Harald Welte8eebb6c2019-08-22 12:40:03 +02001532 return false;
1533}
1534
1535function f_gsup_find_ie(GSUP_PDU msg, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1536 return f_gsup_find_nested_ie(msg.ies, iei, ret);
Harald Weltef9d449e2018-06-24 22:27:47 +02001537}
1538
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001539template GSUP_AN_APDU t_GSUP_AN_APDU(
1540 template GSUP_AN_PROTO an_proto := ?,
1541 template octetstring pdu := ?
1542) := {
1543 proto := an_proto,
1544 pdu := pdu
1545};
1546
1547template GSUP_PDU tr_GSUP_E_AN_APDU(
1548 template GSUP_MessageType msgt,
1549 template hexstring imsi := ?,
1550 template octetstring source_name := ?,
1551 template octetstring destination_name := ?,
1552 template GSUP_AN_APDU an_apdu := ?
1553) := tr_GSUP(
1554 msgt,
1555 {
1556 tr_GSUP_IE_IMSI(imsi),
1557 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1558 tr_GSUP_IE_Source_Name(source_name),
1559 tr_GSUP_IE_Destination_Name(destination_name),
1560 tr_GSUP_IE_AN_APDU(an_apdu)
1561 }
1562);
1563
1564template GSUP_PDU tr_GSUP_E_NO_PDU(
1565 template GSUP_MessageType msgt,
1566 template hexstring imsi := ?,
1567 template octetstring source_name := ?,
1568 template octetstring destination_name := ?
1569) := tr_GSUP(
1570 msgt,
1571 {
1572 tr_GSUP_IE_IMSI(imsi),
1573 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1574 tr_GSUP_IE_Source_Name(source_name),
1575 tr_GSUP_IE_Destination_Name(destination_name)
1576 }
1577);
1578
1579template (value) GSUP_PDU ts_GSUP_E_AN_APDU(
1580 GSUP_MessageType msgt,
1581 hexstring imsi,
1582 octetstring source_name,
1583 octetstring destination_name,
1584 GSUP_AN_APDU an_apdu
1585) := ts_GSUP(
1586 msgt,
1587 {
1588 valueof(ts_GSUP_IE_IMSI(imsi)),
1589 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1590 valueof(ts_GSUP_IE_Source_Name(source_name)),
1591 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1592 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1593 }
1594);
1595
1596template (value) GSUP_PDU ts_GSUP_E_PrepareHandoverResult(
1597 hexstring imsi,
1598 hexstring msisdn,
1599 octetstring source_name,
1600 octetstring destination_name,
1601 GSUP_AN_APDU an_apdu
1602) := ts_GSUP(
1603 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT,
1604 {
1605 valueof(ts_GSUP_IE_IMSI(imsi)),
1606 valueof(ts_GSUP_IE_MSISDN(msisdn)),
1607 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1608 valueof(ts_GSUP_IE_Source_Name(source_name)),
1609 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1610 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1611 }
1612);
Harald Weltef9d449e2018-06-24 22:27:47 +02001613
Harald Weltedf327232017-12-28 22:51:51 +01001614} with { encode "RAW"; variant "FIELDORDER(msb)" }