blob: 9936dd09213ae1dbab43c252c92a903287b3d0d7 [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
116template (value) PDU_SCCP ts_SCCP_UDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
117 template (value) octetstring data,
118 template (value) BIT4 msg_hdl := '0000'B) := {
119 unitdata := {
120 messageType := udt,
121 protClass := {'0000'B, msg_hdl},
122 pointer1 := 0, /* overwritten */
123 pointer2 := 0, /* overwritten */
124 pointer3 := 0, /* overwritten */
125 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
126 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
127 data := {
128 paramLength := 0,
129 data := data
130 }
131 }
132}
133
134template PDU_SCCP tr_SCCP_UDT(SCCP_PAR_Address calling, SCCP_PAR_Address called,
135 template octetstring data := ?,
136 template BIT4 msg_hdl := '0000'B) := {
137 unitdata := {
138 messageType := udt,
139 protClass := {'0000'B, msg_hdl},
140 pointer1 := ?,
141 pointer2 := ?,
142 pointer3 := ?,
143 calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
144 callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling),
145 data := {
Harald Weltee92cc662021-02-10 19:37:13 +0100146 paramLength := ?,
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100147 data := data
148 }
149 }
150}
151
152template PDU_SCCP tr_SCCP_IT(template (present) OCT3 source_lref := ?,
153 template (present) OCT3 dest_lref := ?) := {
154 inacttest := {
155 messageType := it,
156 destLocRef := dest_lref,
157 sourceLocRef := source_lref,
158 protClass := c_class2,
159 sequencingSegmenting := {
160 reserved := ?,
161 p_s := ?,
162 more := ?,
163 pr := ?
164 },
165 credit := ?
166 }
167}
168
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100169template PDU_SCCP ts_SCCP_IT(template (present) OCT3 source_lref,
170 template (present) OCT3 dest_lref) := {
171 inacttest := {
172 messageType := it,
173 destLocRef := dest_lref,
174 sourceLocRef := source_lref,
175 protClass := c_class2,
176 /* rfc3868 3.3.11: sequencing and credit are ignored with class2 */
177 sequencingSegmenting := {
178 reserved := '0'B,
179 p_s := '0000000'B,
180 more := '0'B,
181 pr := '0000000'B
182 },
183 credit := '00'O
184 }
185}
186
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100187template PDU_SCCP tr_SCCP_RLSD(template (present) OCT3 source_lref := ?,
188 template (present) OCT3 dest_lref := ?,
189 template (present) SCCP_param_ReleaseCause relcause := ?) := {
190 released := {
191 messageType := rlsd,
192 destLocRef := dest_lref,
193 sourceLocRef := source_lref,
194 releaseCause := relcause,
195 pointer1 := ?,
196 optionalPart := *,
197 eop := *
198 }
199}
200
201template PDU_SCCP ts_SCCP_RLC(OCT3 source_lref, OCT3 dest_lref) := {
202 relcomp := {
203 messageType := rlc,
204 destLocRef := dest_lref,
205 sourceLocRef := source_lref
206 }
207}
208
209template PDU_SCCP tr_SCCP_RLC(template (present) OCT3 source_lref := ?,
210 template (present) OCT3 dest_lref := ?) := {
211 relcomp := {
212 messageType := rlc,
213 destLocRef := dest_lref,
214 sourceLocRef := source_lref
215 }
216}
217
Harald Welte24f921b2021-02-10 19:37:45 +0100218private function f_pc_int2bit(template (present) integer pc)
219return template SCMG_param_AffectedPointCode {
220 if (istemplatekind(pc, "?")) {
221 return ?;
222 } else {
223 return int2bit(valueof(pc), 16);
224 }
225}
226
227template (value) PDU_SCMG_message ts_SCMG_SSA(template (value) integer ssn,
228 integer pc,
229 template (value) BIT2 smi := '00'B) := {
230 messageType := sSAallowed,
231 affectedSSN := ssn,
232 affectedPC := int2bit(valueof(pc), 16),
233 smi := {
234 smi := smi,
235 reserved := '000000'B
236 },
237 congLevel := omit
238}
239template (present) PDU_SCMG_message tr_SCMG_SSA(template (present) integer ssn := ?,
240 template (present) integer pc := ?,
241 template (present) BIT2 smi := ?) := {
242 messageType := sSAallowed,
243 affectedSSN := ssn,
244 affectedPC := f_pc_int2bit(pc),
245 smi := {
246 smi := smi,
247 reserved := '000000'B
248 },
249 congLevel := omit
250}
251
252template (value) PDU_SCMG_message ts_SCMG_SSP(template (value) integer ssn,
253 integer pc,
254 template (value) BIT2 smi := '00'B) := {
255 messageType := sSPprohib,
256 affectedSSN := ssn,
257 affectedPC := int2bit(valueof(pc), 16),
258 smi := {
259 smi := smi,
260 reserved := '000000'B
261 },
262 congLevel := omit
263}
264template (present) PDU_SCMG_message tr_SCMG_SSP(template (present) integer ssn := ?,
265 template (present) integer pc := ?,
266 template (present) BIT2 smi := ?) := {
267 messageType := sSPprohib,
268 affectedSSN := ssn,
269 affectedPC := f_pc_int2bit(pc),
270 smi := {
271 smi := smi,
272 reserved := '000000'B
273 },
274 congLevel := omit
275}
276
277template (value) PDU_SCMG_message ts_SCMG_SST(template (value) integer ssn,
278 integer pc,
279 template (value) BIT2 smi := '00'B) := {
280 messageType := sSTstaTest,
281 affectedSSN := ssn,
282 affectedPC := int2bit(valueof(pc), 16),
283 smi := {
284 smi := smi,
285 reserved := '000000'B
286 },
287 congLevel := omit
288}
289template (present) PDU_SCMG_message tr_SCMG_SST(template (present) integer ssn := ?,
290 template (present) integer pc := ?,
291 template (present) BIT2 smi := ?) := {
292 messageType := sSTstaTest,
293 affectedSSN := ssn,
294 affectedPC := f_pc_int2bit(pc),
295 smi := {
296 smi := smi,
297 reserved := '000000'B
298 },
299 congLevel := omit
300}
301
302
Harald Welte0db44132019-10-17 11:09:05 +0200303
Stefan Sperlingc307e682018-06-14 15:15:46 +0200304}