blob: 55bf74559b673598ec22614cc7ac10018fc1a86a [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
18/* construct a SCCP_PAR_Address with just PC + SSN and no GT */
19template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn, octetstring sio,
20 charstring sccp_srv_type) := {
21 addressIndicator := {
22 pointCodeIndic := '1'B,
23 ssnIndicator := '1'B,
24 globalTitleIndic := '0000'B,
25 routingIndicator := '1'B
26 },
27 signPointCode := SCCP_SPC_int2bit(pc, sccp_srv_type, sio),
28 subsystemNumber := ssn,
29 globalTitle := omit
30}
31
32/* construct a SCCP_PAR_Address with only GT */
33template (value) SCCP_PAR_Address ts_SccpAddr_GT(hexstring global_address) := {
34 addressIndicator := {
35 pointCodeIndic := '0'B,
36 ssnIndicator := '0'B,
37 globalTitleIndic := '0001'B, // NAI only
38 routingIndicator := cg_route_on_GT // route on GT
39 },
40 signPointCode := omit,
41 subsystemNumber := omit,
42 globalTitle := {
43 gti0001 := {
44 natureOfAddress := '0000011'B,
45 oddeven := '0'B,
46 globalTitleAddress := global_address
47 }
48 }
49}
50
Harald Welte0db44132019-10-17 11:09:05 +020051/* construct a SCCP_PAR_Address with PC + SSN and GT */
52template (value) SCCP_PAR_Address ts_SccpAddr_PC_GT(integer pc, octetstring sio,
53 charstring sccp_srv_type, hexstring gt_addr) := {
54 addressIndicator := {
55 pointCodeIndic := '1'B,
56 ssnIndicator := '0'B,
57 globalTitleIndic := '0001'B, // NAI only
58 routingIndicator := cg_route_on_GT // route on GT
59 },
60 signPointCode := SCCP_SPC_int2bit(pc, sccp_srv_type, sio),
61 subsystemNumber := omit,
62 globalTitle := {
63 gti0001 := {
64 natureOfAddress := '0000011'B,
65 oddeven := '0'B,
66 globalTitleAddress := gt_addr
67 }
68 }
69}
70
Pau Espin Pedrola2473da2020-01-20 13:20:58 +010071/* connection oriented SCCP */
72const SCCP_param_ProtocolClass c_class2 := { class:='0010'B, messageHandling:='0000'B };//class 2
73
74function ts_SCCP_CR(OCT3 source_lref, SCCP_PAR_Address calling, SCCP_PAR_Address called)
75return template (value) PDU_SCCP {
76 var SCCP_param_CPartyAddressEnc calling_enc := ConvertASPAddressToEncodedAddress_itu(calling);
77
78 var template (value) PDU_SCCP ret := {
79 connrequest := {
80 messageType := cr,
81 sourceLocRef := source_lref,
82 protClass := c_class2,
83 pointer1 := 2,
84 pointer2 := 0, /* overwritten */
85 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
86 optionalPart := {
87 credit := omit,
88 callingPAddress := {
89 paramName := con_SCCP_cgPA,
90 paramLength := calling_enc.paramLength, /* overwritten */
91 addr := calling_enc.addr
92 },
93 data := omit,
94 hopCounter := omit,
95 importance := omit
96 },
97 eop := { paramName:= con_SCCP_eop }
98 }
99 }
100 return ret;
101}
102
103template (present) PDU_SCCP tr_SCCP_CC(template (present) OCT3 source_lref,
104 template (present) OCT3 dest_lref) := {
105 connconfirm := {
106 messageType := cc,
107 destLocRef := dest_lref,
108 sourceLocRef := source_lref,
109 protClass := c_class2,
110 pointer1 := ?,
111 optionalPart := *,
112 eop := *
113 }
114}
115
Harald Welte2eb30d42021-05-13 21:54:26 +0200116private function tr_Addr(template SCCP_PAR_Address addr := *)
117return template (present) SCCP_param_CPartyAddressEnc {
118 if (istemplatekind(addr, "?")) {
119 return ?;
120 } else {
121 return ConvertASPAddressToEncodedAddress_itu(valueof(addr));
122 }
123}
124
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100125template (value) PDU_SCCP ts_SCCP_UDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
126 template (value) octetstring data,
127 template (value) BIT4 msg_hdl := '0000'B) := {
128 unitdata := {
129 messageType := udt,
130 protClass := {'0000'B, msg_hdl},
131 pointer1 := 0, /* overwritten */
132 pointer2 := 0, /* overwritten */
133 pointer3 := 0, /* overwritten */
134 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
135 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
136 data := {
137 paramLength := 0,
138 data := data
139 }
140 }
141}
142
Harald Welte2eb30d42021-05-13 21:54:26 +0200143template 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 +0100144 template octetstring data := ?,
145 template BIT4 msg_hdl := '0000'B) := {
146 unitdata := {
147 messageType := udt,
148 protClass := {'0000'B, msg_hdl},
149 pointer1 := ?,
150 pointer2 := ?,
151 pointer3 := ?,
Harald Welte2eb30d42021-05-13 21:54:26 +0200152 calledPAddress := tr_Addr(called),
153 callingPAddress := tr_Addr(calling),
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100154 data := {
Harald Weltee92cc662021-02-10 19:37:13 +0100155 paramLength := ?,
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100156 data := data
157 }
158 }
159}
160
161template PDU_SCCP tr_SCCP_IT(template (present) OCT3 source_lref := ?,
162 template (present) OCT3 dest_lref := ?) := {
163 inacttest := {
164 messageType := it,
165 destLocRef := dest_lref,
166 sourceLocRef := source_lref,
167 protClass := c_class2,
168 sequencingSegmenting := {
169 reserved := ?,
170 p_s := ?,
171 more := ?,
172 pr := ?
173 },
174 credit := ?
175 }
176}
177
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100178template PDU_SCCP ts_SCCP_IT(template (present) OCT3 source_lref,
179 template (present) OCT3 dest_lref) := {
180 inacttest := {
181 messageType := it,
182 destLocRef := dest_lref,
183 sourceLocRef := source_lref,
184 protClass := c_class2,
185 /* rfc3868 3.3.11: sequencing and credit are ignored with class2 */
186 sequencingSegmenting := {
187 reserved := '0'B,
188 p_s := '0000000'B,
189 more := '0'B,
190 pr := '0000000'B
191 },
192 credit := '00'O
193 }
194}
195
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100196template PDU_SCCP tr_SCCP_RLSD(template (present) OCT3 source_lref := ?,
197 template (present) OCT3 dest_lref := ?,
198 template (present) SCCP_param_ReleaseCause relcause := ?) := {
199 released := {
200 messageType := rlsd,
201 destLocRef := dest_lref,
202 sourceLocRef := source_lref,
203 releaseCause := relcause,
204 pointer1 := ?,
205 optionalPart := *,
206 eop := *
207 }
208}
209
210template PDU_SCCP ts_SCCP_RLC(OCT3 source_lref, OCT3 dest_lref) := {
211 relcomp := {
212 messageType := rlc,
213 destLocRef := dest_lref,
214 sourceLocRef := source_lref
215 }
216}
217
218template PDU_SCCP tr_SCCP_RLC(template (present) OCT3 source_lref := ?,
219 template (present) OCT3 dest_lref := ?) := {
220 relcomp := {
221 messageType := rlc,
222 destLocRef := dest_lref,
223 sourceLocRef := source_lref
224 }
225}
226
Harald Welte24f921b2021-02-10 19:37:45 +0100227private function f_pc_int2bit(template (present) integer pc)
228return template SCMG_param_AffectedPointCode {
229 if (istemplatekind(pc, "?")) {
230 return ?;
231 } else {
232 return int2bit(valueof(pc), 16);
233 }
234}
235
236template (value) PDU_SCMG_message ts_SCMG_SSA(template (value) integer ssn,
237 integer pc,
238 template (value) BIT2 smi := '00'B) := {
239 messageType := sSAallowed,
240 affectedSSN := ssn,
241 affectedPC := int2bit(valueof(pc), 16),
242 smi := {
243 smi := smi,
244 reserved := '000000'B
245 },
246 congLevel := omit
247}
248template (present) PDU_SCMG_message tr_SCMG_SSA(template (present) integer ssn := ?,
249 template (present) integer pc := ?,
250 template (present) BIT2 smi := ?) := {
251 messageType := sSAallowed,
252 affectedSSN := ssn,
253 affectedPC := f_pc_int2bit(pc),
254 smi := {
255 smi := smi,
256 reserved := '000000'B
257 },
258 congLevel := omit
259}
260
261template (value) PDU_SCMG_message ts_SCMG_SSP(template (value) integer ssn,
262 integer pc,
263 template (value) BIT2 smi := '00'B) := {
264 messageType := sSPprohib,
265 affectedSSN := ssn,
266 affectedPC := int2bit(valueof(pc), 16),
267 smi := {
268 smi := smi,
269 reserved := '000000'B
270 },
271 congLevel := omit
272}
273template (present) PDU_SCMG_message tr_SCMG_SSP(template (present) integer ssn := ?,
274 template (present) integer pc := ?,
275 template (present) BIT2 smi := ?) := {
276 messageType := sSPprohib,
277 affectedSSN := ssn,
278 affectedPC := f_pc_int2bit(pc),
279 smi := {
280 smi := smi,
281 reserved := '000000'B
282 },
283 congLevel := omit
284}
285
286template (value) PDU_SCMG_message ts_SCMG_SST(template (value) integer ssn,
287 integer pc,
288 template (value) BIT2 smi := '00'B) := {
289 messageType := sSTstaTest,
290 affectedSSN := ssn,
291 affectedPC := int2bit(valueof(pc), 16),
292 smi := {
293 smi := smi,
294 reserved := '000000'B
295 },
296 congLevel := omit
297}
298template (present) PDU_SCMG_message tr_SCMG_SST(template (present) integer ssn := ?,
299 template (present) integer pc := ?,
300 template (present) BIT2 smi := ?) := {
301 messageType := sSTstaTest,
302 affectedSSN := ssn,
303 affectedPC := f_pc_int2bit(pc),
304 smi := {
305 smi := smi,
306 reserved := '000000'B
307 },
308 congLevel := omit
309}
310
311
Harald Welte0db44132019-10-17 11:09:05 +0200312
Stefan Sperlingc307e682018-06-14 15:15:46 +0200313}