Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 1 | /* (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 Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 6 | * |
| 7 | * SPDX-License-Identifier: GPL-2.0-or-later |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | module SCCP_Templates { |
| 11 | |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 12 | import from General_Types all; |
| 13 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 14 | import from SCCP_Types all; |
| 15 | import from SCCPasp_Types all; |
| 16 | import from SCCP_Emulation all; |
| 17 | |
Harald Welte | aed9f94 | 2021-05-13 21:54:58 +0200 | [diff] [blame] | 18 | /* construct a SCCP_PAR_Address with just SSN and no PC or GT */ |
| 19 | template (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 Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 31 | /* construct a SCCP_PAR_Address with just PC + SSN and no GT */ |
| 32 | template (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 */ |
| 46 | template (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 Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 64 | /* construct a SCCP_PAR_Address with PC + SSN and GT */ |
| 65 | template (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 Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 84 | /* connection oriented SCCP */ |
| 85 | const SCCP_param_ProtocolClass c_class2 := { class:='0010'B, messageHandling:='0000'B };//class 2 |
| 86 | |
| 87 | function ts_SCCP_CR(OCT3 source_lref, SCCP_PAR_Address calling, SCCP_PAR_Address called) |
| 88 | return 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 | |
| 116 | template (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 Welte | 2eb30d4 | 2021-05-13 21:54:26 +0200 | [diff] [blame] | 129 | private function tr_Addr(template SCCP_PAR_Address addr := *) |
| 130 | return template (present) SCCP_param_CPartyAddressEnc { |
| 131 | if (istemplatekind(addr, "?")) { |
| 132 | return ?; |
| 133 | } else { |
| 134 | return ConvertASPAddressToEncodedAddress_itu(valueof(addr)); |
| 135 | } |
| 136 | } |
| 137 | |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 138 | template (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 Welte | 2eb30d4 | 2021-05-13 21:54:26 +0200 | [diff] [blame] | 156 | template PDU_SCCP tr_SCCP_UDT(template (present) SCCP_PAR_Address calling, template (present) SCCP_PAR_Address called, |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 157 | 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 Welte | 2eb30d4 | 2021-05-13 21:54:26 +0200 | [diff] [blame] | 165 | calledPAddress := tr_Addr(called), |
| 166 | callingPAddress := tr_Addr(calling), |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 167 | data := { |
Harald Welte | e92cc66 | 2021-02-10 19:37:13 +0100 | [diff] [blame] | 168 | paramLength := ?, |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 169 | data := data |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | template PDU_SCCP tr_SCCP_IT(template (present) OCT3 source_lref := ?, |
| 175 | template (present) OCT3 dest_lref := ?) := { |
| 176 | inacttest := { |
| 177 | messageType := it, |
| 178 | destLocRef := dest_lref, |
| 179 | sourceLocRef := source_lref, |
| 180 | protClass := c_class2, |
| 181 | sequencingSegmenting := { |
| 182 | reserved := ?, |
| 183 | p_s := ?, |
| 184 | more := ?, |
| 185 | pr := ? |
| 186 | }, |
| 187 | credit := ? |
| 188 | } |
| 189 | } |
| 190 | |
Pau Espin Pedrol | e30d543 | 2020-01-21 13:47:32 +0100 | [diff] [blame] | 191 | template PDU_SCCP ts_SCCP_IT(template (present) OCT3 source_lref, |
| 192 | template (present) OCT3 dest_lref) := { |
| 193 | inacttest := { |
| 194 | messageType := it, |
| 195 | destLocRef := dest_lref, |
| 196 | sourceLocRef := source_lref, |
| 197 | protClass := c_class2, |
| 198 | /* rfc3868 3.3.11: sequencing and credit are ignored with class2 */ |
| 199 | sequencingSegmenting := { |
| 200 | reserved := '0'B, |
| 201 | p_s := '0000000'B, |
| 202 | more := '0'B, |
| 203 | pr := '0000000'B |
| 204 | }, |
| 205 | credit := '00'O |
| 206 | } |
| 207 | } |
| 208 | |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 209 | template PDU_SCCP tr_SCCP_RLSD(template (present) OCT3 source_lref := ?, |
| 210 | template (present) OCT3 dest_lref := ?, |
| 211 | template (present) SCCP_param_ReleaseCause relcause := ?) := { |
| 212 | released := { |
| 213 | messageType := rlsd, |
| 214 | destLocRef := dest_lref, |
| 215 | sourceLocRef := source_lref, |
| 216 | releaseCause := relcause, |
| 217 | pointer1 := ?, |
| 218 | optionalPart := *, |
| 219 | eop := * |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | template PDU_SCCP ts_SCCP_RLC(OCT3 source_lref, OCT3 dest_lref) := { |
| 224 | relcomp := { |
| 225 | messageType := rlc, |
| 226 | destLocRef := dest_lref, |
| 227 | sourceLocRef := source_lref |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | template PDU_SCCP tr_SCCP_RLC(template (present) OCT3 source_lref := ?, |
| 232 | template (present) OCT3 dest_lref := ?) := { |
| 233 | relcomp := { |
| 234 | messageType := rlc, |
| 235 | destLocRef := dest_lref, |
| 236 | sourceLocRef := source_lref |
| 237 | } |
| 238 | } |
| 239 | |
Harald Welte | 24f921b | 2021-02-10 19:37:45 +0100 | [diff] [blame] | 240 | private function f_pc_int2bit(template (present) integer pc) |
| 241 | return template SCMG_param_AffectedPointCode { |
| 242 | if (istemplatekind(pc, "?")) { |
| 243 | return ?; |
| 244 | } else { |
| 245 | return int2bit(valueof(pc), 16); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | template (value) PDU_SCMG_message ts_SCMG_SSA(template (value) integer ssn, |
| 250 | integer pc, |
| 251 | template (value) BIT2 smi := '00'B) := { |
| 252 | messageType := sSAallowed, |
| 253 | affectedSSN := ssn, |
| 254 | affectedPC := int2bit(valueof(pc), 16), |
| 255 | smi := { |
| 256 | smi := smi, |
| 257 | reserved := '000000'B |
| 258 | }, |
| 259 | congLevel := omit |
| 260 | } |
| 261 | template (present) PDU_SCMG_message tr_SCMG_SSA(template (present) integer ssn := ?, |
| 262 | template (present) integer pc := ?, |
| 263 | template (present) BIT2 smi := ?) := { |
| 264 | messageType := sSAallowed, |
| 265 | affectedSSN := ssn, |
| 266 | affectedPC := f_pc_int2bit(pc), |
| 267 | smi := { |
| 268 | smi := smi, |
| 269 | reserved := '000000'B |
| 270 | }, |
| 271 | congLevel := omit |
| 272 | } |
| 273 | |
| 274 | template (value) PDU_SCMG_message ts_SCMG_SSP(template (value) integer ssn, |
| 275 | integer pc, |
| 276 | template (value) BIT2 smi := '00'B) := { |
| 277 | messageType := sSPprohib, |
| 278 | affectedSSN := ssn, |
| 279 | affectedPC := int2bit(valueof(pc), 16), |
| 280 | smi := { |
| 281 | smi := smi, |
| 282 | reserved := '000000'B |
| 283 | }, |
| 284 | congLevel := omit |
| 285 | } |
| 286 | template (present) PDU_SCMG_message tr_SCMG_SSP(template (present) integer ssn := ?, |
| 287 | template (present) integer pc := ?, |
| 288 | template (present) BIT2 smi := ?) := { |
| 289 | messageType := sSPprohib, |
| 290 | affectedSSN := ssn, |
| 291 | affectedPC := f_pc_int2bit(pc), |
| 292 | smi := { |
| 293 | smi := smi, |
| 294 | reserved := '000000'B |
| 295 | }, |
| 296 | congLevel := omit |
| 297 | } |
| 298 | |
| 299 | template (value) PDU_SCMG_message ts_SCMG_SST(template (value) integer ssn, |
| 300 | integer pc, |
| 301 | template (value) BIT2 smi := '00'B) := { |
| 302 | messageType := sSTstaTest, |
| 303 | affectedSSN := ssn, |
| 304 | affectedPC := int2bit(valueof(pc), 16), |
| 305 | smi := { |
| 306 | smi := smi, |
| 307 | reserved := '000000'B |
| 308 | }, |
| 309 | congLevel := omit |
| 310 | } |
| 311 | template (present) PDU_SCMG_message tr_SCMG_SST(template (present) integer ssn := ?, |
| 312 | template (present) integer pc := ?, |
| 313 | template (present) BIT2 smi := ?) := { |
| 314 | messageType := sSTstaTest, |
| 315 | affectedSSN := ssn, |
| 316 | affectedPC := f_pc_int2bit(pc), |
| 317 | smi := { |
| 318 | smi := smi, |
| 319 | reserved := '000000'B |
| 320 | }, |
| 321 | congLevel := omit |
| 322 | } |
| 323 | |
| 324 | |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 325 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 326 | } |