blob: b3e3392fb4991141e9744eaa69d27f90b6ddf9ff [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 := {
146 paramLength := lengthof(data),
147 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
169template PDU_SCCP tr_SCCP_RLSD(template (present) OCT3 source_lref := ?,
170 template (present) OCT3 dest_lref := ?,
171 template (present) SCCP_param_ReleaseCause relcause := ?) := {
172 released := {
173 messageType := rlsd,
174 destLocRef := dest_lref,
175 sourceLocRef := source_lref,
176 releaseCause := relcause,
177 pointer1 := ?,
178 optionalPart := *,
179 eop := *
180 }
181}
182
183template PDU_SCCP ts_SCCP_RLC(OCT3 source_lref, OCT3 dest_lref) := {
184 relcomp := {
185 messageType := rlc,
186 destLocRef := dest_lref,
187 sourceLocRef := source_lref
188 }
189}
190
191template PDU_SCCP tr_SCCP_RLC(template (present) OCT3 source_lref := ?,
192 template (present) OCT3 dest_lref := ?) := {
193 relcomp := {
194 messageType := rlc,
195 destLocRef := dest_lref,
196 sourceLocRef := source_lref
197 }
198}
199
Harald Welte0db44132019-10-17 11:09:05 +0200200
Stefan Sperlingc307e682018-06-14 15:15:46 +0200201}