blob: a87ef5cf261a89ea073da318d5c96858c6ad9424 [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
116template (present) PDU_SCCP tr_SCCP_CC(template (present) OCT3 source_lref,
117 template (present) OCT3 dest_lref) := {
118 connconfirm := {
119 messageType := cc,
120 destLocRef := dest_lref,
121 sourceLocRef := source_lref,
122 protClass := c_class2,
123 pointer1 := ?,
124 optionalPart := *,
125 eop := *
126 }
127}
128
Harald Welte2eb30d42021-05-13 21:54:26 +0200129private function tr_Addr(template SCCP_PAR_Address addr := *)
130return template (present) SCCP_param_CPartyAddressEnc {
131 if (istemplatekind(addr, "?")) {
132 return ?;
133 } else {
134 return ConvertASPAddressToEncodedAddress_itu(valueof(addr));
135 }
136}
137
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100138template (value) PDU_SCCP ts_SCCP_UDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
139 template (value) octetstring data,
140 template (value) BIT4 msg_hdl := '0000'B) := {
141 unitdata := {
142 messageType := udt,
143 protClass := {'0000'B, msg_hdl},
144 pointer1 := 0, /* overwritten */
145 pointer2 := 0, /* overwritten */
146 pointer3 := 0, /* overwritten */
147 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
148 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
149 data := {
150 paramLength := 0,
151 data := data
152 }
153 }
154}
155
Harald Welte2eb30d42021-05-13 21:54:26 +0200156template 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 +0100157 template octetstring data := ?,
158 template BIT4 msg_hdl := '0000'B) := {
159 unitdata := {
160 messageType := udt,
161 protClass := {'0000'B, msg_hdl},
162 pointer1 := ?,
163 pointer2 := ?,
164 pointer3 := ?,
Harald Welte2eb30d42021-05-13 21:54:26 +0200165 calledPAddress := tr_Addr(called),
166 callingPAddress := tr_Addr(calling),
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100167 data := {
Harald Weltee92cc662021-02-10 19:37:13 +0100168 paramLength := ?,
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100169 data := data
170 }
171 }
172}
173
Harald Welte4038d4c2021-10-26 14:37:54 +0200174template (value) PDU_SCCP ts_SCCP_XUDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
175 template (value) octetstring data,
176 template (value) BIT4 msg_hdl := '0000'B,
177 template (value) integer hop_ctr := 16) := {
178 extudata := {
179 messageType := xudt,
180 protClass := {'0000'B, msg_hdl},
181 hopCounter := hop_ctr,
182 pointer1 := 0, /* overwritten */
183 pointer2 := 0, /* overwritten */
184 pointer3 := 0, /* overwritten */
185 pointer4 := 0, /* overwritten */
186 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
187 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
188 data := {
189 paramLength := 0,
190 data := data
191 },
192 optionalPart := omit,
193 eop := omit
194 }
195}
196
197template PDU_SCCP tr_SCCP_XUDT(template (present) SCCP_PAR_Address calling, template (present) SCCP_PAR_Address called,
198 template octetstring data := ?,
199 template BIT4 msg_hdl := '0000'B,
200 template integer hop_ctr := ?) := {
201 extudata := {
202 messageType := xudt,
203 protClass := {'0000'B, msg_hdl},
204 hopCounter := hop_ctr,
205 pointer1 := ?,
206 pointer2 := ?,
207 pointer3 := ?,
208 pointer4 := ?,
209 calledPAddress := tr_Addr(called),
210 callingPAddress := tr_Addr(calling),
211 data := {
212 paramLength := ?,
213 data := data
214 },
215 optionalPart := { segmentation:= omit, importance := * } ifpresent,
216 eop := { paramName:= con_SCCP_eop } ifpresent
217 }
218}
219
Pau Espin Pedrol0c613ab2023-09-19 14:39:34 +0200220template (value) PDU_SCCP ts_SCCP_LUDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
221 template (value) octetstring data,
222 template (value) BIT4 msg_hdl := '0000'B,
223 template (value) integer hop_ctr := 16) := {
224 longudata := {
225 messageType := ludt,
226 protClass := {'0000'B, msg_hdl},
227 hopCounter := hop_ctr,
228 pointer1 := 0, /* overwritten */
229 pointer2 := 0, /* overwritten */
230 pointer3 := 0, /* overwritten */
231 pointer4 := 0, /* overwritten */
232 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
233 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
234 longData := {
235 paramLength := 0,
236 data := data
237 },
238 optionalPart := omit,
239 eop := omit
240 }
241}
242
243template PDU_SCCP tr_SCCP_LUDT(template (present) SCCP_PAR_Address calling, template (present) SCCP_PAR_Address called,
244 template octetstring data := ?,
245 template BIT4 msg_hdl := '0000'B,
246 template integer hop_ctr := ?) := {
247 longudata := {
248 messageType := ludt,
249 protClass := {'0000'B, msg_hdl},
250 hopCounter := hop_ctr,
251 pointer1 := ?,
252 pointer2 := ?,
253 pointer3 := ?,
254 pointer4 := ?,
255 calledPAddress := tr_Addr(called),
256 callingPAddress := tr_Addr(calling),
257 longData := {
258 paramLength := ?,
259 data := data
260 },
261 optionalPart := { segmentation:= omit, importance := * } ifpresent,
262 eop := { paramName:= con_SCCP_eop } ifpresent
263 }
264}
265
Harald Welte4038d4c2021-10-26 14:37:54 +0200266
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100267template PDU_SCCP tr_SCCP_IT(template (present) OCT3 source_lref := ?,
268 template (present) OCT3 dest_lref := ?) := {
269 inacttest := {
270 messageType := it,
271 destLocRef := dest_lref,
272 sourceLocRef := source_lref,
273 protClass := c_class2,
274 sequencingSegmenting := {
275 reserved := ?,
276 p_s := ?,
277 more := ?,
278 pr := ?
279 },
280 credit := ?
281 }
282}
283
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100284template PDU_SCCP ts_SCCP_IT(template (present) OCT3 source_lref,
285 template (present) OCT3 dest_lref) := {
286 inacttest := {
287 messageType := it,
288 destLocRef := dest_lref,
289 sourceLocRef := source_lref,
290 protClass := c_class2,
291 /* rfc3868 3.3.11: sequencing and credit are ignored with class2 */
292 sequencingSegmenting := {
293 reserved := '0'B,
294 p_s := '0000000'B,
295 more := '0'B,
296 pr := '0000000'B
297 },
298 credit := '00'O
299 }
300}
301
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100302template PDU_SCCP tr_SCCP_RLSD(template (present) OCT3 source_lref := ?,
303 template (present) OCT3 dest_lref := ?,
304 template (present) SCCP_param_ReleaseCause relcause := ?) := {
305 released := {
306 messageType := rlsd,
307 destLocRef := dest_lref,
308 sourceLocRef := source_lref,
309 releaseCause := relcause,
310 pointer1 := ?,
311 optionalPart := *,
312 eop := *
313 }
314}
315
316template PDU_SCCP ts_SCCP_RLC(OCT3 source_lref, OCT3 dest_lref) := {
317 relcomp := {
318 messageType := rlc,
319 destLocRef := dest_lref,
320 sourceLocRef := source_lref
321 }
322}
323
324template PDU_SCCP tr_SCCP_RLC(template (present) OCT3 source_lref := ?,
325 template (present) OCT3 dest_lref := ?) := {
326 relcomp := {
327 messageType := rlc,
328 destLocRef := dest_lref,
329 sourceLocRef := source_lref
330 }
331}
332
Harald Welte24f921b2021-02-10 19:37:45 +0100333private function f_pc_int2bit(template (present) integer pc)
334return template SCMG_param_AffectedPointCode {
335 if (istemplatekind(pc, "?")) {
336 return ?;
337 } else {
338 return int2bit(valueof(pc), 16);
339 }
340}
341
342template (value) PDU_SCMG_message ts_SCMG_SSA(template (value) integer ssn,
343 integer pc,
344 template (value) BIT2 smi := '00'B) := {
345 messageType := sSAallowed,
346 affectedSSN := ssn,
347 affectedPC := int2bit(valueof(pc), 16),
348 smi := {
349 smi := smi,
350 reserved := '000000'B
351 },
352 congLevel := omit
353}
354template (present) PDU_SCMG_message tr_SCMG_SSA(template (present) integer ssn := ?,
355 template (present) integer pc := ?,
356 template (present) BIT2 smi := ?) := {
357 messageType := sSAallowed,
358 affectedSSN := ssn,
359 affectedPC := f_pc_int2bit(pc),
360 smi := {
361 smi := smi,
362 reserved := '000000'B
363 },
364 congLevel := omit
365}
366
367template (value) PDU_SCMG_message ts_SCMG_SSP(template (value) integer ssn,
368 integer pc,
369 template (value) BIT2 smi := '00'B) := {
370 messageType := sSPprohib,
371 affectedSSN := ssn,
372 affectedPC := int2bit(valueof(pc), 16),
373 smi := {
374 smi := smi,
375 reserved := '000000'B
376 },
377 congLevel := omit
378}
379template (present) PDU_SCMG_message tr_SCMG_SSP(template (present) integer ssn := ?,
380 template (present) integer pc := ?,
381 template (present) BIT2 smi := ?) := {
382 messageType := sSPprohib,
383 affectedSSN := ssn,
384 affectedPC := f_pc_int2bit(pc),
385 smi := {
386 smi := smi,
387 reserved := '000000'B
388 },
389 congLevel := omit
390}
391
392template (value) PDU_SCMG_message ts_SCMG_SST(template (value) integer ssn,
393 integer pc,
394 template (value) BIT2 smi := '00'B) := {
395 messageType := sSTstaTest,
396 affectedSSN := ssn,
397 affectedPC := int2bit(valueof(pc), 16),
398 smi := {
399 smi := smi,
400 reserved := '000000'B
401 },
402 congLevel := omit
403}
404template (present) PDU_SCMG_message tr_SCMG_SST(template (present) integer ssn := ?,
405 template (present) integer pc := ?,
406 template (present) BIT2 smi := ?) := {
407 messageType := sSTstaTest,
408 affectedSSN := ssn,
409 affectedPC := f_pc_int2bit(pc),
410 smi := {
411 smi := smi,
412 reserved := '000000'B
413 },
414 congLevel := omit
415}
416
417
Harald Welte0db44132019-10-17 11:09:05 +0200418
Stefan Sperlingc307e682018-06-14 15:15:46 +0200419}