Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 1 | module BSSMAP_Emulation { |
| 2 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 3 | import from SCCP_Emulation all; |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 4 | import from SCCPasp_Types all; |
| 5 | import from BSSAP_Types all; |
| 6 | import from BSSMAP_Templates all; |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 7 | import from MGCP_Types all; |
| 8 | import from MGCP_Templates all; |
| 9 | import from IPA_Emulation all; |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 10 | |
| 11 | /* General "base class" component definition, of which specific implementations |
| 12 | * derive themselves by means of the "extends" feature */ |
| 13 | type component BSSAP_ConnHdlr { |
| 14 | /* port towards MSC Emulator core / SCCP connection dispatchar */ |
| 15 | port BSSAP_Conn_PT BSSAP; |
| 16 | } |
| 17 | |
| 18 | /* Auxiliary primitive that can happen on the port between per-connection client and this dispatcher */ |
| 19 | type enumerated BSSAP_Conn_Prim { |
| 20 | /* SCCP tell us that connection was released */ |
| 21 | MSC_CONN_PRIM_DISC_IND, |
| 22 | /* we tell SCCP to release connection */ |
| 23 | MSC_CONN_PRIM_DISC_REQ |
| 24 | } |
| 25 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 26 | type record BSSAP_Conn_Req { |
| 27 | SCCP_PAR_Address addr_peer, |
| 28 | SCCP_PAR_Address addr_own, |
| 29 | PDU_BSSAP bssap |
| 30 | } |
| 31 | |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 32 | /* port between individual per-connection components and this dispatcher */ |
| 33 | type port BSSAP_Conn_PT message { |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 34 | inout PDU_BSSAP, BSSAP_Conn_Prim, BSSAP_Conn_Req, MgcpCommand, MgcpResponse; |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 35 | } with { extension "internal" }; |
| 36 | |
| 37 | |
| 38 | /* represents a single BSSAP connection over SCCP */ |
| 39 | type record ConnectionData { |
| 40 | /* reference to the instance of the per-connection component */ |
| 41 | BSSAP_ConnHdlr comp_ref, |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 42 | integer sccp_conn_id, |
| 43 | /* most recent MGCP transaction ID (Used on MSC side) */ |
| 44 | MgcpTransId mgcp_trans_id optional, |
| 45 | /* CIC that has been used for voice of this channel (BSC side) */ |
| 46 | integer cic optional |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | type component BSSMAP_Emulation_CT { |
| 50 | /* SCCP port on the bottom side, using ASP primitives */ |
| 51 | port SCCPasp_PT SCCP; |
| 52 | /* BSSAP port to the per-connection clients */ |
| 53 | port BSSAP_Conn_PT CLIENT; |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 54 | /* MGCP port */ |
| 55 | port IPA_MGCP_PT MGCP; |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 56 | |
| 57 | /* use 16 as this is also the number of SCCP connections that SCCP_Emulation can handle */ |
| 58 | var ConnectionData ConnectionTable[16]; |
| 59 | }; |
| 60 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 61 | private function f_conn_id_known(integer sccp_conn_id) |
| 62 | runs on BSSMAP_Emulation_CT return boolean { |
| 63 | var integer i; |
| 64 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 65 | if (ConnectionTable[i].sccp_conn_id == sccp_conn_id){ |
| 66 | return true; |
| 67 | } |
| 68 | } |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | private function f_comp_known(BSSAP_ConnHdlr client) |
| 73 | runs on BSSMAP_Emulation_CT return boolean { |
| 74 | var integer i; |
| 75 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 76 | if (ConnectionTable[i].comp_ref == client) { |
| 77 | return true; |
| 78 | } |
| 79 | } |
| 80 | return false; |
| 81 | } |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 82 | |
| 83 | /* resolve component reference by connection ID */ |
| 84 | private function f_comp_by_conn_id(integer sccp_conn_id) |
| 85 | runs on BSSMAP_Emulation_CT return BSSAP_ConnHdlr { |
| 86 | var integer i; |
| 87 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 88 | if (ConnectionTable[i].sccp_conn_id == sccp_conn_id) { |
| 89 | return ConnectionTable[i].comp_ref; |
| 90 | } |
| 91 | } |
| 92 | log("BSSMAP Connection table not found by SCCP Connection ID ", sccp_conn_id); |
| 93 | self.stop; |
| 94 | } |
| 95 | |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 96 | /* resolve component reference by CIC */ |
| 97 | private function f_comp_by_mgcp_tid(MgcpTransId tid) |
| 98 | runs on BSSMAP_Emulation_CT return BSSAP_ConnHdlr { |
| 99 | var integer i; |
| 100 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 101 | if (ConnectionTable[i].mgcp_trans_id == tid) { |
| 102 | return ConnectionTable[i].comp_ref; |
| 103 | } |
| 104 | } |
| 105 | log("BSSMAP Connection table not found by MGCP Transaction ID ", tid); |
| 106 | self.stop; |
| 107 | } |
| 108 | |
| 109 | private function f_comp_store_mgcp_tid(BSSAP_ConnHdlr client, MgcpTransId tid) |
| 110 | runs on BSSMAP_Emulation_CT { |
| 111 | var integer i; |
| 112 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 113 | if (ConnectionTable[i].comp_ref == client) { |
| 114 | ConnectionTable[i].mgcp_trans_id := tid; |
| 115 | return; |
| 116 | } |
| 117 | } |
| 118 | log("BSSMAP Connection table not found by component ", client); |
| 119 | self.stop; |
| 120 | } |
| 121 | |
| 122 | private function f_comp_by_cic(integer cic) |
| 123 | runs on BSSMAP_Emulation_CT return BSSAP_ConnHdlr { |
| 124 | var integer i; |
| 125 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 126 | if (ConnectionTable[i].cic == cic) { |
| 127 | return ConnectionTable[i].comp_ref; |
| 128 | } |
| 129 | } |
| 130 | log("BSSMAP Connection table not found by CIC ", cic); |
| 131 | self.stop; |
| 132 | } |
| 133 | |
| 134 | private function f_comp_store_cic(BSSAP_ConnHdlr client, integer cic) |
| 135 | runs on BSSMAP_Emulation_CT { |
| 136 | var integer i; |
| 137 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 138 | if (ConnectionTable[i].comp_ref == client) { |
| 139 | ConnectionTable[i].cic := cic; |
| 140 | return; |
| 141 | } |
| 142 | } |
| 143 | log("BSSMAP Connection table not found by component ", client); |
| 144 | } |
| 145 | |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 146 | /* resolve connection ID by component reference */ |
| 147 | private function f_conn_id_by_comp(BSSAP_ConnHdlr client) |
| 148 | runs on BSSMAP_Emulation_CT return integer { |
| 149 | for (var integer i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 150 | if (ConnectionTable[i].comp_ref == client) { |
| 151 | return ConnectionTable[i].sccp_conn_id; |
| 152 | } |
| 153 | } |
| 154 | log("BSSMAP Connection table not found by component ", client); |
| 155 | self.stop; |
| 156 | } |
| 157 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 158 | private function f_gen_conn_id() |
| 159 | runs on BSSMAP_Emulation_CT return integer { |
| 160 | var integer conn_id; |
| 161 | |
| 162 | do { |
| 163 | conn_id := float2int(rnd()*SCCP_Emulation.tsp_max_ConnectionId); |
| 164 | } while (f_conn_id_known(conn_id) == true); |
| 165 | |
| 166 | return conn_id; |
| 167 | } |
| 168 | |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 169 | private function f_conn_table_init() |
| 170 | runs on BSSMAP_Emulation_CT { |
| 171 | for (var integer i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 172 | ConnectionTable[i].comp_ref := null; |
| 173 | ConnectionTable[i].sccp_conn_id := -1; |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 174 | ConnectionTable[i].mgcp_trans_id := omit; |
| 175 | ConnectionTable[i].cic := omit; |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 176 | } |
| 177 | } |
| 178 | |
| 179 | private function f_conn_table_add(BSSAP_ConnHdlr comp_ref, integer sccp_conn_id) |
| 180 | runs on BSSMAP_Emulation_CT { |
| 181 | for (var integer i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 182 | if (ConnectionTable[i].sccp_conn_id == -1) { |
| 183 | ConnectionTable[i].comp_ref := comp_ref; |
| 184 | ConnectionTable[i].sccp_conn_id := sccp_conn_id; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 185 | log("Added conn table entry ", i, comp_ref, sccp_conn_id); |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 186 | return; |
| 187 | } |
| 188 | } |
| 189 | log("BSSMAP Connection table full!"); |
| 190 | self.stop; |
| 191 | } |
| 192 | |
| 193 | private function f_conn_table_del(integer sccp_conn_id) |
| 194 | runs on BSSMAP_Emulation_CT { |
| 195 | for (var integer i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 196 | if (ConnectionTable[i].sccp_conn_id == sccp_conn_id) { |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 197 | log("Deleted conn table entry ", i, |
| 198 | ConnectionTable[i].comp_ref, sccp_conn_id); |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 199 | ConnectionTable[i].sccp_conn_id := -1; |
| 200 | ConnectionTable[i].comp_ref := null; |
| 201 | } |
| 202 | } |
| 203 | log("BSSMAP Connection table attempt to delete non-existant ", sccp_conn_id); |
| 204 | self.stop; |
| 205 | } |
| 206 | |
| 207 | /* handle (optional) userData portion of various primitives and dispatch it to the client */ |
Harald Welte | 5cc4aa2 | 2017-11-23 18:51:28 +0100 | [diff] [blame] | 208 | private function f_handle_userData(BSSAP_ConnHdlr client, octetstring userdata) |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 209 | runs on BSSMAP_Emulation_CT { |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 210 | /* decode + send decoded BSSAP to client */ |
| 211 | var PDU_BSSAP bssap := dec_PDU_BSSAP(valueof(userdata)); |
| 212 | CLIENT.send(bssap) to client; |
| 213 | } |
| 214 | |
| 215 | /* call-back type, to be provided by specific implementation; called when new SCCP connection |
| 216 | * arrives */ |
| 217 | type function BssmapCreateCallback(ASP_SCCP_N_CONNECT_ind conn_ind) |
| 218 | runs on BSSMAP_Emulation_CT return BSSAP_ConnHdlr; |
| 219 | |
| 220 | type function BssmapUnitdataCallback(PDU_BSSAP bssap) |
| 221 | runs on BSSMAP_Emulation_CT return template PDU_BSSAP; |
| 222 | |
| 223 | type record BssmapOps { |
| 224 | BssmapCreateCallback create_cb, |
| 225 | BssmapUnitdataCallback unitdata_cb |
| 226 | } |
| 227 | |
| 228 | function main(BssmapOps ops) runs on BSSMAP_Emulation_CT { |
| 229 | |
| 230 | f_conn_table_init(); |
| 231 | |
| 232 | while (true) { |
| 233 | var ASP_SCCP_N_UNITDATA_ind ud_ind; |
| 234 | var ASP_SCCP_N_CONNECT_ind conn_ind; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 235 | var ASP_SCCP_N_CONNECT_cfm conn_cfm; |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 236 | var ASP_SCCP_N_DATA_ind data_ind; |
| 237 | var ASP_SCCP_N_DISCONNECT_ind disc_ind; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 238 | var BSSAP_Conn_Req creq; |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 239 | var BSSAP_ConnHdlr vc_conn; |
| 240 | var PDU_BSSAP bssap; |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 241 | var MgcpCommand mgcp_req; |
| 242 | var MgcpResponse mgcp_resp; |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 243 | |
| 244 | alt { |
| 245 | /* SCCP -> Client: UNIT-DATA (connectionless SCCP) from a BSC */ |
| 246 | [] SCCP.receive(ASP_SCCP_N_UNITDATA_ind:?) -> value ud_ind { |
| 247 | /* Connectionless Procedures like RESET */ |
| 248 | var template PDU_BSSAP resp; |
| 249 | bssap := dec_PDU_BSSAP(ud_ind.userData); |
| 250 | resp := ops.unitdata_cb.apply(bssap); |
| 251 | if (isvalue(resp)) { |
| 252 | var octetstring resp_ud := enc_PDU_BSSAP(valueof(resp)); |
| 253 | SCCP.send(t_ASP_N_UNITDATA_req(ud_ind.callingAddress, |
| 254 | ud_ind.calledAddress, omit, |
| 255 | omit, resp_ud, omit)); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | /* SCCP -> Client: new connection from BSC */ |
| 260 | [] SCCP.receive(ASP_SCCP_N_CONNECT_ind:?) -> value conn_ind { |
| 261 | vc_conn := ops.create_cb.apply(conn_ind); |
| 262 | /* store mapping between client components and SCCP connectionId */ |
| 263 | f_conn_table_add(vc_conn, conn_ind.connectionId); |
| 264 | /* handle user payload */ |
| 265 | f_handle_userData(vc_conn, conn_ind.userData); |
| 266 | /* confirm connection establishment */ |
| 267 | SCCP.send(t_ASP_N_CONNECT_res(omit, omit, omit, omit, conn_ind.connectionId, omit)); |
| 268 | } |
| 269 | |
| 270 | /* SCCP -> Client: connection-oriented data in existing connection */ |
| 271 | [] SCCP.receive(ASP_SCCP_N_DATA_ind:?) -> value data_ind { |
| 272 | vc_conn := f_comp_by_conn_id(data_ind.connectionId); |
Harald Welte | 5cc4aa2 | 2017-11-23 18:51:28 +0100 | [diff] [blame] | 273 | if (ispresent(data_ind.userData)) { |
| 274 | f_handle_userData(vc_conn, data_ind.userData); |
| 275 | } |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | /* SCCP -> Client: disconnect of an existing connection */ |
| 279 | [] SCCP.receive(ASP_SCCP_N_DISCONNECT_ind:?) -> value disc_ind { |
| 280 | vc_conn := f_comp_by_conn_id(disc_ind.connectionId); |
Harald Welte | 5cc4aa2 | 2017-11-23 18:51:28 +0100 | [diff] [blame] | 281 | if (ispresent(disc_ind.userData)) { |
| 282 | f_handle_userData(vc_conn, disc_ind.userData); |
| 283 | } |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 284 | /* notify client about termination */ |
| 285 | var BSSAP_Conn_Prim prim := MSC_CONN_PRIM_DISC_IND; |
| 286 | CLIENT.send(prim) to vc_conn; |
| 287 | f_conn_table_del(disc_ind.connectionId); |
| 288 | /* TOOD: return confirm to other side? */ |
| 289 | } |
| 290 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 291 | /* SCCP -> Client: connection confirm for outbound connection */ |
| 292 | [] SCCP.receive(ASP_SCCP_N_CONNECT_cfm:?) -> value conn_cfm { |
| 293 | /* handle user payload */ |
Harald Welte | 5cc4aa2 | 2017-11-23 18:51:28 +0100 | [diff] [blame] | 294 | if (ispresent(conn_cfm.userData)) { |
| 295 | f_handle_userData(vc_conn, conn_cfm.userData); |
| 296 | } |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 297 | } |
| 298 | |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 299 | /* Disconnect request client -> SCCP */ |
| 300 | [] CLIENT.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_REQ) -> sender vc_conn { |
| 301 | var integer conn_id := f_conn_id_by_comp(vc_conn); |
| 302 | SCCP.send(t_ASP_N_DISCONNECT_req(omit, 0, omit, conn_id, omit)); |
| 303 | f_conn_table_del(conn_id); |
| 304 | } |
| 305 | |
| 306 | /* BSSAP from client -> SCCP */ |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 307 | [] CLIENT.receive(BSSAP_Conn_Req:?) -> value creq sender vc_conn { |
| 308 | var integer conn_id; |
| 309 | /* encode + send to dispatcher */ |
| 310 | var octetstring userdata := enc_PDU_BSSAP(creq.bssap); |
| 311 | |
| 312 | if (f_comp_known(vc_conn) == false) { |
| 313 | /* unknown client, create new connection */ |
| 314 | conn_id := f_gen_conn_id(); |
| 315 | |
| 316 | /* store mapping between client components and SCCP connectionId */ |
| 317 | f_conn_table_add(vc_conn, conn_id); |
| 318 | |
| 319 | SCCP.send(t_ASP_N_CONNECT_req(creq.addr_peer, creq.addr_own, omit, omit, |
| 320 | userdata, conn_id, omit)); |
| 321 | } else { |
| 322 | /* known client, send via existing connection */ |
| 323 | conn_id := f_conn_id_by_comp(vc_conn); |
| 324 | SCCP.send(t_ASP_N_DATA_req(userdata, conn_id, omit)); |
| 325 | } |
| 326 | |
| 327 | } |
| 328 | |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 329 | [] CLIENT.receive(PDU_BSSAP:?) -> value bssap sender vc_conn { |
| 330 | var integer conn_id := f_conn_id_by_comp(vc_conn); |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 331 | /* MSC Side: If this is an assignment command, store CIC */ |
| 332 | if (ischosen(bssap.pdu.bssmap.assignmentRequest) and |
| 333 | ispresent(bssap.pdu.bssmap.assignmentRequest.circuitIdentityCode)) { |
| 334 | var BSSMAP_IE_CircuitIdentityCode cic_ie := |
| 335 | bssap.pdu.bssmap.assignmentRequest.circuitIdentityCode; |
| 336 | var integer cic := (oct2int(cic_ie.cicHigh) * 256) + oct2int(cic_ie.cicLow); |
| 337 | f_comp_store_cic(vc_conn, cic); |
| 338 | } |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 339 | /* encode + send it to dispatcher */ |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 340 | var octetstring userdata := enc_PDU_BSSAP(bssap); |
| 341 | SCCP.send(t_ASP_N_DATA_req(userdata, conn_id, omit)); |
| 342 | } |
| 343 | |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 344 | /* Handling of MGCP in IPA SCCPLite case. This predates 3GPP AoIP |
| 345 | * and uses a MGCP session in parallel to BSSAP. BSSAP uses CIC |
| 346 | * as usual, and MGCP uses "CIC@mgw" endpoint naming, where CIC |
| 347 | * is printed as hex string, e.g. a@mgw for CIC 10 */ |
| 348 | |
| 349 | /* CLIENT -> MGCP */ |
| 350 | [] CLIENT.receive(MgcpCommand:?) -> value mgcp_req sender vc_conn { |
| 351 | /* MGCP request from Handler (we're MSC) */ |
| 352 | /* store the transaction ID we've seen */ |
| 353 | f_comp_store_mgcp_tid(vc_conn, mgcp_req.line.trans_id); |
| 354 | /* simply forward any MGCP from the client to the port */ |
| 355 | MGCP.send(mgcp_req); |
| 356 | } |
| 357 | [] CLIENT.receive(MgcpResponse:?) -> value mgcp_resp sender vc_conn { |
| 358 | /* MGCP response from Handler (we're BSC/MGW) */ |
| 359 | /* simply forward any MGCP from the client to the port */ |
| 360 | MGCP.send(mgcp_resp); |
| 361 | } |
| 362 | |
| 363 | /* MGCP -> CLIENT */ |
| 364 | [] MGCP.receive(MgcpCommand:?) -> value mgcp_req { |
| 365 | /* MGCP request from network side (we're BSC/MGW) */ |
| 366 | /* Extract CIC from local part of endpoint name */ |
| 367 | var integer cic := f_mgcp_ep_extract_cic(mgcp_req.line.ep); |
| 368 | /* Resolve the vc_conn by the CIC */ |
| 369 | vc_conn := f_comp_by_cic(cic); |
| 370 | CLIENT.send(mgcp_req) to vc_conn; |
| 371 | } |
| 372 | [] MGCP.receive(MgcpResponse:?) -> value mgcp_resp { |
| 373 | /* MGCP response from network side (we're MSC) */ |
| 374 | /* Resolve the vc_conn by the transaction ID */ |
| 375 | vc_conn := f_comp_by_mgcp_tid(mgcp_resp.line.trans_id); |
| 376 | CLIENT.send(mgcp_resp) to vc_conn; |
| 377 | } |
| 378 | |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame^] | 383 | private function f_mgcp_ep_extract_cic(charstring inp) return integer { |
| 384 | var charstring local_part := regexp(inp, "(.*)@(.*)", 0); |
| 385 | return hex2int(str2hex(local_part)); |
| 386 | |
| 387 | } |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 388 | |
| 389 | } |