blob: 403af743b98c940f9d8c8a633ce9285077edbb30 [file] [log] [blame]
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001module GSUP_Templates {
2
3/* GSUP_Templates, defining TTCN-3 templates 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 *
8 * (C) 2017-2019 by Harald Welte <laforge@gnumonks.org>
9 * contributions by sysmocom - s.f.m.c. GmbH
10 * All rights reserved.
11 *
12 * Released under the terms of GNU General Public License, Version 2 or
13 * (at your option) any later version.
14 *
15 * SPDX-License-Identifier: GPL-2.0-or-later
16 */
17
18import from General_Types all;
19import from Osmocom_Types all;
Pau Espin Pedrolce1d3cb2024-02-21 17:40:59 +010020import from PCO_Types all;
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +010021import from GSUP_Types all;
22
23function f_gsup_postprocess_decoded(inout GSUP_PDU gsup) {
24 if (gsup.ies[0].tag == OSMO_GSUP_IMSI_IE) {
25 /* if last digit is 'F', then there's an odd number of digits and we must strip the F */
26 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
27 if (gsup.ies[0].val.imsi[num_digits-1] == 'F'H) {
28 gsup.ies[0].val.imsi := substr(gsup.ies[0].val.imsi, 0, num_digits-1);
29 }
30 }
31}
32
33function f_gsup_preprocess_encoded(inout GSUP_PDU gsup) {
34 if (ischosen(gsup.ies[0].val.imsi)) {
35 /* if number of digits is odd, add a 'F' as padding at the end */
36 var integer num_digits := lengthof(gsup.ies[0].val.imsi);
37 if (num_digits rem 2 == 1) {
38 gsup.ies[0].val.imsi := gsup.ies[0].val.imsi & 'F'H;
39 }
40 }
41}
42
43template (value) GSUP_MSISDN ts_GSUP_MSISDN(hexstring digits,
44 BIT3 ton := '000'B,
45 BIT4 npi := '0000'B) := {
46 len := 0, /* overwritten */
47 /* numberingPlanIdentification := npi,
48 typeOfNumber := ton,
49 ext1 := '0'B, */
50 digits := digits
51}
52
53template GSUP_MSISDN tr_GSUP_MSISDN(template hexstring digits,
54 template BIT3 ton := ?,
55 template BIT4 npi := ?) := {
56 len := ?,
57 /* numberingPlanIdentification := npi,
58 typeOfNumber := ton,
59 ext1 := '0'B, */
60 digits := digits
61}
62
Pau Espin Pedrol7b7a1e82024-01-19 20:49:28 +010063template (value) GSUP_PDP_Address ts_GSUP_PDP_Address_IPv4(template (omit) OCT4 ip_addr) := {
64 ipv4 := {
Pau Espin Pedrol7b7a1e82024-01-19 20:49:28 +010065 spare := '1111'B,
Pau Espin Pedrola518d052024-01-30 12:35:33 +010066 pdp_typeorg := '0001'B,
Pau Espin Pedrol7b7a1e82024-01-19 20:49:28 +010067 pdp_typenum := '21'O,
68 ipv4_address := ip_addr
69 }
70}
71template (value) GSUP_PDP_Address ts_EuaIPv4Dyn := ts_GSUP_PDP_Address_IPv4(omit);
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +010072
Pau Espin Pedrol78598b52024-02-14 19:21:42 +010073template (present) GSUP_PDP_Address tr_GSUP_PDP_Address_IPv4(template OCT4 ip_addr) := {
74 ipv4 := {
75 spare := ?,
76 pdp_typeorg := '0001'B,
77 pdp_typenum := '21'O,
78 ipv4_address := ip_addr
79 }
80}
81
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +010082template GSUP_IE ts_GSUP_IE_AuthTuple2G(octetstring rand, octetstring sres,
83 octetstring kc) := {
84 tag := OSMO_GSUP_AUTH_TUPLE_IE,
85 len := 0, /* overwritten */
86 val := {
87 auth_tuple := {
88 valueof(ts_GSUP_IE_RAND(rand)),
89 valueof(ts_GSUP_IE_SRES(sres)),
90 valueof(ts_GSUP_IE_Kc(kc))
91 }
92 }
93}
94
95template GSUP_IE tr_GSUP_IE_AuthTuple3G(
96 template (present) octetstring rand := ?,
97 template (present) octetstring ik := ?,
98 template (present) octetstring ck := ?,
99 template (present) octetstring autn := ?,
100 template (present) octetstring res := ?) := {
101 tag := OSMO_GSUP_AUTH_TUPLE_IE,
102 len := ?,
103 val := {
104 auth_tuple := {
105 tr_GSUP_IE_RAND(rand),
106 tr_GSUP_IE_IK(ik),
107 tr_GSUP_IE_CK(ck),
108 tr_GSUP_IE_AUTN(autn),
109 tr_GSUP_IE_RES(res)
110 }
111 }
112}
113
114template GSUP_IE ts_GSUP_IE_AuthTuple3G(octetstring rand, octetstring ik,
115 octetstring ck, octetstring autn,
116 octetstring res) := {
117 tag := OSMO_GSUP_AUTH_TUPLE_IE,
118 len := 0, /* overwritten */
119 val := {
120 auth_tuple := {
121 valueof(ts_GSUP_IE_RAND(rand)),
122 valueof(ts_GSUP_IE_IK(ik)),
123 valueof(ts_GSUP_IE_CK(ck)),
124 valueof(ts_GSUP_IE_AUTN(autn)),
125 valueof(ts_GSUP_IE_RES(res))
126 }
127 }
128}
129
130template GSUP_IE tr_GSUP_IE_AuthTuple2G3G(
131 template (present) octetstring rand := ?,
132 template (present) octetstring sres := ?,
133 template (present) octetstring kc := ?,
134 template (present) octetstring ik := ?,
135 template (present) octetstring ck := ?,
136 template (present) octetstring autn := ?,
137 template (present) octetstring res := ?) := {
138 tag := OSMO_GSUP_AUTH_TUPLE_IE,
139 len := ?,
140 val := {
141 auth_tuple := {
142 tr_GSUP_IE_RAND(rand),
143 tr_GSUP_IE_SRES(sres),
144 tr_GSUP_IE_Kc(kc),
145 tr_GSUP_IE_IK(ik),
146 tr_GSUP_IE_CK(ck),
147 tr_GSUP_IE_AUTN(autn),
148 tr_GSUP_IE_RES(res)
149 }
150 }
151}
152
153template GSUP_IE ts_GSUP_IE_AuthTuple2G3G(octetstring rand, octetstring sres,
154 octetstring kc, octetstring ik,
155 octetstring ck, octetstring autn,
156 octetstring res) := {
157 tag := OSMO_GSUP_AUTH_TUPLE_IE,
158 len := 0, /* overwritten */
159 val := {
160 auth_tuple := {
161 valueof(ts_GSUP_IE_RAND(rand)),
162 valueof(ts_GSUP_IE_SRES(sres)),
163 valueof(ts_GSUP_IE_Kc(kc)),
164 valueof(ts_GSUP_IE_IK(ik)),
165 valueof(ts_GSUP_IE_CK(ck)),
166 valueof(ts_GSUP_IE_AUTN(autn)),
167 valueof(ts_GSUP_IE_RES(res))
168 }
169 }
170}
171
Pau Espin Pedrolbb76d7a2024-01-22 19:56:13 +0100172template (value) GSUP_IE ts_GSUP_IE_PdpInfoCompl := {
173 tag := OSMO_GSUP_PDP_INFO_COMPL_IE,
174 len := 0, /* overwritten */
175 val := {
176 pdp_info_compl := ''O
177 }
178}
179
180template (present) GSUP_IE tr_GSUP_IE_PdpInfoCompl := {
181 tag := OSMO_GSUP_PDP_INFO_COMPL_IE,
182 len := 0, /* overwritten */
183 val := {
184 pdp_info_compl := ''O
185 }
186}
187
Pau Espin Pedrolc63fa8e2024-01-22 19:58:09 +0100188template (value) GSUP_IE ts_GSUP_IE_PdpInfo(template (value) OCT1 ctx_id,
189 template (value) octetstring apn,
190 template (value) GSUP_PDP_Address pdp_address,
191 template (value) octetstring pdp_qos) := {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100192 tag := OSMO_GSUP_PDP_INFO_IE,
193 len := 0, /* overwritten */
194 val := {
195 pdp_info := {
Pau Espin Pedrolc63fa8e2024-01-22 19:58:09 +0100196 valueof(ts_GSUP_IE_PDP_CONTEXT_ID(ctx_id)),
Pau Espin Pedrol7b7a1e82024-01-19 20:49:28 +0100197 valueof(ts_GSUP_IE_PDP_ADDRESS(pdp_address)),
Pau Espin Pedrolc63fa8e2024-01-22 19:58:09 +0100198 valueof(ts_GSUP_IE_APN(apn)),
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100199 valueof(ts_GSUP_IE_PDP_QOS(pdp_qos))
200 }
201 }
202}
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +0100203template (value) GSUP_IE ts_GSUP_IE_PdpInfo_ie(template (value) GSUP_IEs pdp_info) := {
204 tag := OSMO_GSUP_PDP_INFO_IE,
205 len := 0, /* overwritten */
206 val := {
207 pdp_info := pdp_info
208 }
209}
210
211template (present) GSUP_IE tr_GSUP_IE_PdpInfo(template (present) OCT1 ctx_id,
212 template (present) octetstring apn,
213 template (present) GSUP_PDP_Address pdp_address) := {
214 tag := OSMO_GSUP_PDP_INFO_IE,
215 len := ?,
216 val := {
217 pdp_info := {
218 tr_GSUP_IE_PDP_CONTEXT_ID(ctx_id),
219 tr_GSUP_IE_PDP_ADDRESS(pdp_address),
220 tr_GSUP_IE_APN(apn)
221 }
222 }
223}
224template (present) GSUP_IE tr_GSUP_IE_PdpInfo_ie(template (present) GSUP_IEs pdp_info := ?) := {
225 tag := OSMO_GSUP_PDP_INFO_IE,
226 len := ?,
227 val := {
228 pdp_info := pdp_info
229 }
230}
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100231
Pau Espin Pedrolc63fa8e2024-01-22 19:58:09 +0100232template (value) GSUP_IE ts_GSUP_IE_PDP_CONTEXT_ID(template (value) OCT1 ctx_id) := {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100233 tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
234 len := 0,
235 val := {
236 pdp_ctx_id := ctx_id
237 }
238}
239
Pau Espin Pedrolc63fa8e2024-01-22 19:58:09 +0100240template (present) GSUP_IE tr_GSUP_IE_PDP_CONTEXT_ID(template OCT1 ctx_id) := {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100241 tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
242 len := ?,
243 val := {
244 pdp_ctx_id := ctx_id
245 }
246}
247
Pau Espin Pedrol7b7a1e82024-01-19 20:49:28 +0100248template (value) GSUP_IE ts_GSUP_IE_PDP_ADDRESS(template (value) GSUP_PDP_Address pdp_address) := {
249 tag := OSMO_GSUP_PDP_ADDRESS_IE,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100250 len := 0,
251 val := {
Pau Espin Pedrol7b7a1e82024-01-19 20:49:28 +0100252 pdp_address := pdp_address
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100253 }
254}
255
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +0100256template (present) GSUP_IE tr_GSUP_IE_PDP_ADDRESS(template (present) GSUP_PDP_Address pdp_address := ?) := {
257 tag := OSMO_GSUP_PDP_ADDRESS_IE,
258 len := ?,
259 val := {
260 pdp_address := pdp_address
261 }
262}
263
Pau Espin Pedrol7b7a1e82024-01-19 20:49:28 +0100264template (value) GSUP_IE ts_GSUP_IE_PDP_QOS(template (value) octetstring pdp_qos) := {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100265 tag := OSMO_GSUP_PDP_QOS_IE,
266 len := 0,
267 val := {
268 pdp_qos := pdp_qos
269 }
270}
271
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +0100272template (present) GSUP_IE tr_GSUP_IE_PDP_QOS(template (present) octetstring pdp_qos := ?) := {
273 tag := OSMO_GSUP_PDP_QOS_IE,
274 len := ?,
275 val := {
276 pdp_qos := pdp_qos
277 }
278}
279
280template (value) GSUP_IE ts_GSUP_IE_Charging_Characteristics(template (value) octetstring charg_char) := {
281 tag := OSMO_GSUP_CHARG_CHAR_IE,
282 len := 0,
283 val := {
284 charg_char := charg_char
285 }
286}
287
288template (present) GSUP_IE tr_GSUP_IE_Charging_Characteristics(template (present) octetstring charg_char := ?) := {
289 tag := OSMO_GSUP_CHARG_CHAR_IE,
290 len := ?,
291 val := {
292 charg_char := charg_char
293 }
294}
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100295
Pau Espin Pedrolce1d3cb2024-02-21 17:40:59 +0100296template (value) GSUP_IE ts_GSUP_IE_PCO(template (value) PCO_DATA pco) := {
297 tag := OSMO_GSUP_PCO_IE,
298 len := 0,
299 val := {
300 pco := pco
301 }
302}
303
Pau Espin Pedrolf2925862024-02-22 20:12:30 +0100304template (present) GSUP_IE tr_GSUP_IE_PCO(template (present) PCO_DATA pco := ?) := {
305 tag := OSMO_GSUP_PCO_IE,
306 len := ?,
307 val := {
308 pco := pco
309 }
310}
311
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100312template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
313 msg_type := msgt,
314 ies := ies
315}
316
317template (present) GSUP_PDU tr_GSUP_IMSI(template (present) GSUP_MessageType msgt := ?, template (present) hexstring imsi := ?) := {
318 msg_type := msgt,
319 ies := { tr_GSUP_IE_IMSI(imsi), * }
320}
321
322template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
323 msg_type := msgt,
324 ies := ies
325}
326
327template (value) GSUP_IMEI ts_GSUP_IMEI(hexstring digits) := {
328 len := 0, /* overwritten */
329 digits := digits
330}
331
332template GSUP_IMEI tr_GSUP_IMEI(template hexstring digits) := {
333 len := ?,
334 digits := digits
335}
336
337
338template (value) GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
339 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
340
341template (value) GSUP_PDU ts_GSUP_SAI_REQ_EPS(hexstring imsi) :=
342 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
343 valueof(ts_GSUP_IE_IMSI(imsi)),
344 valueof(ts_GSUP_IE_CURRENT_RAT_TYPE(RAT_TYPE_EUTRAN_SGs))
345 });
346
347template (value) GSUP_PDU ts_GSUP_SAI_REQ_NUM_AUTH(hexstring imsi, OCT1 num_auth_vectors) :=
348 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
349 valueof(ts_GSUP_IE_IMSI(imsi)),
350 valueof(ts_GSUP_IE_NUM_VECTORS_REQ(num_auth_vectors))
351 });
352
Pau Espin Pedrolc2cfd552024-02-07 17:51:55 +0100353template (value) GSUP_PDU ts_GSUP_SAI_REQ_PDP_INFO(hexstring imsi, template (value) GSUP_IEs pdp_info) :=
354 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
355 valueof(ts_GSUP_IE_IMSI(imsi)),
356 valueof(ts_GSUP_IE_PdpInfo_ie(pdp_info))
357 });
358
Pau Espin Pedrolb8cc6102024-03-08 17:37:08 +0100359template GSUP_PDU ts_GSUP_SAI_REQ_PDP_INFO_UMTS_AKA_RESYNC(
360 template (value) hexstring imsi,
361 template (value) GSUP_IEs pdp_info,
362 template (value) octetstring auts,
363 template (value) octetstring rand) :=
364 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
365 valueof(ts_GSUP_IE_IMSI(imsi)),
366 valueof(ts_GSUP_IE_PdpInfo_ie(pdp_info)),
367 valueof(ts_GSUP_IE_AUTS(auts)),
368 valueof(ts_GSUP_IE_RAND(rand))
369 });
370
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100371template GSUP_PDU tr_GSUP_SAI_REQ(template hexstring imsi) :=
372 tr_GSUP_IMSI(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, imsi);
373
374template GSUP_PDU tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC(
375 template hexstring imsi,
376 template octetstring auts,
377 template octetstring rand) :=
378 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
379 tr_GSUP_IE_IMSI(imsi),
380 tr_GSUP_IE_AUTS(auts),
381 tr_GSUP_IE_RAND(rand),
382 *
383 });
384
385template (value) GSUP_PDU ts_GSUP_SAI_RES(hexstring imsi, GSUP_IE auth_tuple) :=
386 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
387 valueof(ts_GSUP_IE_IMSI(imsi)), auth_tuple });
388
Pau Espin Pedrol6601f222024-03-05 18:51:09 +0100389template GSUP_PDU tr_GSUP_SAI_ERR(template hexstring imsi, template (present) integer cause := ?) :=
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100390 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
Pau Espin Pedrolb81c5da2024-03-06 18:02:34 +0100391 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause), *});
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100392
393template (value) GSUP_PDU ts_GSUP_SAI_ERR(hexstring imsi, integer cause) :=
394 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR, {
395 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
396
397
398template GSUP_PDU tr_GSUP_SAI_RES(template (present) hexstring imsi,
399 template (present) GSUP_IE auth_tuple_ie := tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE)) :=
400 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, {
401 tr_GSUP_IE_IMSI(imsi), *, auth_tuple_ie, * });
402
403template GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi, GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS,
404 template octetstring source_name := omit) :=
405 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, f_gen_ts_ies(imsi, dom := dom,
406 source_name := source_name));
407
408template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) :=
409 tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, imsi);
410
411template (value) GSUP_PDU ts_GSUP_UL_RES(hexstring imsi, octetstring destination_name := ''O) :=
412 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)),
413 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
414
415template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi, template octetstring destination_name := omit) :=
416 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, f_gen_tr_ies(imsi, destination_name := destination_name));
417
418template (value) GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) :=
419 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, {
420 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
421
422template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?,
423 template octetstring destination_name := omit) :=
424 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR,
425 f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name));
426
427template (value) GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn, octetstring destination_name := ''O) :=
428 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
429 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)),
430 valueof(ts_GSUP_IE_Destination_Name(destination_name))});
431
432template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?,
433 template octetstring destination_name := omit) :=
434 tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST,
435 f_gen_tr_ies(imsi, msisdn := msisdn, destination_name := destination_name));
436
437template GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi,
438 template octetstring source_name := omit,
439 template octetstring destination_name := omit) :=
440 ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT,
441 f_gen_ts_ies(imsi, source_name := source_name,
442 destination_name := destination_name));
443
444template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) :=
445 tr_GSUP_IMSI(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, imsi);
446
447template GSUP_PDU tr_GSUP_AUTH_FAIL_IND(hexstring imsi) :=
448 tr_GSUP_IMSI(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT, imsi);
449
Pau Espin Pedrolcbe6eba2024-02-06 12:53:14 +0100450template (present) GSUP_PDU tr_GSUP_CL_REQ(template (present) hexstring imsi := ?,
451 template GSUP_CnDomain dom := omit,
452 template GSUP_CancelType ctype := omit) :=
453 tr_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST,
454 f_gen_tr_ies(imsi,
455 cancel_type := ctype,
456 cn_domain := dom));
457
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100458template (value) GSUP_PDU ts_GSUP_CL_REQ(hexstring imsi, GSUP_CancelType ctype) :=
459 ts_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST, {
460 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CancelType(ctype)) });
461
462template GSUP_PDU tr_GSUP_CL_RES(template hexstring imsi) :=
463 tr_GSUP_IMSI(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT, imsi);
464
Pau Espin Pedrolcbe6eba2024-02-06 12:53:14 +0100465template (value) GSUP_PDU ts_GSUP_CL_RES(template (value) hexstring imsi) :=
466 ts_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT, {valueof(ts_GSUP_IE_IMSI(imsi))});
467
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100468template GSUP_PDU tr_GSUP_CL_ERR(template hexstring imsi, template integer cause := ?) :=
469 tr_GSUP(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR, {
470 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause), * });
471
472template (value) GSUP_PDU ts_GSUP_PURGE_MS_REQ(hexstring imsi, GSUP_CnDomain dom) :=
473 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
474 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CnDomain(dom)) });
475
476template GSUP_PDU tr_GSUP_PURGE_MS_REQ(template hexstring imsi, template GSUP_CnDomain dom := ?) :=
477 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_REQUEST, {
478 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_CnDomain(dom) });
479
480template (value) GSUP_PDU ts_GSUP_PURGE_MS_RES(hexstring imsi) :=
481 ts_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
482 valueof(ts_GSUP_IE_IMSI(imsi)) });
483
484template GSUP_PDU tr_GSUP_PURGE_MS_RES(template hexstring imsi) :=
485 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_RESULT, {
486 tr_GSUP_IE_IMSI(imsi), * });
487
488template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer cause) :=
489 tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, {
490 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
491
492template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei,
493 template (omit) octetstring source_name := omit) :=
494 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST, f_gen_ts_ies(imsi, imei := imei, source_name := source_name));
495
496template GSUP_PDU tr_GSUP_CHECK_IMEI_REQ(
497 template hexstring imsi,
498 template hexstring imei
499) := tr_GSUP(
500 OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST,
501 {
502 tr_GSUP_IE_IMSI(imsi),
503 tr_GSUP_IE_IMEI(imei),
504 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT)
505 }
506);
507
508template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_RES(hexstring imsi, GSUP_IMEIResult result) :=
509 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, {
510 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI_Result(result)) });
511
512template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result,
513 template octetstring destination_name := omit) :=
514 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT,
515 f_gen_tr_ies(imsi, imei_result := result, destination_name := destination_name));
516
517template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_ERR(hexstring imsi, integer cause) :=
518 ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, {
519 valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) });
520
521template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause,
522 template octetstring destination_name := omit) :=
523 tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name));
524
525
526/* EPDG Tunnel */
527template (value) GSUP_PDU ts_GSUP_EPDGTunnel_REQ(hexstring imsi,
Pau Espin Pedrolce1d3cb2024-02-21 17:40:59 +0100528 template (value) PCO_DATA pco,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100529 GSUP_Message_Class message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG,
530 GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS,
531 template (omit) octetstring source_name := omit) :=
532 ts_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_REQUEST, f_gen_ts_ies(imsi,
533 message_class := message_class,
Pau Espin Pedrolce1d3cb2024-02-21 17:40:59 +0100534 pco := pco,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100535 dom := dom,
536 source_name := source_name));
537
538template (present) GSUP_PDU tr_GSUP_EPDGTunnel_REQ(template (present) hexstring imsi := ?,
539 template (present) GSUP_Message_Class message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG) :=
540 tr_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_REQUEST,
541 f_gen_tr_ies(imsi,
542 message_class := message_class));
543
544
545template (value) GSUP_PDU ts_GSUP_EPDGTunnel_RES(hexstring imsi,
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +0100546 template (value) GSUP_IEs pdp_info,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100547 GSUP_Message_Class message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG,
548 octetstring destination_name := ''O) :=
549 ts_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_RESULT, {
550 valueof(ts_GSUP_IE_IMSI(imsi)),
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +0100551 valueof(ts_GSUP_IE_PdpInfoCompl),
552 valueof(ts_GSUP_IE_PdpInfo_ie(pdp_info)),
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100553 valueof(ts_GSUP_IE_Message_Class(message_class)),
554 valueof(ts_GSUP_IE_Destination_Name(destination_name))
555 });
556
557template (present) GSUP_PDU tr_GSUP_EPDGTunnel_RES(template (present) hexstring imsi,
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +0100558 template (present) GSUP_IEs pdp_info,
Pau Espin Pedrolf2925862024-02-22 20:12:30 +0100559 template (present) PCO_DATA pco := ?,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100560 template (present) GSUP_Message_Class message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG,
561 template octetstring destination_name := omit) :=
562 tr_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_RESULT,
563 f_gen_tr_ies(imsi,
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +0100564 pdp_info_compl := true,
565 pdp_info := pdp_info,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100566 message_class := message_class,
Pau Espin Pedrolf2925862024-02-22 20:12:30 +0100567 pco := pco,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100568 destination_name := destination_name));
569
570template (value) GSUP_PDU ts_GSUP_EPDGTunnel_ERR(hexstring imsi,
571 GSUP_Message_Class message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG,
572 integer cause := 0) :=
573 ts_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_ERROR, {
574 valueof(ts_GSUP_IE_IMSI(imsi)),
575 valueof(ts_GSUP_IE_Cause(cause)),
576 valueof(ts_GSUP_IE_Message_Class(message_class))
577 });
578
579template (present) GSUP_PDU tr_GSUP_EPDGTunnel_ERR(template (present) hexstring imsi,
580 template (present) GSUP_Message_Class message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG,
581 template (present) integer cause := ?,
582 template octetstring destination_name := omit) :=
583 tr_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_ERROR,
584 f_gen_tr_ies(imsi,
585 message_class := message_class,
586 cause := cause,
587 destination_name := destination_name));
588
589
590template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := {
591 tag := OSMO_GSUP_CANCEL_TYPE_IE,
592 len := 0, /* overwritten */
593 val := {
594 cancel_type := ctype
595 }
596}
597
598template GSUP_IE tr_GSUP_IE_CancelType(template GSUP_CancelType ctype) :=
599 tr_GSUP_IE(OSMO_GSUP_CANCEL_TYPE_IE, GSUP_IeValue:{cancel_type:=ctype});
600
601template GSUP_IE tr_GSUP_IE_CnDomain(template GSUP_CnDomain domain) :=
602 tr_GSUP_IE(OSMO_GSUP_CN_DOMAIN_IE, GSUP_IeValue:{cn_domain:=domain});
603
604template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := {
605 tag := iei,
606 len := ?,
607 val := val
608}
609
Pau Espin Pedrolcbe6eba2024-02-06 12:53:14 +0100610template (value) GSUP_IE ts_GSUP_IE_IMSI(template (value) hexstring imsi) := {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100611 tag := OSMO_GSUP_IMSI_IE,
612 len := 0, /* overwritten */
613 val := {
614 imsi := imsi
615 }
616}
617
618template (present) GSUP_IE tr_GSUP_IE_IMSI(template (present) hexstring imsi := ?) := {
619 tag := OSMO_GSUP_IMSI_IE,
620 len := ?,
621 val := {
622 imsi := imsi
623 }
624}
625
626template (value) GSUP_IE ts_GSUP_IE_MSISDN(hexstring msisdn) := {
627 tag := OSMO_GSUP_MSISDN_IE,
628 len := 0, /* overwritten */
629 val := {
630 msisdn := ts_GSUP_MSISDN(msisdn)
631 }
632}
633
634template GSUP_IE tr_GSUP_IE_MSISDN(template hexstring msisdn) := {
635 tag := OSMO_GSUP_MSISDN_IE,
636 len := ?,
637 val := {
638 msisdn := tr_GSUP_MSISDN(msisdn)
639 }
640}
641
642
643template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := {
644 tag := OSMO_GSUP_CAUSE_IE,
645 len := 0, /* overwritten */
646 val := {
647 cause := cause
648 }
649}
650
651template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := {
652 tag := OSMO_GSUP_CAUSE_IE,
653 len := ?,
654 val := {
655 cause := cause
656 }
657}
658
Pau Espin Pedrolb8cc6102024-03-08 17:37:08 +0100659template (value) GSUP_IE ts_GSUP_IE_AUTS(template (value) octetstring auts) := {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100660 tag := OSMO_GSUP_AUTS_IE,
661 len := 0, /* overwritten */
662 val := {
663 auts := auts
664 }
665}
666
667template GSUP_IE tr_GSUP_IE_AUTS(template octetstring auts) := {
668 tag := OSMO_GSUP_AUTS_IE,
669 len := ?,
670 val := {
671 auts := auts
672 }
673}
674
Pau Espin Pedrolb8cc6102024-03-08 17:37:08 +0100675template (value) GSUP_IE ts_GSUP_IE_RAND(template (value) octetstring rand) := {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100676 tag := OSMO_GSUP_RAND_IE,
677 len := 0, /* overwritten */
678 val := {
679 rand := rand
680 }
681}
682
683template GSUP_IE tr_GSUP_IE_RAND(template octetstring rand := ?) := {
684 tag := OSMO_GSUP_RAND_IE,
685 len := ?,
686 val := {
687 rand := rand
688 }
689}
690
691template (present) GSUP_IE tr_GSUP_IE_SRES(template (present) octetstring sres := ?) := {
692 tag := OSMO_GSUP_SRES_IE,
693 len := ?,
694 val := {
695 sres := sres
696 }
697}
698
699template (value) GSUP_IE ts_GSUP_IE_SRES(octetstring sres) := {
700 tag := OSMO_GSUP_SRES_IE,
701 len := 0, /* overwritten */
702 val := {
703 sres := sres
704 }
705}
706
707template (present) GSUP_IE tr_GSUP_IE_Kc(template (present) octetstring kc := ?) := {
708 tag := OSMO_GSUP_KC_IE,
709 len := ?,
710 val := {
711 kc := kc
712 }
713}
714
715template (value) GSUP_IE ts_GSUP_IE_Kc(octetstring kc) := {
716 tag := OSMO_GSUP_KC_IE,
717 len := 0, /* overwritten */
718 val := {
719 kc := kc
720 }
721}
722
723template (present) GSUP_IE tr_GSUP_IE_IK(template (present) octetstring ik := ?) := {
724 tag := OSMO_GSUP_IK_IE,
725 len := ?,
726 val := {
727 ik := ik
728 }
729}
730
731template (value) GSUP_IE ts_GSUP_IE_IK(octetstring ik) := {
732 tag := OSMO_GSUP_IK_IE,
733 len := 0, /* overwritten */
734 val := {
735 ik := ik
736 }
737}
738
739template (present) GSUP_IE tr_GSUP_IE_CK(template (present) octetstring ck := ?) := {
740 tag := OSMO_GSUP_CK_IE,
741 len := ?,
742 val := {
743 ck := ck
744 }
745}
746
747template (value) GSUP_IE ts_GSUP_IE_CK(octetstring ck) := {
748 tag := OSMO_GSUP_CK_IE,
749 len := 0, /* overwritten */
750 val := {
751 ck := ck
752 }
753}
754
755template (present) GSUP_IE tr_GSUP_IE_AUTN(template (present) octetstring autn := ?) := {
756 tag := OSMO_GSUP_AUTN_IE,
757 len := ?,
758 val := {
759 autn := autn
760 }
761}
762
763template (value) GSUP_IE ts_GSUP_IE_AUTN(octetstring autn) := {
764 tag := OSMO_GSUP_AUTN_IE,
765 len := 0, /* overwritten */
766 val := {
767 autn := autn
768 }
769}
770
771template (present) GSUP_IE tr_GSUP_IE_RES(template (present) octetstring res := ?) := {
772 tag := OSMO_GSUP_RES_IE,
773 len := ?,
774 val := {
775 res := res
776 }
777}
778
779template (value) GSUP_IE ts_GSUP_IE_RES(octetstring res) := {
780 tag := OSMO_GSUP_RES_IE,
781 len := 0, /* overwritten */
782 val := {
783 res := res
784 }
785}
786
Pau Espin Pedrol7b7a1e82024-01-19 20:49:28 +0100787template (value) GSUP_IE ts_GSUP_IE_APN(template (value) octetstring apn) := {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +0100788 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
789 len := 0, /* overwritten */
790 val := {
791 apn := apn
792 }
793}
794
795template GSUP_IE tr_GSUP_IE_APN(template octetstring apn) := {
796 tag := OSMO_GSUP_ACCESS_POINT_NAME_IE,
797 len := ?,
798 val := {
799 apn := apn
800 }
801}
802
803template GSUP_IE ts_GSUP_IE_CnDomain(template GSUP_CnDomain dom) := {
804 tag := OSMO_GSUP_CN_DOMAIN_IE,
805 len := 0, /* overwritten */
806 val := {
807 cn_domain := dom
808 }
809}
810
811template (value) GSUP_IE ts_GSUP_IE_SessionId(OCT4 sid) := {
812 tag := OSMO_GSUP_SESSION_ID_IE,
813 len := 0, /* overwritten */
814 val := {
815 session_id := sid
816 }
817}
818template GSUP_IE tr_GSUP_IE_SessionId(template OCT4 sid) := {
819 tag := OSMO_GSUP_SESSION_ID_IE,
820 len := ?,
821 val := {
822 session_id := sid
823 }
824}
825
826template (value) GSUP_IE ts_GSUP_IE_SessionState(GSUP_SessionState state) := {
827 tag := OSMO_GSUP_SESSION_STATE_IE,
828 len := 0, /* overwritten */
829 val := {
830 session_state := state
831 }
832}
833template GSUP_IE tr_GSUP_IE_SessionState(template GSUP_SessionState state) := {
834 tag := OSMO_GSUP_SESSION_STATE_IE,
835 len := ?,
836 val := {
837 session_state := state
838 }
839}
840
841template (value) GSUP_IE ts_GSUP_IE_SM_RP_MR(OCT1 ref) := {
842 tag := OSMO_GSUP_SM_RP_MR_IE,
843 len := 0, /* overwritten */
844 val := {
845 sm_rp_mr := ref
846 }
847}
848template GSUP_IE tr_GSUP_IE_SM_RP_MR(template OCT1 ref) := {
849 tag := OSMO_GSUP_SM_RP_MR_IE,
850 len := ?,
851 val := {
852 sm_rp_mr := ref
853 }
854}
855
856template (value) GSUP_IE ts_GSUP_IE_SM_RP_CAUSE(OCT1 cause) := {
857 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
858 len := 0, /* overwritten */
859 val := {
860 sm_rp_cause := cause
861 }
862}
863template GSUP_IE tr_GSUP_IE_SM_RP_CAUSE(template OCT1 cause) := {
864 tag := OSMO_GSUP_SM_RP_CAUSE_IE,
865 len := ?,
866 val := {
867 sm_rp_cause := cause
868 }
869}
870
871template (value) GSUP_IE ts_GSUP_IE_SM_RP_MMS(OCT1 mms) := {
872 tag := OSMO_GSUP_SM_RP_MMS_IE,
873 len := 0, /* overwritten */
874 val := {
875 sm_rp_mms := mms
876 }
877}
878template GSUP_IE tr_GSUP_IE_SM_RP_MMS(template OCT1 mms) := {
879 tag := OSMO_GSUP_SM_RP_MMS_IE,
880 len := ?,
881 val := {
882 sm_rp_mms := mms
883 }
884}
885
886template (value) GSUP_IE ts_GSUP_IE_IMEI(hexstring imei) := {
887 tag := OSMO_GSUP_IMEI_IE,
888 len := 0, /* overwritten */
889 val := {
890 imei := ts_GSUP_IMEI(imei)
891 }
892}
893template GSUP_IE tr_GSUP_IE_IMEI(template hexstring imei) := {
894 tag := OSMO_GSUP_IMEI_IE,
895 len := ?,
896 val := {
897 imei := tr_GSUP_IMEI(imei)
898 }
899}
900
901template (value) GSUP_IE ts_GSUP_IE_IMEI_Result(GSUP_IMEIResult result) := {
902 tag := OSMO_GSUP_IMEI_RESULT_IE,
903 len := 0, /* overwritten */
904 val := {
905 imei_result := result
906 }
907}
908template GSUP_IE tr_GSUP_IE_IMEI_Result(template GSUP_IMEIResult result) := {
909 tag := OSMO_GSUP_IMEI_RESULT_IE,
910 len := ?,
911 val := {
912 imei_result := result
913 }
914}
915
916template (value) GSUP_IE ts_GSUP_IE_NUM_VECTORS_REQ(OCT1 num) := {
917 tag := OSMO_GSUP_NUM_VECTORS_REQ_IE,
918 len := 0, /* overwritten */
919 val := {
920 num_auth_vectors := num
921 }
922}
923template GSUP_IE tr_GSUP_IE_NUM_VECTORS_REQ(template OCT1 num) := {
924 tag := OSMO_GSUP_NUM_VECTORS_REQ_IE,
925 len := ?,
926 val := {
927 num_auth_vectors := num
928 }
929}
930
931/* See 3GPP TS 24.011, figures 8.5 and 8.6 */
932private function f_pad_SM_RP_Addr(template hexstring number)
933return template hexstring {
934 if (isvalue(number) and not istemplatekind(number, "omit")) {
935 return f_pad_bcd_number(valueof(number));
936 } else {
937 return number;
938 }
939}
940
941template GSUP_SM_RP_Addr t_GSUP_SM_RP_Addr(template hexstring number,
942 template BIT4 npi := '0001'B,
943 template BIT3 ton := '001'B,
944 template BIT1 ext := '1'B) := {
945 ext := ext,
946 ton := ton,
947 npi := npi,
948 /* Work around TITAN's padding problems: encoding works fine,
949 * but it does not consider 'F'H as padding in decoded data. */
950 number := f_pad_SM_RP_Addr(number)
951}
952
953/**
954 * SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
955 * It can be either of the following:
956 * - IMSI
957 * - LMSI (not implemented)
958 * - MSISDN
959 * - roaming number (not implemented)
960 * - service centre address
961 */
962template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_IMSI(hexstring imsi) := {
963 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
964 id_enc := { imsi := imsi }
965}
966template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_IMSI(template hexstring imsi) := {
967 id_type := OSMO_GSUP_SM_RP_ODA_ID_IMSI,
968 id_enc := { imsi := imsi }
969}
970
971template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
972 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
973 id_enc := { msisdn := msisdn }
974}
975template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
976 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
977 id_enc := { msisdn := msisdn }
978}
979
980template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(GSUP_SM_RP_Addr smsc_addr) := {
981 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
982 id_enc := { smsc_addr := smsc_addr }
983}
984template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template GSUP_SM_RP_Addr smsc_addr) := {
985 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
986 id_enc := { smsc_addr := smsc_addr }
987}
988
989template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_NULL := {
990 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
991 id_enc := omit
992}
993template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_NULL := {
994 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
995 id_enc := omit
996}
997
998template (value) GSUP_IE ts_GSUP_IE_SM_RP_DA(GSUP_SM_RP_DA val) := {
999 tag := OSMO_GSUP_SM_RP_DA_IE,
1000 len := 0, /* overwritten */
1001 val := {
1002 sm_rp_da := val
1003 }
1004}
1005template GSUP_IE tr_GSUP_IE_SM_RP_DA(template GSUP_SM_RP_DA val) := {
1006 tag := OSMO_GSUP_SM_RP_DA_IE,
1007 len := ?,
1008 val := {
1009 sm_rp_da := val
1010 }
1011}
1012
1013/**
1014 * SM-RP-OA represents the SM Originating Address, see 7.6.8.2.
1015 * It can be either of the following:
1016 * - MSISDN
1017 * - service centre address
1018 */
1019template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
1020 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
1021 id_enc := { msisdn := msisdn }
1022}
1023template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
1024 id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
1025 id_enc := { msisdn := msisdn }
1026}
1027
1028template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(GSUP_SM_RP_Addr smsc_addr) := {
1029 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
1030 id_enc := { smsc_addr := smsc_addr }
1031}
1032template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template GSUP_SM_RP_Addr smsc_addr) := {
1033 id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
1034 id_enc := { smsc_addr := smsc_addr }
1035}
1036
1037template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_NULL := {
1038 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
1039 id_enc := omit
1040}
1041template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_NULL := {
1042 id_type := OSMO_GSUP_SM_RP_ODA_ID_NULL,
1043 id_enc := omit
1044}
1045
1046template (value) GSUP_IE ts_GSUP_IE_SM_RP_OA(GSUP_SM_RP_OA val) := {
1047 tag := OSMO_GSUP_SM_RP_OA_IE,
1048 len := 0, /* overwritten */
1049 val := {
1050 sm_rp_oa := val
1051 }
1052}
1053template GSUP_IE tr_GSUP_IE_SM_RP_OA(template GSUP_SM_RP_OA val) := {
1054 tag := OSMO_GSUP_SM_RP_OA_IE,
1055 len := ?,
1056 val := {
1057 sm_rp_oa := val
1058 }
1059}
1060
1061/* SM-RP-UI represents the SM TPDU, see 7.6.8.4 */
1062template (value) GSUP_IE ts_GSUP_IE_SM_RP_UI(octetstring val) := {
1063 tag := OSMO_GSUP_SM_RP_UI_IE,
1064 len := 0, /* overwritten */
1065 val := {
1066 sm_rp_ui := val
1067 }
1068}
1069template GSUP_IE tr_GSUP_IE_SM_RP_UI(template octetstring val) := {
1070 tag := OSMO_GSUP_SM_RP_UI_IE,
1071 len := ?,
1072 val := {
1073 sm_rp_ui := val
1074 }
1075}
1076
1077/* SM Alert Reason IE (used in READY-FOR-SM), see 7.6.8.8 */
1078template (value) GSUP_IE ts_GSUP_IE_SM_ALERT_RSN(GSUP_SM_ALERT_RSN_Type rsn) := {
1079 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1080 len := 0, /* overwritten */
1081 val := {
1082 sm_alert_rsn := rsn
1083 }
1084}
1085template GSUP_IE tr_GSUP_IE_SM_ALERT_RSN(template GSUP_SM_ALERT_RSN_Type rsn) := {
1086 tag := OSMO_GSUP_SM_ALERT_RSN_IE,
1087 len := ?,
1088 val := {
1089 sm_alert_rsn := rsn
1090 }
1091}
1092
1093template (value) GSUP_IE ts_GSUP_IE_SSInfo(octetstring ss) := {
1094 tag := OSMO_GSUP_SS_INFO_IE,
1095 len := 0, /* overwritten */
1096 val := {
1097 ss_info := ss
1098 }
1099}
1100template GSUP_IE tr_GSUP_IE_SSInfo(template octetstring ss) := {
1101 tag := OSMO_GSUP_SS_INFO_IE,
1102 len := ?,
1103 val := {
1104 ss_info := ss
1105 }
1106}
1107
1108template GSUP_IE tr_GSUP_IE_Message_Class(template GSUP_Message_Class val) := {
1109 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1110 len := ?,
1111 val := {
1112 message_class := val
1113 }
1114}
1115
1116template (value) GSUP_IE ts_GSUP_IE_Message_Class(GSUP_Message_Class val) := {
1117 tag := OSMO_GSUP_MESSAGE_CLASS_IE,
1118 len := 0, /* overwritten */
1119 val := {
1120 message_class := val
1121 }
1122}
1123
1124template GSUP_IE tr_GSUP_IE_Source_Name(template octetstring name) := {
1125 tag := OSMO_GSUP_SOURCE_NAME_IE,
1126 len := ?,
1127 val := {
1128 source_name := name
1129 }
1130}
1131
1132template (value) GSUP_IE ts_GSUP_IE_Source_Name(octetstring name) := {
1133 tag := OSMO_GSUP_SOURCE_NAME_IE,
1134 len := 0, /* overwritten */
1135 val := {
1136 source_name := name
1137 }
1138}
1139
1140template GSUP_IE tr_GSUP_IE_Destination_Name(template octetstring name) := {
1141 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1142 len := ?,
1143 val := {
1144 destination_name := name
1145 }
1146}
1147
1148template (value) GSUP_IE ts_GSUP_IE_Destination_Name(octetstring name) := {
1149 tag := OSMO_GSUP_DESTINATION_NAME_IE,
1150 len := 0, /* overwritten */
1151 val := {
1152 destination_name := name
1153 }
1154}
1155
1156template GSUP_IE tr_GSUP_IE_AN_APDU(template GSUP_AN_APDU an_apdu) := {
1157 tag := OSMO_GSUP_AN_APDU_IE,
1158 len := ?,
1159 val := {
1160 an_apdu := an_apdu
1161 }
1162}
1163
1164template (value) GSUP_IE ts_GSUP_IE_AN_APDU(GSUP_AN_APDU an_apdu) := {
1165 tag := OSMO_GSUP_AN_APDU_IE,
1166 len := 0, /* overwritten */
1167 val := {
1168 an_apdu := an_apdu
1169 }
1170}
1171
1172template (present) GSUP_IE tr_GSUP_IE_SUPPORTED_RAT_TYPES(template (present) GSUP_RatTypes ratt) := {
1173 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
1174 len := ?,
1175 val := {
1176 supported_rat_types := ratt
1177 }
1178}
1179template (value) GSUP_IE ts_GSUP_IE_SUPPORTED_RAT_TYPES(GSUP_RatTypes ratt) := {
1180 tag := OSMO_GSUP_SUPPORTED_RAT_TYPES_IE,
1181 len := 0, /* overwritten */
1182 val := {
1183 supported_rat_types := ratt
1184 }
1185}
1186
1187template (present) GSUP_IE tr_GSUP_IE_CURRENT_RAT_TYPE(template (present) GSUP_RatType ratt) := {
1188 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1189 len := ?,
1190 val := {
1191 current_rat_type := ratt
1192 }
1193}
1194template (value) GSUP_IE ts_GSUP_IE_CURRENT_RAT_TYPE(GSUP_RatType ratt) := {
1195 tag := OSMO_GSUP_CURRENT_RAT_TYPE_IE,
1196 len := 0, /* overwritten */
1197 val := {
1198 current_rat_type := ratt
1199 }
1200}
1201
1202private function f_gen_ts_ies(hexstring imsi,
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001203 template (omit) boolean pdp_info_compl := omit,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001204 template (omit) GSUP_Message_Class message_class := omit,
1205 template (omit) hexstring imei := omit,
Pau Espin Pedrolce1d3cb2024-02-21 17:40:59 +01001206 template (omit) PCO_DATA pco := omit,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001207 template (omit) GSUP_CnDomain dom := omit,
1208 template (omit) octetstring source_name := omit,
1209 template (omit) octetstring destination_name := omit
1210 ) return GSUP_IEs {
1211 var GSUP_IEs ies := {
1212 valueof(ts_GSUP_IE_IMSI(imsi))
1213 };
1214
1215 if (isvalue(dom)) {
1216 ies := ies & { valueof(ts_GSUP_IE_CnDomain(dom)) };
1217 }
1218
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001219 if (isvalue(pdp_info_compl) and valueof(pdp_info_compl)) {
1220 ies := ies & { valueof(ts_GSUP_IE_PdpInfoCompl) };
1221 }
1222
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001223 if (isvalue(imei)) {
1224 ies := ies & { valueof(ts_GSUP_IE_IMEI(valueof(imei))) };
1225 }
1226
Pau Espin Pedrolce1d3cb2024-02-21 17:40:59 +01001227 if (isvalue(pco)) {
1228 ies := ies & { valueof(ts_GSUP_IE_PCO(valueof(pco))) };
1229 }
1230
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001231 if (isvalue(message_class)) {
1232 ies := ies & { valueof(ts_GSUP_IE_Message_Class(valueof(message_class))) };
1233 }
1234
1235 if (isvalue(source_name)) {
1236 ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) };
1237 }
1238
1239 if (isvalue(destination_name)) {
1240 ies := ies & { valueof(ts_GSUP_IE_Destination_Name(valueof(destination_name))) };
1241 }
1242
1243 return ies;
1244}
1245
1246private function f_gen_tr_ies(template hexstring imsi,
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001247 template boolean pdp_info_compl := omit,
1248 template GSUP_IEs pdp_info := omit,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001249 template GSUP_Message_Class message_class := omit,
1250 template integer cause := omit,
Pau Espin Pedrolcbe6eba2024-02-06 12:53:14 +01001251 template GSUP_CancelType cancel_type := omit,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001252 template hexstring msisdn := omit,
1253 template GSUP_IMEIResult imei_result := omit,
Pau Espin Pedrolf2925862024-02-22 20:12:30 +01001254 template PCO_DATA pco := omit,
Pau Espin Pedrolcbe6eba2024-02-06 12:53:14 +01001255 template GSUP_CnDomain cn_domain := omit,
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001256 template octetstring source_name := omit,
1257 template octetstring destination_name := omit
1258 ) return template GSUP_IEs {
1259 var template GSUP_IEs ies := {
1260 tr_GSUP_IE_IMSI(imsi)
1261 };
1262 var integer idx := 1;
1263
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001264 if (not istemplatekind(msisdn, "omit")) {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001265 ies[idx] := tr_GSUP_IE_MSISDN(msisdn);
1266 idx := idx + 1;
1267 }
1268
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001269 if (not istemplatekind(cause, "omit")) {
1270 ies[idx] := tr_GSUP_IE_Cause(cause);
1271 idx := idx + 1;
1272 }
1273
Pau Espin Pedrolcbe6eba2024-02-06 12:53:14 +01001274 if (not istemplatekind(cancel_type, "omit")) {
1275 ies[idx] := tr_GSUP_IE_CancelType(cancel_type);
1276 idx := idx + 1;
1277 }
1278
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001279 if (not istemplatekind(pdp_info_compl, "omit")) {
1280 ies[idx] := tr_GSUP_IE_PdpInfoCompl;
1281 idx := idx + 1;
1282 }
1283
1284 if (not istemplatekind(pdp_info, "omit")) {
1285 ies[idx] := tr_GSUP_IE_PdpInfo_ie(pdp_info);
1286 idx := idx + 1;
1287 }
1288
Pau Espin Pedrolcbe6eba2024-02-06 12:53:14 +01001289 if (not istemplatekind(cn_domain, "omit")) {
1290 ies[idx] := tr_GSUP_IE_CnDomain(cn_domain);
1291 idx := idx + 1;
1292 }
1293
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001294 if (not istemplatekind(imei_result, "omit")) {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001295 ies[idx] := tr_GSUP_IE_IMEI_Result(imei_result);
1296 idx := idx + 1;
1297 }
1298
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001299 if (not istemplatekind(message_class, "omit")) {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001300 ies[idx] := tr_GSUP_IE_Message_Class(message_class);
1301 idx := idx + 1;
1302 }
1303
Pau Espin Pedrolf2925862024-02-22 20:12:30 +01001304 if (not istemplatekind(pco, "omit")) {
1305 ies[idx] := tr_GSUP_IE_PCO(pco);
1306 idx := idx + 1;
1307 }
1308
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001309 if (not istemplatekind(source_name, "omit")) {
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001310 ies[idx] := tr_GSUP_IE_Source_Name(source_name);
1311 idx := idx + 1;
1312 }
1313
1314 ies[idx] := *;
1315 idx := idx + 1;
1316
Pau Espin Pedrola6b0c1c2024-01-22 20:02:06 +01001317 if (not istemplatekind(destination_name, "omit")) {
1318 if (istemplatekind(destination_name, "*")) {
1319 ies[idx] := *;
1320 } else {
1321 ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
1322 }
Pau Espin Pedrol8f1403a2024-01-18 20:08:43 +01001323 idx := idx + 1;
1324 }
1325
1326 return ies;
1327}
1328
1329private function f_gen_ts_ss_ies(
1330 hexstring imsi,
1331 OCT4 sid,
1332 GSUP_SessionState state,
1333 template (omit) octetstring ss := omit,
1334 template (omit) integer cause := omit,
1335 template octetstring source_name := omit
1336) return GSUP_IEs {
1337 /* Mandatory IEs */
1338 var GSUP_IEs ies := {
1339 valueof(ts_GSUP_IE_IMSI(imsi))
1340 };
1341
1342 /* Cause IE is needed for PROC_SS_ERR */
1343 if (isvalue(cause)) {
1344 ies := ies & { valueof(ts_GSUP_IE_Cause(valueof(cause))) };
1345 }
1346
1347 /* Mandatory session IEs */
1348 ies := ies & { valueof(ts_GSUP_IE_SessionId(sid)) };
1349 ies := ies & { valueof(ts_GSUP_IE_SessionState(state)) };
1350
1351 /* Optional SS payload */
1352 if (isvalue(ss)) {
1353 ies := ies & { valueof(ts_GSUP_IE_SSInfo(valueof(ss))) };
1354 }
1355
1356 if (isvalue(source_name)) {
1357 ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) };
1358 }
1359
1360 return ies;
1361}
1362private function f_gen_tr_ss_ies(
1363 template hexstring imsi,
1364 template OCT4 sid := ?,
1365 template GSUP_SessionState state := ?,
1366 template octetstring ss := omit,
1367 template integer cause := omit,
1368 template octetstring destination_name := omit
1369) return template GSUP_IEs {
1370 /* Mandatory IEs */
1371 var template GSUP_IEs ies := {
1372 tr_GSUP_IE_IMSI(imsi)
1373 };
1374 var integer idx := 1;
1375
1376 /* Cause IE is needed for PROC_SS_ERR */
1377 if (istemplatekind(cause, "*")) {
1378 ies[idx] := *;
1379 idx := idx + 1;
1380 } else if (not istemplatekind(cause, "omit")) {
1381 ies[idx] := tr_GSUP_IE_Cause(cause);
1382 idx := idx + 1;
1383 }
1384
1385 /* Mandatory session IEs */
1386 ies[idx] := tr_GSUP_IE_SessionId(sid);
1387 ies[idx + 1] := tr_GSUP_IE_SessionState(state);
1388 idx := idx + 2;
1389
1390 /* Optional SS payload */
1391 if (istemplatekind(ss, "*")) {
1392 ies[idx] := *;
1393 idx := idx + 1;
1394 } else if (not istemplatekind(ss, "omit")) {
1395 ies[idx] := tr_GSUP_IE_SSInfo(ss);
1396 idx := idx + 1;
1397 }
1398
1399 if (isvalue(destination_name)) {
1400 ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
1401 idx := idx + 1;
1402 }
1403
1404 /* the GSUP Message Class IE is optional, as old implementations don't have it yet */
1405 var template GSUP_IEs ies2 := ies;
1406 ies2[idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD);
1407 idx := idx + 1;
1408
1409 return (ies, ies2);
1410}
1411
1412template (value) GSUP_PDU ts_GSUP_PROC_SS_REQ(
1413 hexstring imsi,
1414 OCT4 sid,
1415 GSUP_SessionState state,
1416 template (omit) octetstring ss := omit,
1417 template (omit) octetstring source_name := omit
1418) := ts_GSUP(
1419 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
1420 f_gen_ts_ss_ies(imsi, sid, state, ss, source_name := source_name)
1421);
1422template GSUP_PDU tr_GSUP_PROC_SS_REQ(
1423 template hexstring imsi,
1424 template OCT4 sid := ?,
1425 template GSUP_SessionState state := ?,
1426 template octetstring ss := *
1427) := tr_GSUP(
1428 OSMO_GSUP_MSGT_PROC_SS_REQUEST,
1429 f_gen_tr_ss_ies(imsi, sid, state, ss)
1430);
1431
1432template (value) GSUP_PDU ts_GSUP_PROC_SS_RES(
1433 hexstring imsi,
1434 OCT4 sid,
1435 GSUP_SessionState state,
1436 template (omit) octetstring ss := omit
1437) := ts_GSUP(
1438 OSMO_GSUP_MSGT_PROC_SS_RESULT,
1439 f_gen_ts_ss_ies(imsi, sid, state, ss)
1440);
1441template GSUP_PDU tr_GSUP_PROC_SS_RES(
1442 template hexstring imsi,
1443 template OCT4 sid := ?,
1444 template GSUP_SessionState state := ?,
1445 template octetstring ss := *,
1446 template octetstring destination_name := omit
1447) := tr_GSUP(
1448 OSMO_GSUP_MSGT_PROC_SS_RESULT,
1449 f_gen_tr_ss_ies(imsi, sid, state, ss, destination_name := destination_name)
1450);
1451
1452template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR(
1453 hexstring imsi,
1454 OCT4 sid,
1455 GSUP_SessionState state,
1456 integer cause
1457) := ts_GSUP(
1458 OSMO_GSUP_MSGT_PROC_SS_ERROR,
1459 f_gen_ts_ss_ies(imsi, sid, state, cause := cause)
1460);
1461template GSUP_PDU tr_GSUP_PROC_SS_ERR(
1462 template hexstring imsi,
1463 template OCT4 sid := ?,
1464 template GSUP_SessionState state := ?,
1465 template integer cause := ?
1466) := tr_GSUP(
1467 OSMO_GSUP_MSGT_PROC_SS_ERROR,
1468 f_gen_tr_ss_ies(imsi, sid, state, cause := cause)
1469);
1470
1471template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_REQ(
1472 hexstring imsi,
1473 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1474 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1475 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1476 octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1477) := ts_GSUP(
1478 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1479 {
1480 valueof(ts_GSUP_IE_IMSI(imsi)),
1481 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1482 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1483 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1484 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
1485 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1486 }
1487);
1488template GSUP_PDU tr_GSUP_MO_FORWARD_SM_REQ(
1489 template hexstring imsi := ?,
1490 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1491 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1492 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1493 template octetstring sm_rp_ui /* SM TPDU, see 7.6.8.4 */
1494) := tr_GSUP(
1495 OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST,
1496 {
1497 tr_GSUP_IE_IMSI(imsi),
1498 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1499 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1500 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1501 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
1502 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1503 tr_GSUP_IE_Source_Name(?)
1504 }
1505);
1506
1507template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_RES(
1508 hexstring imsi,
1509 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1510) := ts_GSUP(
1511 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1512 {
1513 valueof(ts_GSUP_IE_IMSI(imsi)),
1514 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1515 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1516 }
1517);
1518template GSUP_PDU tr_GSUP_MO_FORWARD_SM_RES(
1519 template hexstring imsi := ?,
1520 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1521) := tr_GSUP(
1522 OSMO_GSUP_MSGT_MO_FORWARD_SM_RESULT,
1523 {
1524 tr_GSUP_IE_IMSI(imsi),
1525 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1526 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1527 tr_GSUP_IE_Source_Name(?)
1528 }
1529);
1530
1531template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_ERR(
1532 hexstring imsi,
1533 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1534 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1535) := ts_GSUP(
1536 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1537 {
1538 valueof(ts_GSUP_IE_IMSI(imsi)),
1539 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1540 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)),
1541 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1542 }
1543);
1544template GSUP_PDU tr_GSUP_MO_FORWARD_SM_ERR(
1545 template hexstring imsi := ?,
1546 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1547 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1548) := tr_GSUP(
1549 OSMO_GSUP_MSGT_MO_FORWARD_SM_ERROR,
1550 {
1551 tr_GSUP_IE_IMSI(imsi),
1552 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1553 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1554 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1555 tr_GSUP_IE_Source_Name(?)
1556 }
1557);
1558
1559template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_REQ(
1560 hexstring imsi,
1561 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1562 GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1563 GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1564 octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1565 OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1566) := ts_GSUP(
1567 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1568 {
1569 /**
1570 * TODO: add MT-specific fields (and IEs):
1571 * - smDeliveryTimer
1572 * - smDeliveryStartTime
1573 */
1574 valueof(ts_GSUP_IE_IMSI(imsi)),
1575 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1576 valueof(ts_GSUP_IE_SM_RP_DA(sm_rp_da)),
1577 valueof(ts_GSUP_IE_SM_RP_OA(sm_rp_oa)),
1578 valueof(ts_GSUP_IE_SM_RP_UI(sm_rp_ui)),
1579 valueof(ts_GSUP_IE_SM_RP_MMS(sm_rp_mms)),
1580 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1581 }
1582);
1583template GSUP_PDU tr_GSUP_MT_FORWARD_SM_REQ(
1584 template hexstring imsi := ?,
1585 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1586 template GSUP_SM_RP_DA sm_rp_da, /* Destination Address, see 7.6.8.1 */
1587 template GSUP_SM_RP_OA sm_rp_oa, /* Originating Address, see 7.6.8.2 */
1588 template octetstring sm_rp_ui, /* SM TPDU, see 7.6.8.4 */
1589 template OCT1 sm_rp_mms /* MMS (More Messages to Send), see 7.6.8.7 */
1590) := tr_GSUP(
1591 OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST,
1592 {
1593 /**
1594 * TODO: add MT-specific fields (and IEs):
1595 * - smDeliveryTimer
1596 * - smDeliveryStartTime
1597 */
1598 tr_GSUP_IE_IMSI(imsi),
1599 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1600 tr_GSUP_IE_SM_RP_DA(sm_rp_da),
1601 tr_GSUP_IE_SM_RP_OA(sm_rp_oa),
1602 tr_GSUP_IE_SM_RP_UI(sm_rp_ui),
1603 tr_GSUP_IE_SM_RP_MMS(sm_rp_mms),
1604 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1605 tr_GSUP_IE_Source_Name(?)
1606 }
1607);
1608
1609template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_RES(
1610 hexstring imsi,
1611 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1612) := ts_GSUP(
1613 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1614 {
1615 valueof(ts_GSUP_IE_IMSI(imsi)),
1616 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1617 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1618 }
1619);
1620template GSUP_PDU tr_GSUP_MT_FORWARD_SM_RES(
1621 template hexstring imsi := ?,
1622 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1623) := tr_GSUP(
1624 OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT,
1625 {
1626 tr_GSUP_IE_IMSI(imsi),
1627 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1628 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1629 tr_GSUP_IE_Source_Name(?)
1630 }
1631);
1632
1633template (value) GSUP_PDU ts_GSUP_MT_FORWARD_SM_ERR(
1634 hexstring imsi,
1635 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1636 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1637) := ts_GSUP(
1638 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1639 {
1640 valueof(ts_GSUP_IE_IMSI(imsi)),
1641 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1642 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)),
1643 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1644 }
1645);
1646template GSUP_PDU tr_GSUP_MT_FORWARD_SM_ERR(
1647 template hexstring imsi := ?,
1648 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1649 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1650) := tr_GSUP(
1651 OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR,
1652 {
1653 tr_GSUP_IE_IMSI(imsi),
1654 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1655 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1656 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1657 tr_GSUP_IE_Source_Name(?)
1658 }
1659);
1660
1661template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_REQ(
1662 hexstring imsi,
1663 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1664 GSUP_SM_ALERT_RSN_Type sm_alert_rsn /* SM Alert Reason, see 7.6.8.8 */
1665) := ts_GSUP(
1666 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1667 {
1668 valueof(ts_GSUP_IE_IMSI(imsi)),
1669 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1670 valueof(ts_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn)),
1671 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1672 }
1673);
1674template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_REQ(
1675 template hexstring imsi := ?,
1676 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1677 template GSUP_SM_ALERT_RSN_Type sm_alert_rsn := ? /* SM Alert Reason, see 7.6.8.8 */
1678) := tr_GSUP(
1679 OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST,
1680 {
1681 tr_GSUP_IE_IMSI(imsi),
1682 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1683 tr_GSUP_IE_SM_ALERT_RSN(sm_alert_rsn),
1684 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1685 tr_GSUP_IE_Source_Name(?)
1686 }
1687);
1688
1689template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_RES(
1690 hexstring imsi,
1691 OCT1 sm_rp_mr /* Message Reference, see GSM TS 04.11, 8.2.3 */
1692) := ts_GSUP(
1693 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1694 {
1695 valueof(ts_GSUP_IE_IMSI(imsi)),
1696 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1697 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1698 }
1699);
1700template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_RES(
1701 template hexstring imsi := ?,
1702 template OCT1 sm_rp_mr := ? /* Message Reference, see GSM TS 04.11, 8.2.3 */
1703) := tr_GSUP(
1704 OSMO_GSUP_MSGT_READY_FOR_SM_RESULT,
1705 {
1706 tr_GSUP_IE_IMSI(imsi),
1707 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1708 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1709 tr_GSUP_IE_Source_Name(?)
1710 }
1711);
1712
1713template (value) GSUP_PDU ts_GSUP_MO_READY_FOR_SM_ERR(
1714 hexstring imsi,
1715 OCT1 sm_rp_mr, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1716 OCT1 sm_rp_cause /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1717) := ts_GSUP(
1718 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1719 {
1720 valueof(ts_GSUP_IE_IMSI(imsi)),
1721 valueof(ts_GSUP_IE_SM_RP_MR(sm_rp_mr)),
1722 valueof(ts_GSUP_IE_SM_RP_CAUSE(sm_rp_cause)),
1723 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS))
1724 }
1725);
1726template GSUP_PDU tr_GSUP_MO_READY_FOR_SM_ERR(
1727 template hexstring imsi := ?,
1728 template OCT1 sm_rp_mr := ?, /* Message Reference, see GSM TS 04.11, 8.2.3 */
1729 template OCT1 sm_rp_cause := ? /* RP-Cause value, see GSM TS 04.11, 8.2.5.4 */
1730) := tr_GSUP(
1731 OSMO_GSUP_MSGT_READY_FOR_SM_ERROR,
1732 {
1733 tr_GSUP_IE_IMSI(imsi),
1734 tr_GSUP_IE_SM_RP_MR(sm_rp_mr),
1735 tr_GSUP_IE_SM_RP_CAUSE(sm_rp_cause),
1736 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_SMS),
1737 tr_GSUP_IE_Source_Name(?)
1738 }
1739);
1740
1741function f_gsup_find_nested_ie_multiple(GSUP_IEs ies, GSUP_IEI iei, integer nth, out GSUP_IeValue ret) return boolean {
1742 var integer current := 0;
1743 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1744 if (ies[i].tag == iei) {
1745 if (current == nth) {
1746 ret := ies[i].val;
1747 return true;
1748 } else {
1749 current := current + 1;
1750 }
1751 }
1752 }
1753 return false;
1754}
1755
1756function f_gsup_find_nested_ie(GSUP_IEs ies, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1757 for (var integer i := 0; i < sizeof(ies); i := i+1) {
1758 if (ies[i].tag == iei) {
1759 ret := ies[i].val;
1760 return true;
1761 }
1762 }
1763 return false;
1764}
1765
1766function f_gsup_find_ie(GSUP_PDU msg, GSUP_IEI iei, out GSUP_IeValue ret) return boolean {
1767 return f_gsup_find_nested_ie(msg.ies, iei, ret);
1768}
1769
1770template GSUP_AN_APDU t_GSUP_AN_APDU(
1771 template GSUP_AN_PROTO an_proto := ?,
1772 template octetstring pdu := ?
1773) := {
1774 proto := an_proto,
1775 pdu := pdu
1776};
1777
1778template GSUP_PDU tr_GSUP_E_AN_APDU(
1779 template GSUP_MessageType msgt,
1780 template hexstring imsi := ?,
1781 template octetstring source_name := ?,
1782 template octetstring destination_name := ?,
1783 template GSUP_AN_APDU an_apdu := ?
1784) := tr_GSUP(
1785 msgt,
1786 {
1787 tr_GSUP_IE_IMSI(imsi),
1788 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1789 tr_GSUP_IE_Source_Name(source_name),
1790 tr_GSUP_IE_Destination_Name(destination_name),
1791 tr_GSUP_IE_AN_APDU(an_apdu)
1792 }
1793);
1794
1795template GSUP_PDU tr_GSUP_E_NO_PDU(
1796 template GSUP_MessageType msgt,
1797 template hexstring imsi := ?,
1798 template octetstring source_name := ?,
1799 template octetstring destination_name := ?
1800) := tr_GSUP(
1801 msgt,
1802 {
1803 tr_GSUP_IE_IMSI(imsi),
1804 tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC),
1805 tr_GSUP_IE_Source_Name(source_name),
1806 tr_GSUP_IE_Destination_Name(destination_name)
1807 }
1808);
1809
1810template (value) GSUP_PDU ts_GSUP_E_AN_APDU(
1811 GSUP_MessageType msgt,
1812 hexstring imsi,
1813 octetstring source_name,
1814 octetstring destination_name,
1815 GSUP_AN_APDU an_apdu
1816) := ts_GSUP(
1817 msgt,
1818 {
1819 valueof(ts_GSUP_IE_IMSI(imsi)),
1820 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1821 valueof(ts_GSUP_IE_Source_Name(source_name)),
1822 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1823 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1824 }
1825);
1826
1827template (value) GSUP_PDU ts_GSUP_E_PrepareHandoverResult(
1828 hexstring imsi,
1829 hexstring msisdn,
1830 octetstring source_name,
1831 octetstring destination_name,
1832 GSUP_AN_APDU an_apdu
1833) := ts_GSUP(
1834 OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT,
1835 {
1836 valueof(ts_GSUP_IE_IMSI(imsi)),
1837 valueof(ts_GSUP_IE_MSISDN(msisdn)),
1838 valueof(ts_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_INTER_MSC)),
1839 valueof(ts_GSUP_IE_Source_Name(source_name)),
1840 valueof(ts_GSUP_IE_Destination_Name(destination_name)),
1841 valueof(ts_GSUP_IE_AN_APDU(an_apdu))
1842 }
1843);
1844
1845} with { encode "RAW"; variant "FIELDORDER(msb)" }