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 | |
| 18 | /* construct a SCCP_PAR_Address with just PC + SSN and no GT */ |
| 19 | template (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 */ |
| 33 | template (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 Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 51 | /* construct a SCCP_PAR_Address with PC + SSN and GT */ |
| 52 | template (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 Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 71 | /* connection oriented SCCP */ |
| 72 | const SCCP_param_ProtocolClass c_class2 := { class:='0010'B, messageHandling:='0000'B };//class 2 |
| 73 | |
| 74 | function ts_SCCP_CR(OCT3 source_lref, SCCP_PAR_Address calling, SCCP_PAR_Address called) |
| 75 | return 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 | |
| 103 | template (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 | |
| 116 | template (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 | |
| 134 | template 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 | |
| 152 | template 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 Pedrol | e30d543 | 2020-01-21 13:47:32 +0100 | [diff] [blame] | 169 | template 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 Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 187 | template 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 | |
| 201 | template 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 | |
| 209 | template 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 Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 218 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 219 | } |