blob: 6c977ac4d467d745c87e354b98377534be2a490e [file] [log] [blame]
Stefan Sperlingc307e682018-06-14 15:15:46 +02001/* (C) 2018 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
2 * All Rights Reserved
3 *
4 * Released under the terms of GNU General Public License, Version 2 or
5 * (at your option) any later version.
Harald Welte34b5a952019-05-27 11:54:11 +02006 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
Stefan Sperlingc307e682018-06-14 15:15:46 +02008 */
9
10module SCCP_Templates {
11
Pau Espin Pedrola2473da2020-01-20 13:20:58 +010012import from General_Types all;
13
Stefan Sperlingc307e682018-06-14 15:15:46 +020014import from SCCP_Types all;
15import from SCCPasp_Types all;
16import from SCCP_Emulation all;
17
Harald Welteaed9f942021-05-13 21:54:58 +020018/* construct a SCCP_PAR_Address with just SSN and no PC or GT */
19template (value) SCCP_PAR_Address ts_SccpAddr_SSN(integer ssn) := {
20 addressIndicator := {
21 pointCodeIndic := '0'B,
22 ssnIndicator := '1'B,
23 globalTitleIndic := '0000'B,
24 routingIndicator := '1'B
25 },
26 signPointCode := omit,
27 subsystemNumber := ssn,
28 globalTitle := omit
29}
30
Stefan Sperlingc307e682018-06-14 15:15:46 +020031/* construct a SCCP_PAR_Address with just PC + SSN and no GT */
32template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn, octetstring sio,
33 charstring sccp_srv_type) := {
34 addressIndicator := {
35 pointCodeIndic := '1'B,
36 ssnIndicator := '1'B,
37 globalTitleIndic := '0000'B,
38 routingIndicator := '1'B
39 },
40 signPointCode := SCCP_SPC_int2bit(pc, sccp_srv_type, sio),
41 subsystemNumber := ssn,
42 globalTitle := omit
43}
44
45/* construct a SCCP_PAR_Address with only GT */
46template (value) SCCP_PAR_Address ts_SccpAddr_GT(hexstring global_address) := {
47 addressIndicator := {
48 pointCodeIndic := '0'B,
49 ssnIndicator := '0'B,
50 globalTitleIndic := '0001'B, // NAI only
51 routingIndicator := cg_route_on_GT // route on GT
52 },
53 signPointCode := omit,
54 subsystemNumber := omit,
55 globalTitle := {
56 gti0001 := {
57 natureOfAddress := '0000011'B,
58 oddeven := '0'B,
59 globalTitleAddress := global_address
60 }
61 }
62}
63
Harald Welte0db44132019-10-17 11:09:05 +020064/* construct a SCCP_PAR_Address with PC + SSN and GT */
65template (value) SCCP_PAR_Address ts_SccpAddr_PC_GT(integer pc, octetstring sio,
66 charstring sccp_srv_type, hexstring gt_addr) := {
67 addressIndicator := {
68 pointCodeIndic := '1'B,
69 ssnIndicator := '0'B,
70 globalTitleIndic := '0001'B, // NAI only
71 routingIndicator := cg_route_on_GT // route on GT
72 },
73 signPointCode := SCCP_SPC_int2bit(pc, sccp_srv_type, sio),
74 subsystemNumber := omit,
75 globalTitle := {
76 gti0001 := {
77 natureOfAddress := '0000011'B,
78 oddeven := '0'B,
79 globalTitleAddress := gt_addr
80 }
81 }
82}
83
Pau Espin Pedrola2473da2020-01-20 13:20:58 +010084/* connection oriented SCCP */
85const SCCP_param_ProtocolClass c_class2 := { class:='0010'B, messageHandling:='0000'B };//class 2
86
87function ts_SCCP_CR(OCT3 source_lref, SCCP_PAR_Address calling, SCCP_PAR_Address called)
88return template (value) PDU_SCCP {
89 var SCCP_param_CPartyAddressEnc calling_enc := ConvertASPAddressToEncodedAddress_itu(calling);
90
91 var template (value) PDU_SCCP ret := {
92 connrequest := {
93 messageType := cr,
94 sourceLocRef := source_lref,
95 protClass := c_class2,
96 pointer1 := 2,
97 pointer2 := 0, /* overwritten */
98 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
99 optionalPart := {
100 credit := omit,
101 callingPAddress := {
102 paramName := con_SCCP_cgPA,
103 paramLength := calling_enc.paramLength, /* overwritten */
104 addr := calling_enc.addr
105 },
106 data := omit,
107 hopCounter := omit,
108 importance := omit
109 },
110 eop := { paramName:= con_SCCP_eop }
111 }
112 }
113 return ret;
114}
115
Pau Espin Pedrol27486792023-10-30 18:13:20 +0100116template (present) PDU_SCCP tr_SCCP_CR(template (present) OCT3 source_lref := ?,
117 template (present) SCCP_PAR_Address called := ?,
118 template (present) SCCP_PAR_Address calling := ?) := {
119 connrequest := {
120 messageType := cr,
121 sourceLocRef := source_lref,
122 protClass := c_class2,
123 pointer1 := ?,
124 pointer2 := ?,
125 calledPAddress := tr_Addr(called),
126 optionalPart := {
127 credit := omit,
128 callingPAddress := tr_Addr_opt(calling),
129 data := omit,
130 hopCounter := *,
131 importance := *
132 },
133 eop := *
134 }
135}
136
137template (value) PDU_SCCP ts_SCCP_CC(OCT3 source_lref, OCT3 dest_lref) := {
138 connconfirm := {
139 messageType := cc,
140 destLocRef := dest_lref,
141 sourceLocRef := source_lref,
142 protClass := c_class2,
143 pointer1 := 0, /* overwritten */
144 optionalPart := omit,
145 eop := { paramName:= con_SCCP_eop }
146 }
147}
148
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100149template (present) PDU_SCCP tr_SCCP_CC(template (present) OCT3 source_lref,
150 template (present) OCT3 dest_lref) := {
151 connconfirm := {
152 messageType := cc,
153 destLocRef := dest_lref,
154 sourceLocRef := source_lref,
155 protClass := c_class2,
156 pointer1 := ?,
157 optionalPart := *,
158 eop := *
159 }
160}
161
Harald Welte2eb30d42021-05-13 21:54:26 +0200162private function tr_Addr(template SCCP_PAR_Address addr := *)
163return template (present) SCCP_param_CPartyAddressEnc {
164 if (istemplatekind(addr, "?")) {
165 return ?;
166 } else {
167 return ConvertASPAddressToEncodedAddress_itu(valueof(addr));
168 }
169}
170
Pau Espin Pedrol27486792023-10-30 18:13:20 +0100171private function tr_Addr_opt(template SCCP_PAR_Address addr := *)
172return template SCCP_param_CPartyAddressEnc_opt {
173 if (istemplatekind(addr, "omit")) {
174 return omit;
175 } else if (istemplatekind(addr, "*")) {
176 return *;
177 } else if (istemplatekind(addr, "?")) {
178 return ?;
179 } else {
180 var SCCP_param_CPartyAddressEnc enc := ConvertASPAddressToEncodedAddress_itu(valueof(addr));
181 var SCCP_param_CPartyAddressEnc_opt enc_opt := {
182 paramName := con_SCCP_cgPA,
183 paramLength := enc.paramLength, /* overwritten */
184 addr := enc.addr
185 };
186 return enc_opt;
187 }
188}
189
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100190template (value) PDU_SCCP ts_SCCP_UDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
191 template (value) octetstring data,
192 template (value) BIT4 msg_hdl := '0000'B) := {
193 unitdata := {
194 messageType := udt,
195 protClass := {'0000'B, msg_hdl},
196 pointer1 := 0, /* overwritten */
197 pointer2 := 0, /* overwritten */
198 pointer3 := 0, /* overwritten */
199 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
200 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
201 data := {
202 paramLength := 0,
203 data := data
204 }
205 }
206}
207
Harald Welte2eb30d42021-05-13 21:54:26 +0200208template PDU_SCCP tr_SCCP_UDT(template (present) SCCP_PAR_Address calling, template (present) SCCP_PAR_Address called,
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100209 template octetstring data := ?,
210 template BIT4 msg_hdl := '0000'B) := {
211 unitdata := {
212 messageType := udt,
213 protClass := {'0000'B, msg_hdl},
214 pointer1 := ?,
215 pointer2 := ?,
216 pointer3 := ?,
Harald Welte2eb30d42021-05-13 21:54:26 +0200217 calledPAddress := tr_Addr(called),
218 callingPAddress := tr_Addr(calling),
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100219 data := {
Harald Weltee92cc662021-02-10 19:37:13 +0100220 paramLength := ?,
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100221 data := data
222 }
223 }
224}
225
Harald Welte4038d4c2021-10-26 14:37:54 +0200226template (value) PDU_SCCP ts_SCCP_XUDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
227 template (value) octetstring data,
228 template (value) BIT4 msg_hdl := '0000'B,
229 template (value) integer hop_ctr := 16) := {
230 extudata := {
231 messageType := xudt,
232 protClass := {'0000'B, msg_hdl},
233 hopCounter := hop_ctr,
234 pointer1 := 0, /* overwritten */
235 pointer2 := 0, /* overwritten */
236 pointer3 := 0, /* overwritten */
237 pointer4 := 0, /* overwritten */
238 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
239 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
240 data := {
241 paramLength := 0,
242 data := data
243 },
244 optionalPart := omit,
245 eop := omit
246 }
247}
248
249template PDU_SCCP tr_SCCP_XUDT(template (present) SCCP_PAR_Address calling, template (present) SCCP_PAR_Address called,
250 template octetstring data := ?,
251 template BIT4 msg_hdl := '0000'B,
252 template integer hop_ctr := ?) := {
253 extudata := {
254 messageType := xudt,
255 protClass := {'0000'B, msg_hdl},
256 hopCounter := hop_ctr,
257 pointer1 := ?,
258 pointer2 := ?,
259 pointer3 := ?,
260 pointer4 := ?,
261 calledPAddress := tr_Addr(called),
262 callingPAddress := tr_Addr(calling),
263 data := {
264 paramLength := ?,
265 data := data
266 },
267 optionalPart := { segmentation:= omit, importance := * } ifpresent,
268 eop := { paramName:= con_SCCP_eop } ifpresent
269 }
270}
271
Pau Espin Pedrol0c613ab2023-09-19 14:39:34 +0200272template (value) PDU_SCCP ts_SCCP_LUDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
273 template (value) octetstring data,
274 template (value) BIT4 msg_hdl := '0000'B,
275 template (value) integer hop_ctr := 16) := {
276 longudata := {
277 messageType := ludt,
278 protClass := {'0000'B, msg_hdl},
279 hopCounter := hop_ctr,
280 pointer1 := 0, /* overwritten */
281 pointer2 := 0, /* overwritten */
282 pointer3 := 0, /* overwritten */
283 pointer4 := 0, /* overwritten */
284 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
285 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
286 longData := {
287 paramLength := 0,
288 data := data
289 },
290 optionalPart := omit,
291 eop := omit
292 }
293}
294
295template PDU_SCCP tr_SCCP_LUDT(template (present) SCCP_PAR_Address calling, template (present) SCCP_PAR_Address called,
296 template octetstring data := ?,
297 template BIT4 msg_hdl := '0000'B,
298 template integer hop_ctr := ?) := {
299 longudata := {
300 messageType := ludt,
301 protClass := {'0000'B, msg_hdl},
302 hopCounter := hop_ctr,
303 pointer1 := ?,
304 pointer2 := ?,
305 pointer3 := ?,
306 pointer4 := ?,
307 calledPAddress := tr_Addr(called),
308 callingPAddress := tr_Addr(calling),
309 longData := {
310 paramLength := ?,
311 data := data
312 },
313 optionalPart := { segmentation:= omit, importance := * } ifpresent,
314 eop := { paramName:= con_SCCP_eop } ifpresent
315 }
316}
317
Harald Welte4038d4c2021-10-26 14:37:54 +0200318
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100319template PDU_SCCP tr_SCCP_IT(template (present) OCT3 source_lref := ?,
320 template (present) OCT3 dest_lref := ?) := {
321 inacttest := {
322 messageType := it,
323 destLocRef := dest_lref,
324 sourceLocRef := source_lref,
325 protClass := c_class2,
326 sequencingSegmenting := {
327 reserved := ?,
328 p_s := ?,
329 more := ?,
330 pr := ?
331 },
332 credit := ?
333 }
334}
335
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100336template PDU_SCCP ts_SCCP_IT(template (present) OCT3 source_lref,
337 template (present) OCT3 dest_lref) := {
338 inacttest := {
339 messageType := it,
340 destLocRef := dest_lref,
341 sourceLocRef := source_lref,
342 protClass := c_class2,
343 /* rfc3868 3.3.11: sequencing and credit are ignored with class2 */
344 sequencingSegmenting := {
345 reserved := '0'B,
346 p_s := '0000000'B,
347 more := '0'B,
348 pr := '0000000'B
349 },
350 credit := '00'O
351 }
352}
353
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100354template PDU_SCCP tr_SCCP_RLSD(template (present) OCT3 source_lref := ?,
355 template (present) OCT3 dest_lref := ?,
356 template (present) SCCP_param_ReleaseCause relcause := ?) := {
357 released := {
358 messageType := rlsd,
359 destLocRef := dest_lref,
360 sourceLocRef := source_lref,
361 releaseCause := relcause,
362 pointer1 := ?,
363 optionalPart := *,
364 eop := *
365 }
366}
367
368template PDU_SCCP ts_SCCP_RLC(OCT3 source_lref, OCT3 dest_lref) := {
369 relcomp := {
370 messageType := rlc,
371 destLocRef := dest_lref,
372 sourceLocRef := source_lref
373 }
374}
375
376template PDU_SCCP tr_SCCP_RLC(template (present) OCT3 source_lref := ?,
377 template (present) OCT3 dest_lref := ?) := {
378 relcomp := {
379 messageType := rlc,
380 destLocRef := dest_lref,
381 sourceLocRef := source_lref
382 }
383}
384
Harald Welte24f921b2021-02-10 19:37:45 +0100385private function f_pc_int2bit(template (present) integer pc)
386return template SCMG_param_AffectedPointCode {
387 if (istemplatekind(pc, "?")) {
388 return ?;
389 } else {
390 return int2bit(valueof(pc), 16);
391 }
392}
393
394template (value) PDU_SCMG_message ts_SCMG_SSA(template (value) integer ssn,
395 integer pc,
396 template (value) BIT2 smi := '00'B) := {
397 messageType := sSAallowed,
398 affectedSSN := ssn,
399 affectedPC := int2bit(valueof(pc), 16),
400 smi := {
401 smi := smi,
402 reserved := '000000'B
403 },
404 congLevel := omit
405}
406template (present) PDU_SCMG_message tr_SCMG_SSA(template (present) integer ssn := ?,
407 template (present) integer pc := ?,
408 template (present) BIT2 smi := ?) := {
409 messageType := sSAallowed,
410 affectedSSN := ssn,
411 affectedPC := f_pc_int2bit(pc),
412 smi := {
413 smi := smi,
414 reserved := '000000'B
415 },
416 congLevel := omit
417}
418
419template (value) PDU_SCMG_message ts_SCMG_SSP(template (value) integer ssn,
420 integer pc,
421 template (value) BIT2 smi := '00'B) := {
422 messageType := sSPprohib,
423 affectedSSN := ssn,
424 affectedPC := int2bit(valueof(pc), 16),
425 smi := {
426 smi := smi,
427 reserved := '000000'B
428 },
429 congLevel := omit
430}
431template (present) PDU_SCMG_message tr_SCMG_SSP(template (present) integer ssn := ?,
432 template (present) integer pc := ?,
433 template (present) BIT2 smi := ?) := {
434 messageType := sSPprohib,
435 affectedSSN := ssn,
436 affectedPC := f_pc_int2bit(pc),
437 smi := {
438 smi := smi,
439 reserved := '000000'B
440 },
441 congLevel := omit
442}
443
444template (value) PDU_SCMG_message ts_SCMG_SST(template (value) integer ssn,
445 integer pc,
446 template (value) BIT2 smi := '00'B) := {
447 messageType := sSTstaTest,
448 affectedSSN := ssn,
449 affectedPC := int2bit(valueof(pc), 16),
450 smi := {
451 smi := smi,
452 reserved := '000000'B
453 },
454 congLevel := omit
455}
456template (present) PDU_SCMG_message tr_SCMG_SST(template (present) integer ssn := ?,
457 template (present) integer pc := ?,
458 template (present) BIT2 smi := ?) := {
459 messageType := sSTstaTest,
460 affectedSSN := ssn,
461 affectedPC := f_pc_int2bit(pc),
462 smi := {
463 smi := smi,
464 reserved := '000000'B
465 },
466 congLevel := omit
467}
468
469
Harald Welte0db44132019-10-17 11:09:05 +0200470
Stefan Sperlingc307e682018-06-14 15:15:46 +0200471}