blob: 74f1a2062eed91160166696829d0baab3701d579 [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
220
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100221template PDU_SCCP tr_SCCP_IT(template (present) OCT3 source_lref := ?,
222 template (present) OCT3 dest_lref := ?) := {
223 inacttest := {
224 messageType := it,
225 destLocRef := dest_lref,
226 sourceLocRef := source_lref,
227 protClass := c_class2,
228 sequencingSegmenting := {
229 reserved := ?,
230 p_s := ?,
231 more := ?,
232 pr := ?
233 },
234 credit := ?
235 }
236}
237
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100238template PDU_SCCP ts_SCCP_IT(template (present) OCT3 source_lref,
239 template (present) OCT3 dest_lref) := {
240 inacttest := {
241 messageType := it,
242 destLocRef := dest_lref,
243 sourceLocRef := source_lref,
244 protClass := c_class2,
245 /* rfc3868 3.3.11: sequencing and credit are ignored with class2 */
246 sequencingSegmenting := {
247 reserved := '0'B,
248 p_s := '0000000'B,
249 more := '0'B,
250 pr := '0000000'B
251 },
252 credit := '00'O
253 }
254}
255
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100256template PDU_SCCP tr_SCCP_RLSD(template (present) OCT3 source_lref := ?,
257 template (present) OCT3 dest_lref := ?,
258 template (present) SCCP_param_ReleaseCause relcause := ?) := {
259 released := {
260 messageType := rlsd,
261 destLocRef := dest_lref,
262 sourceLocRef := source_lref,
263 releaseCause := relcause,
264 pointer1 := ?,
265 optionalPart := *,
266 eop := *
267 }
268}
269
270template PDU_SCCP ts_SCCP_RLC(OCT3 source_lref, OCT3 dest_lref) := {
271 relcomp := {
272 messageType := rlc,
273 destLocRef := dest_lref,
274 sourceLocRef := source_lref
275 }
276}
277
278template PDU_SCCP tr_SCCP_RLC(template (present) OCT3 source_lref := ?,
279 template (present) OCT3 dest_lref := ?) := {
280 relcomp := {
281 messageType := rlc,
282 destLocRef := dest_lref,
283 sourceLocRef := source_lref
284 }
285}
286
Harald Welte24f921b2021-02-10 19:37:45 +0100287private function f_pc_int2bit(template (present) integer pc)
288return template SCMG_param_AffectedPointCode {
289 if (istemplatekind(pc, "?")) {
290 return ?;
291 } else {
292 return int2bit(valueof(pc), 16);
293 }
294}
295
296template (value) PDU_SCMG_message ts_SCMG_SSA(template (value) integer ssn,
297 integer pc,
298 template (value) BIT2 smi := '00'B) := {
299 messageType := sSAallowed,
300 affectedSSN := ssn,
301 affectedPC := int2bit(valueof(pc), 16),
302 smi := {
303 smi := smi,
304 reserved := '000000'B
305 },
306 congLevel := omit
307}
308template (present) PDU_SCMG_message tr_SCMG_SSA(template (present) integer ssn := ?,
309 template (present) integer pc := ?,
310 template (present) BIT2 smi := ?) := {
311 messageType := sSAallowed,
312 affectedSSN := ssn,
313 affectedPC := f_pc_int2bit(pc),
314 smi := {
315 smi := smi,
316 reserved := '000000'B
317 },
318 congLevel := omit
319}
320
321template (value) PDU_SCMG_message ts_SCMG_SSP(template (value) integer ssn,
322 integer pc,
323 template (value) BIT2 smi := '00'B) := {
324 messageType := sSPprohib,
325 affectedSSN := ssn,
326 affectedPC := int2bit(valueof(pc), 16),
327 smi := {
328 smi := smi,
329 reserved := '000000'B
330 },
331 congLevel := omit
332}
333template (present) PDU_SCMG_message tr_SCMG_SSP(template (present) integer ssn := ?,
334 template (present) integer pc := ?,
335 template (present) BIT2 smi := ?) := {
336 messageType := sSPprohib,
337 affectedSSN := ssn,
338 affectedPC := f_pc_int2bit(pc),
339 smi := {
340 smi := smi,
341 reserved := '000000'B
342 },
343 congLevel := omit
344}
345
346template (value) PDU_SCMG_message ts_SCMG_SST(template (value) integer ssn,
347 integer pc,
348 template (value) BIT2 smi := '00'B) := {
349 messageType := sSTstaTest,
350 affectedSSN := ssn,
351 affectedPC := int2bit(valueof(pc), 16),
352 smi := {
353 smi := smi,
354 reserved := '000000'B
355 },
356 congLevel := omit
357}
358template (present) PDU_SCMG_message tr_SCMG_SST(template (present) integer ssn := ?,
359 template (present) integer pc := ?,
360 template (present) BIT2 smi := ?) := {
361 messageType := sSTstaTest,
362 affectedSSN := ssn,
363 affectedPC := f_pc_int2bit(pc),
364 smi := {
365 smi := smi,
366 reserved := '000000'B
367 },
368 congLevel := omit
369}
370
371
Harald Welte0db44132019-10-17 11:09:05 +0200372
Stefan Sperlingc307e682018-06-14 15:15:46 +0200373}