Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 1 | module BSSAP_CodecPort { |
| 2 | |
Harald Welte | 35bb716 | 2018-01-03 21:07:52 +0100 | [diff] [blame] | 3 | /* Simple BSSAP Codec Port, translating between raw SCCP primitives with |
| 4 | * octetstring payload towards the SCCP provider, and BSSAP-SCCP primitives |
| 5 | * which carry the decoded BSSAP data types as payload. |
| 6 | * |
| 7 | * (C) 2017 by Harald Welte <laforge@gnumonks.org> |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * Released under the terms of GNU General Public License, Version 2 or |
| 11 | * (at your option) any later version. |
| 12 | */ |
| 13 | |
Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 14 | import from General_Types all; |
| 15 | import from Osmocom_Types all; |
| 16 | |
| 17 | import from SCCPasp_Types all; |
| 18 | import from SCCP_Types all; |
| 19 | |
| 20 | import from BSSAP_Types all; |
| 21 | |
| 22 | type record BSSAP_N_CONNECT_req |
| 23 | { |
| 24 | SCCP_PAR_Address calledAddress, |
| 25 | SCCP_PAR_Address callingAddress optional, |
| 26 | SCCP_PAR_Expedited_Data_Sel expeditedDataSel optional, |
| 27 | SCCP_PAR_Quality_Of_Service qualityOfService optional, |
| 28 | PDU_BSSAP userData optional, |
| 29 | SCCP_PAR_Connection_Id connectionId optional, |
| 30 | SCCP_PAR_Importance importance optional |
| 31 | } |
| 32 | |
| 33 | template BSSAP_N_CONNECT_req ts_BSSAP_CONNECT_req(SCCP_PAR_Address called, |
| 34 | SCCP_PAR_Address calling, |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 35 | SCCP_PAR_Connection_Id conn_id, |
| 36 | template PDU_BSSAP bssap := omit) := { |
Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 37 | calledAddress := called, |
| 38 | callingAddress := calling, |
| 39 | expeditedDataSel := omit, |
| 40 | qualityOfService := omit, |
| 41 | userData := bssap, |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 42 | connectionId := conn_id, |
Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 43 | importance := omit |
| 44 | } |
| 45 | |
| 46 | type record BSSAP_N_CONNECT_ind |
| 47 | { |
| 48 | SCCP_PAR_Address calledAddress, |
| 49 | SCCP_PAR_Address callingAddress optional, |
| 50 | SCCP_PAR_Quality_Of_Service qualityOfService optional, |
| 51 | PDU_BSSAP userData optional, |
| 52 | SCCP_PAR_Connection_Id connectionId optional, |
| 53 | SCCP_PAR_Importance importance optional |
| 54 | } |
| 55 | |
| 56 | template BSSAP_N_CONNECT_ind tr_BSSAP_CONNECT_ind(template SCCP_PAR_Address called, |
| 57 | template SCCP_PAR_Address calling, |
| 58 | template PDU_BSSAP payload := *) := { |
| 59 | calledAddress := called, |
| 60 | callingAddress := calling, |
| 61 | qualityOfService := *, |
| 62 | userData := payload, |
| 63 | connectionId := *, |
| 64 | importance := * |
| 65 | } |
| 66 | |
| 67 | type record BSSAP_N_CONNECT_res |
| 68 | { |
| 69 | SCCP_PAR_Address respondingAddress optional, |
| 70 | SCCP_PAR_Expedited_Data_Sel expeditedDataSel optional, |
| 71 | SCCP_PAR_Quality_Of_Service qualityOfService optional, |
| 72 | PDU_BSSAP userData optional, |
| 73 | SCCP_PAR_Connection_Id connectionId optional, |
| 74 | SCCP_PAR_Importance importance optional |
| 75 | } |
| 76 | |
| 77 | template BSSAP_N_CONNECT_res ts_BSSAP_CONNECT_res(SCCP_PAR_Connection_Id conn_id, |
| 78 | template PDU_BSSAP bssap := omit) := { |
| 79 | respondingAddress := omit, |
| 80 | expeditedDataSel := omit, |
| 81 | qualityOfService := omit, |
| 82 | userData := bssap, |
| 83 | connectionId := conn_id, |
| 84 | importance := omit |
| 85 | } |
| 86 | |
| 87 | type record BSSAP_N_CONNECT_cfm |
| 88 | { |
| 89 | SCCP_PAR_Address respondingAddress optional, |
| 90 | SCCP_PAR_Quality_Of_Service qualityOfService optional, |
| 91 | PDU_BSSAP userData optional, |
| 92 | SCCP_PAR_Connection_Id connectionId optional, |
| 93 | SCCP_PAR_Importance importance optional |
| 94 | } |
| 95 | |
| 96 | template BSSAP_N_CONNECT_cfm tr_BSSAP_CONNECT_cfm(template SCCP_PAR_Connection_Id conn_id, |
| 97 | template PDU_BSSAP bssap := *) := { |
| 98 | respondingAddress := *, |
| 99 | qualityOfService := *, |
| 100 | userData := bssap, |
| 101 | connectionId := conn_id, |
| 102 | importance := * |
| 103 | } |
| 104 | |
| 105 | type record BSSAP_N_DATA_req |
| 106 | { |
| 107 | PDU_BSSAP userData , |
| 108 | SCCP_PAR_Connection_Id connectionId optional , |
| 109 | SCCP_PAR_Importance importance optional |
| 110 | } |
| 111 | |
| 112 | template BSSAP_N_DATA_req ts_BSSAP_DATA_req(SCCP_PAR_Connection_Id conn_id, |
| 113 | template PDU_BSSAP bssap) := { |
| 114 | userData := bssap, |
| 115 | connectionId := conn_id, |
| 116 | importance := omit |
| 117 | } |
| 118 | |
| 119 | |
| 120 | type record BSSAP_N_DATA_ind |
| 121 | { |
| 122 | PDU_BSSAP userData , |
| 123 | SCCP_PAR_Connection_Id connectionId optional , |
| 124 | SCCP_PAR_Importance importance optional |
| 125 | } |
| 126 | |
| 127 | template BSSAP_N_DATA_ind tr_BSSAP_DATA_ind(SCCP_PAR_Connection_Id conn_id, |
| 128 | template PDU_BSSAP bssap := *) := { |
| 129 | userData := bssap, |
| 130 | connectionId := conn_id, |
| 131 | importance := * |
| 132 | } |
| 133 | |
| 134 | |
| 135 | type record BSSAP_N_DISCONNECT_req |
| 136 | { |
| 137 | SCCP_PAR_Address respondingAddress optional, |
| 138 | SCCP_PAR_Reason reason , |
| 139 | PDU_BSSAP userData optional , |
| 140 | SCCP_PAR_Connection_Id connectionId optional , |
| 141 | SCCP_PAR_Importance importance optional |
| 142 | } |
| 143 | |
| 144 | template BSSAP_N_DISCONNECT_req ts_BSSAP_DISC_req(SCCP_PAR_Connection_Id conn_id, |
| 145 | template SCCP_PAR_Reason reason, |
| 146 | template PDU_BSSAP bssap := omit) := { |
| 147 | respondingAddress := omit, |
| 148 | reason := reason, |
| 149 | userData := bssap, |
| 150 | connectionId := conn_id, |
| 151 | importance := omit |
| 152 | } |
| 153 | |
| 154 | |
| 155 | type record BSSAP_N_DISCONNECT_ind |
| 156 | { |
| 157 | SCCP_PAR_Originator originator , |
| 158 | SCCP_PAR_Address respondingAddress optional , |
| 159 | SCCP_PAR_Reason reason , |
| 160 | PDU_BSSAP userData optional , |
| 161 | SCCP_PAR_Connection_Id connectionId optional , |
| 162 | SCCP_PAR_Importance importance optional |
| 163 | } |
| 164 | |
| 165 | template BSSAP_N_DISCONNECT_ind tr_BSSAP_DISC_ind(template SCCP_PAR_Connection_Id conn_id, |
| 166 | template SCCP_PAR_Originator originator, |
| 167 | template SCCP_PAR_Reason reason, |
| 168 | template PDU_BSSAP bssap := *) := { |
| 169 | originator := originator, |
Harald Welte | 346658d | 2017-12-10 14:10:25 +0100 | [diff] [blame] | 170 | respondingAddress:= *, |
Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 171 | reason := reason, |
| 172 | userData := bssap, |
| 173 | connectionId := conn_id, |
| 174 | importance := * |
| 175 | } |
| 176 | |
| 177 | type record BSSAP_N_UNITDATA_req |
| 178 | { |
| 179 | SCCP_PAR_Address calledAddress , |
| 180 | SCCP_PAR_Address callingAddress , |
| 181 | SCCP_PAR_Sequence_Control sequenceControl optional , |
| 182 | SCCP_PAR_Return_Option returnOption optional , |
| 183 | PDU_BSSAP userData , |
| 184 | SCCP_PAR_Importance importance optional |
| 185 | } |
| 186 | |
| 187 | template BSSAP_N_UNITDATA_req ts_BSSAP_UNITDATA_req(SCCP_PAR_Address called, SCCP_PAR_Address calling, template PDU_BSSAP payload) := { |
| 188 | calledAddress := called, |
| 189 | callingAddress := calling, |
| 190 | sequenceControl := omit, |
| 191 | returnOption := omit, |
| 192 | userData := payload, |
| 193 | importance := omit |
| 194 | } |
| 195 | |
| 196 | type record BSSAP_N_UNITDATA_ind |
| 197 | { |
| 198 | SCCP_PAR_Address calledAddress , |
| 199 | SCCP_PAR_Address callingAddress , |
| 200 | SCCP_PAR_Sequence_Control sequenceControl optional , |
| 201 | SCCP_PAR_Return_Option returnOption optional , |
| 202 | PDU_BSSAP userData , |
| 203 | SCCP_PAR_Importance importance optional |
| 204 | } |
| 205 | |
| 206 | template BSSAP_N_UNITDATA_ind tr_BSSAP_UNITDATA_ind(template SCCP_PAR_Address called, template SCCP_PAR_Address calling, template PDU_BSSAP payload) := { |
| 207 | calledAddress := called, |
| 208 | callingAddress := calling, |
| 209 | sequenceControl := *, |
| 210 | returnOption := *, |
| 211 | userData := payload, |
| 212 | importance := * |
| 213 | } |
| 214 | |
| 215 | type record BSSAP_N_NOTICE_ind |
| 216 | { |
| 217 | SCCP_PAR_Address calledAddress , |
| 218 | SCCP_PAR_Address callingAddress , |
| 219 | SCCP_PAR_Reason_For_Return reasonForReturn , |
| 220 | PDU_BSSAP userData , |
| 221 | SCCP_PAR_Importance importance optional |
| 222 | } |
| 223 | |
| 224 | |
| 225 | |
| 226 | private function f_dec_ConnectInd(in ASP_SCCP_N_CONNECT_ind pin, out BSSAP_N_CONNECT_ind pout) { |
| 227 | pout.calledAddress := pin.calledAddress; |
| 228 | pout.callingAddress := pin.callingAddress; |
| 229 | pout.qualityOfService := pin.qualityOfService; |
Harald Welte | 510a287 | 2017-12-10 13:48:17 +0100 | [diff] [blame] | 230 | if (ispresent(pin.userData)) { |
| 231 | pout.userData := dec_PDU_BSSAP(pin.userData); |
| 232 | } else { |
| 233 | pout.userData := omit; |
| 234 | } |
Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 235 | pout.connectionId := pin.connectionId; |
| 236 | pout.importance := pin.importance; |
| 237 | //port.setstate(0); |
| 238 | } with {extension "prototype(fast)" } |
| 239 | |
| 240 | private function f_dec_ConnectCfm(in ASP_SCCP_N_CONNECT_cfm pin, out BSSAP_N_CONNECT_cfm pout) { |
| 241 | pout.respondingAddress := pin.respondingAddress; |
| 242 | pout.qualityOfService := pin.qualityOfService; |
Harald Welte | 510a287 | 2017-12-10 13:48:17 +0100 | [diff] [blame] | 243 | if (ispresent(pin.userData)) { |
| 244 | pout.userData := dec_PDU_BSSAP(pin.userData); |
| 245 | } else { |
| 246 | pout.userData := omit; |
| 247 | } |
Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 248 | pout.connectionId := pin.connectionId; |
| 249 | pout.importance := pin.importance; |
| 250 | //port.setstate(0); |
| 251 | } with {extension "prototype(fast)" } |
| 252 | |
| 253 | private function f_dec_DataInd(in ASP_SCCP_N_DATA_ind pin, out BSSAP_N_DATA_ind pout) { |
| 254 | pout.userData := dec_PDU_BSSAP(pin.userData); |
| 255 | pout.connectionId := pin.connectionId; |
| 256 | pout.importance := pin.importance; |
| 257 | //port.setstate(0); |
| 258 | } with {extension "prototype(fast)" } |
| 259 | |
| 260 | private function f_dec_DisconnectInd(in ASP_SCCP_N_DISCONNECT_ind pin, out BSSAP_N_DISCONNECT_ind pout) { |
| 261 | pout.originator := pin.originator; |
| 262 | pout.respondingAddress := pin.respondingAddress; |
| 263 | pout.reason := pin.reason; |
Harald Welte | 510a287 | 2017-12-10 13:48:17 +0100 | [diff] [blame] | 264 | if (ispresent(pin.userData)) { |
| 265 | pout.userData := dec_PDU_BSSAP(pin.userData); |
| 266 | } else { |
| 267 | pout.userData := omit; |
| 268 | } |
Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 269 | pout.connectionId := pin.connectionId; |
| 270 | pout.importance := pin.importance; |
| 271 | //port.setstate(0); |
| 272 | } with {extension "prototype(fast)" } |
| 273 | |
| 274 | private function f_dec_UnitdataInd(in ASP_SCCP_N_UNITDATA_ind pin, out BSSAP_N_UNITDATA_ind pout) { |
| 275 | pout.calledAddress := pin.calledAddress; |
| 276 | pout.callingAddress := pin.callingAddress; |
| 277 | pout.sequenceControl := pin.sequenceControl; |
| 278 | pout.returnOption := pin.returnOption; |
| 279 | pout.userData := dec_PDU_BSSAP(pin.userData); |
| 280 | pout.importance := pin.importance; |
| 281 | //port.setstate(0); |
| 282 | } with {extension "prototype(fast)" } |
| 283 | |
| 284 | private function f_dec_NoticeInd(in ASP_SCCP_N_NOTICE_ind pin, out BSSAP_N_NOTICE_ind pout) { |
| 285 | pout.calledAddress := pin.calledAddress; |
| 286 | pout.callingAddress := pin.callingAddress; |
| 287 | pout.reasonForReturn := pin.reasonForReturn; |
| 288 | pout.userData := dec_PDU_BSSAP(pin.userData); |
| 289 | pout.importance := pin.importance; |
| 290 | //port.setstate(0); |
| 291 | } with {extension "prototype(fast)" } |
| 292 | |
| 293 | |
| 294 | |
| 295 | private function f_enc_ConnectReq(in BSSAP_N_CONNECT_req pin, out ASP_SCCP_N_CONNECT_req pout) { |
| 296 | pout.calledAddress := pin.calledAddress; |
| 297 | pout.callingAddress := pin.callingAddress; |
| 298 | pout.expeditedDataSel := pin.expeditedDataSel; |
| 299 | pout.qualityOfService := pin.qualityOfService; |
Harald Welte | 510a287 | 2017-12-10 13:48:17 +0100 | [diff] [blame] | 300 | if (ispresent(pin.userData)) { |
| 301 | pout.userData := enc_PDU_BSSAP(pin.userData); |
| 302 | } else { |
| 303 | pout.userData := omit; |
| 304 | } |
Harald Welte | 36975c8 | 2017-12-09 21:39:57 +0100 | [diff] [blame] | 305 | pout.connectionId := pin.connectionId; |
| 306 | pout.importance := pin.importance; |
| 307 | //port.setstate(0); |
| 308 | } with {extension "prototype(fast)" } |
| 309 | |
| 310 | private function f_enc_ConnectRes(in BSSAP_N_CONNECT_res pin, out ASP_SCCP_N_CONNECT_res pout) { |
| 311 | pout.respondingAddress := pin.respondingAddress; |
| 312 | pout.expeditedDataSel := pin.expeditedDataSel; |
| 313 | pout.qualityOfService := pin.qualityOfService; |
| 314 | if (ispresent(pin.userData)) { |
| 315 | pout.userData := enc_PDU_BSSAP(pin.userData); |
| 316 | } else { |
| 317 | pout.userData := omit; |
| 318 | } |
| 319 | pout.connectionId := pin.connectionId; |
| 320 | pout.importance := pin.importance; |
| 321 | //port.setstate(0); |
| 322 | } with {extension "prototype(fast)" } |
| 323 | |
| 324 | private function f_enc_DataReq(in BSSAP_N_DATA_req pin, out ASP_SCCP_N_DATA_req pout) { |
| 325 | pout.userData := enc_PDU_BSSAP(pin.userData); |
| 326 | pout.connectionId := pin.connectionId; |
| 327 | pout.importance := pin.importance; |
| 328 | //port.setstate(0); |
| 329 | } with {extension "prototype(fast)" } |
| 330 | |
| 331 | private function f_enc_DisconnectReq(in BSSAP_N_DISCONNECT_req pin, out ASP_SCCP_N_DISCONNECT_req pout) { |
| 332 | pout.respondingAddress := pin.respondingAddress; |
| 333 | pout.reason := pin.reason; |
| 334 | if (ispresent(pin.userData)) { |
| 335 | pout.userData := enc_PDU_BSSAP(pin.userData); |
| 336 | } else { |
| 337 | pout.userData := omit; |
| 338 | } |
| 339 | pout.connectionId := pin.connectionId; |
| 340 | pout.importance := pin.importance; |
| 341 | //port.setstate(0); |
| 342 | } with {extension "prototype(fast)" } |
| 343 | |
| 344 | private function f_enc_UnitdataReq(in BSSAP_N_UNITDATA_req pin, out ASP_SCCP_N_UNITDATA_req pout) { |
| 345 | pout.calledAddress := pin.calledAddress; |
| 346 | pout.callingAddress := pin.callingAddress; |
| 347 | pout.userData := enc_PDU_BSSAP(pin.userData); |
| 348 | pout.sequenceControl := pin.sequenceControl; |
| 349 | pout.returnOption := pin.returnOption; |
| 350 | pout.importance := pin.importance; |
| 351 | //port.setstate(0); |
| 352 | } with {extension "prototype(fast)" } |
| 353 | |
| 354 | |
| 355 | /* |
| 356 | type port BSSAP_CODEC_PT message map to SCCPasp_PT { |
| 357 | out BSSAP_N_CONNECT_req to ASP_SCCP_N_CONNECT_req with f_enc_ConnectReq(), |
| 358 | BSSAP_N_CONNECT_res to ASP_SCCP_N_CONNECT_res with f_enc_ConnectRes(), |
| 359 | BSSAP_N_DATA_req to ASP_SCCP_N_DATA_req with f_enc_DataReq(), |
| 360 | BSSAP_N_DISCONNECT_req to ASP_SCCP_N_DISCONNECT_req with f_enc_DisconnectReq(), |
| 361 | BSSAP_N_UNITDATA_req to ASP_SCCP_N_UNITDATA_req with f_enc_UnitdataReq(), |
| 362 | ASP_SCCP_N_RESET_req, ASP_SCCP_N_RESET_resp; |
| 363 | |
| 364 | in BSSAP_N_CONNECT_ind from ASP_SCCP_N_CONNECT_ind with f_dec_ConnectInd(), |
| 365 | BSSAP_N_CONNECT_cfm from ASP_SCCP_N_CONNECT_cfm with f_dec_ConnectCfm(), |
| 366 | BSSAP_N_DATA_ind from ASP_SCCP_N_DATA_ind with f_dec_DataInd(), |
| 367 | BSSAP_N_DISCONNECT_ind from ASP_SCCP_N_DISCONNECT_ind with f_dec_DisconnectInd(), |
| 368 | BSSAP_N_UNITDATA_ind from ASP_SCCP_N_UNITDATA_ind with f_dec_UnitdataInd(), |
| 369 | BSSAP_N_NOTICE_ind from ASP_SCCP_N_NOTICE_ind with f_dec_NoticeInd(), |
| 370 | ASP_SCCP_N_STATE_ind, ASP_SCCP_N_RESET_ind, ASP_SCCP_N_RESET_cfm; |
| 371 | } with {extension "internal"} |
| 372 | */ |
| 373 | |
| 374 | type port BSSAP_CODEC_PT message { |
| 375 | out BSSAP_N_CONNECT_req, |
| 376 | BSSAP_N_CONNECT_res, |
| 377 | BSSAP_N_DATA_req, |
| 378 | BSSAP_N_DISCONNECT_req, |
| 379 | BSSAP_N_UNITDATA_req, |
| 380 | ASP_SCCP_N_RESET_req; |
| 381 | in BSSAP_N_CONNECT_ind, |
| 382 | BSSAP_N_CONNECT_cfm, |
| 383 | BSSAP_N_DATA_ind, |
| 384 | BSSAP_N_DISCONNECT_ind, |
| 385 | BSSAP_N_UNITDATA_ind, |
| 386 | BSSAP_N_NOTICE_ind, |
| 387 | ASP_SCCP_N_RESET_ind, |
| 388 | ASP_SCCP_N_RESET_cfm, |
| 389 | ASP_SCCP_N_STATE_ind; |
| 390 | } with { extension "internal user SCCPasp_PT |
| 391 | out(BSSAP_N_CONNECT_req -> ASP_SCCP_N_CONNECT_req: function(f_enc_ConnectReq); |
| 392 | BSSAP_N_CONNECT_res -> ASP_SCCP_N_CONNECT_res: function(f_enc_ConnectRes); |
| 393 | BSSAP_N_DATA_req -> ASP_SCCP_N_DATA_req: function(f_enc_DataReq); |
| 394 | BSSAP_N_DISCONNECT_req -> ASP_SCCP_N_DISCONNECT_req: function(f_enc_DisconnectReq); |
| 395 | BSSAP_N_UNITDATA_req -> ASP_SCCP_N_UNITDATA_req: function(f_enc_UnitdataReq); |
| 396 | ASP_SCCP_N_RESET_req -> ASP_SCCP_N_RESET_req: simple) |
| 397 | in(ASP_SCCP_N_CONNECT_ind -> BSSAP_N_CONNECT_ind: function(f_dec_ConnectInd); |
| 398 | ASP_SCCP_N_CONNECT_cfm -> BSSAP_N_CONNECT_cfm: function(f_dec_ConnectCfm); |
| 399 | ASP_SCCP_N_DATA_ind -> BSSAP_N_DATA_ind: function(f_dec_DataInd); |
| 400 | ASP_SCCP_N_DISCONNECT_ind -> BSSAP_N_DISCONNECT_ind: function(f_dec_DisconnectInd); |
| 401 | ASP_SCCP_N_UNITDATA_ind -> BSSAP_N_UNITDATA_ind: function(f_dec_UnitdataInd); |
| 402 | ASP_SCCP_N_NOTICE_ind -> BSSAP_N_NOTICE_ind: function(f_dec_NoticeInd); |
| 403 | ASP_SCCP_N_RESET_ind -> ASP_SCCP_N_RESET_ind: simple; |
| 404 | ASP_SCCP_N_RESET_cfm -> ASP_SCCP_N_RESET_cfm: simple; |
| 405 | ASP_SCCP_N_STATE_ind -> ASP_SCCP_N_STATE_ind: simple)" |
| 406 | } |
| 407 | |
| 408 | |
| 409 | } |