osmo-bsc: Move user plane/voice related bits into sub-structure

This clarifies which members of the struct are for what.

Change-Id: I618822e6f2d48adce25f9df5c25acbce7c858412
This commit is contained in:
Harald Welte 2017-12-18 18:27:43 +01:00
parent ca494f385e
commit ea0c3203db
7 changed files with 43 additions and 44 deletions

View File

@ -26,23 +26,23 @@ struct osmo_bsc_sccp_con {
int ciphering_handled;
/* for audio handling */
uint16_t cic;
uint32_t rtp_ip;
int rtp_port;
struct {
uint16_t cic;
uint32_t rtp_ip;
int rtp_port;
/* RTP address of the remote end (assigned by MSC through assignment request) */
struct sockaddr_storage aoip_rtp_addr_remote;
/* RTP address of the remote end (assigned by MSC through assignment
* request) */
struct sockaddr_storage aoip_rtp_addr_remote;
/* Local RTP address (reported back to the MSC by us with the
* assignment complete message) */
struct sockaddr_storage aoip_rtp_addr_local;
/* Local RTP address (reported back to the MSC by us with the
* assignment complete message) */
struct sockaddr_storage aoip_rtp_addr_local;
/* storage to keep states of the MGCP connection handler, the
* handler is created when an assignment request is received
* and is terminated when the assignment complete message is
* sent */
struct mgcp_ctx *mgcp_ctx;
/* storage to keep states of the MGCP connection handler, the
* handler is created when an assignment request is received
* and is terminated when the assignment complete message is
* sent */
struct mgcp_ctx *mgcp_ctx;
} user_plane;
/* for advanced ping/pong */
int send_ping;

View File

@ -435,7 +435,7 @@ static void bsc_assign_compl(struct gsm_subscriber_connection *conn, uint8_t rr_
struct msgb *resp;
return_when_not_connected(conn);
if (is_ipaccess_bts(conn->bts) && conn->sccp_con->rtp_ip) {
if (is_ipaccess_bts(conn->bts) && conn->sccp_con->user_plane.rtp_ip) {
/* NOTE: In a network that makes use of an IPA base station
* and AoIP, we have to wait until the BTS reports its RTP
* IP/Port combination back to BSC via RSL. Unfortunately, the

View File

@ -57,17 +57,17 @@ static int handle_abisip_signal(unsigned int subsys, unsigned int signal,
/* we can ask it to connect now */
LOGP(DMSC, LOGL_DEBUG, "Connecting BTS to port: %d conn: %d\n",
con->sccp_con->rtp_port, lchan->abis_ip.conn_id);
con->sccp_con->user_plane.rtp_port, lchan->abis_ip.conn_id);
/* If AoIP is in use, the rtp_ip, which has been communicated
* via the A interface as connect_ip */
if(con->sccp_con->rtp_ip)
rtp_ip = con->sccp_con->rtp_ip;
if(con->sccp_con->user_plane.rtp_ip)
rtp_ip = con->sccp_con->user_plane.rtp_ip;
else
rtp_ip = ntohl(INADDR_ANY);
rc = rsl_ipacc_mdcx(lchan, rtp_ip,
con->sccp_con->rtp_port,
con->sccp_con->user_plane.rtp_port,
lchan->abis_ip.rtp_payload2);
if (rc < 0) {
LOGP(DMSC, LOGL_ERROR, "Failed to send MDCX: %d\n", rc);
@ -84,13 +84,13 @@ static int handle_abisip_signal(unsigned int subsys, unsigned int signal,
* inform the logic that controls the MGW about the new
* connection info */
LOGP(DMSC, LOGL_INFO,"RTP connection handover initiated...\n");
mgcp_handover(con->sccp_con->mgcp_ctx, con->ho_lchan);
} else if (is_ipaccess_bts(con->bts) && con->sccp_con->rtp_ip) {
mgcp_handover(con->sccp_con->user_plane.mgcp_ctx, con->ho_lchan);
} else if (is_ipaccess_bts(con->bts) && con->sccp_con->user_plane.rtp_ip) {
/* NOTE: This is only relevant on AoIP networks with
* IPA based base stations. See also osmo_bsc_api.c,
* function bsc_assign_compl() */
LOGP(DMSC, LOGL_INFO, "Tx MSC ASSIGN COMPL (POSTPONED)\n");
mgcp_ass_complete(con->sccp_con->mgcp_ctx, lchan);
mgcp_ass_complete(con->sccp_con->user_plane.mgcp_ctx, lchan);
}
break;
}

View File

@ -361,13 +361,13 @@ static int bssmap_handle_clear_command(struct osmo_bsc_sccp_con *conn,
return -1;
}
if (conn->mgcp_ctx) {
if (conn->user_plane.mgcp_ctx) {
/* NOTE: This is the AoIP case, osmo-bsc has to negotiate with
* the MGCP-GW. For this an mgcp_ctx should be created that
* contains the FSM and some system data. When the connection
* is removed from the MGCP-GW, then osmo_bsc_sigtran_send()
* calls osmo_bsc_sigtran_send(). */
mgcp_clear_complete(conn->mgcp_ctx, resp);
mgcp_clear_complete(conn->user_plane.mgcp_ctx, resp);
} else {
/* NOTE: This is the SCCP-Lite case, since we do not handle
* the MGCP-GW switching ourselves, we may skip everything
@ -535,11 +535,9 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn,
/* Detect if a CIC code is present, if so, we use the classic ip.access
* method to calculate the RTP port */
if (TLVP_PRESENT(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE)) {
conn->cic =
osmo_load16be(TLVP_VAL
(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE));
timeslot = conn->cic & 0x1f;
multiplex = (conn->cic & ~0x1f) >> 5;
conn->user_plane.cic = osmo_load16be(TLVP_VAL(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE));
timeslot = conn->user_plane.cic & 0x1f;
multiplex = (conn->user_plane.cic & ~0x1f) >> 5;
} else if (TLVP_PRESENT(&tp, GSM0808_IE_AOIP_TRASP_ADDR)) {
/* Decode AoIP transport address element */
data = TLVP_VAL(&tp, GSM0808_IE_AOIP_TRASP_ADDR);
@ -621,15 +619,16 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn,
* reasons, functional wise it would not matter when exactly
* the network side RTP connection is made, as long it is made
* before we return with the assignment complete message. */
memcpy(&conn->aoip_rtp_addr_remote, &rtp_addr, sizeof(rtp_addr));
memcpy(&conn->user_plane.aoip_rtp_addr_remote, &rtp_addr, sizeof(rtp_addr));
/* Create an assignment request using the MGCP fsm. This FSM
* is directly started when its created (now) and will also
* take care about the further processing (creating RTP
* endpoints, calling gsm0808_assign_req(), responding to
* the assignment request etc... */
conn->mgcp_ctx = mgcp_assignm_req(msc->network, msc->network->mgw.client, conn, chan_mode, full_rate);
if (!conn->mgcp_ctx) {
conn->user_plane.mgcp_ctx = mgcp_assignm_req(msc->network, msc->network->mgw.client,
conn, chan_mode, full_rate);
if (!conn->user_plane.mgcp_ctx) {
LOGP(DMSC, LOGL_ERROR, "MGCP GW failure, rejecting assignment... (id=%i)\n", conn->conn_id);
goto reject;
}
@ -641,8 +640,8 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn,
* (the MSC does that for us). We set conn->rtp_ip to 0 and check
* on this later. By this we know that we have to behave accordingly
* to sccp-lite. */
conn->rtp_port = mgcp_timeslot_to_port(multiplex, timeslot, msc->rtp_base);
conn->rtp_ip = 0;
conn->user_plane.rtp_port = mgcp_timeslot_to_port(multiplex, timeslot, msc->rtp_base);
conn->user_plane.rtp_ip = 0;
return gsm0808_assign_req(conn->conn, chan_mode, full_rate);
}
@ -849,7 +848,7 @@ int bssmap_send_aoip_ass_compl(struct gsm_lchan *lchan)
lchan->abis_ip.ass_compl.chosen_channel,
lchan->abis_ip.ass_compl.encr_alg_id,
lchan->abis_ip.ass_compl.speech_mode,
&conn->sccp_con->aoip_rtp_addr_local,
&conn->sccp_con->user_plane.aoip_rtp_addr_local,
&sc,
NULL);

View File

@ -552,7 +552,7 @@ static int set_net_ussd_notify(struct ctrl_cmd *cmd, void *data)
if (!conn->sccp_con)
continue;
if (conn->sccp_con->cic != cic)
if (conn->sccp_con->user_plane.cic != cic)
continue;
/*

View File

@ -231,8 +231,8 @@ static void crcx_for_bts_resp_cb(struct mgcp_response *r, void *priv)
/* Set the connection details in the conn struct. The code that
* controls the BTS via RSL will take these values and signal them
* to the BTS via RSL/IPACC */
conn->rtp_port = r->audio_port;
conn->rtp_ip = osmo_ntohl(inet_addr(r->audio_ip));
conn->user_plane.rtp_port = r->audio_port;
conn->user_plane.rtp_ip = osmo_ntohl(inet_addr(r->audio_ip));
/* Notify the FSM that we got the response. */
osmo_fsm_inst_dispatch(mgcp_ctx->fsm, EV_CRCX_BTS_RESP, mgcp_ctx);
@ -428,7 +428,7 @@ static void fsm_crcx_net_cb(struct osmo_fsm_inst *fi, uint32_t event, void *data
* identifier. However, the MGW does not support IPv6 yet. This is
* why we stop here in case some MSC tries to signal IPv6 AoIP
* transport identifiers */
if (conn->aoip_rtp_addr_remote.ss_family != AF_INET) {
if (conn->user_plane.aoip_rtp_addr_remote.ss_family != AF_INET) {
LOGPFSML(fi, LOGL_ERROR,
"CRCX/NET: endpoint:%x MSC uses unsupported address format in AoIP transport identifier -- aborting...\n",
rtp_endpoint);
@ -436,7 +436,7 @@ static void fsm_crcx_net_cb(struct osmo_fsm_inst *fi, uint32_t event, void *data
return;
}
sin = (struct sockaddr_in *)&conn->aoip_rtp_addr_remote;
sin = (struct sockaddr_in *)&conn->user_plane.aoip_rtp_addr_remote;
addr = inet_ntoa(sin->sin_addr);
port = osmo_ntohs(sin->sin_port);
LOGPFSML(fi, LOGL_DEBUG, "CRCX/NET: MSC expects RTP input on address %s:%u\n", addr, port);
@ -512,7 +512,7 @@ static void crcx_for_net_resp_cb(struct mgcp_response *r, void *priv)
r->audio_ip, r->audio_port);
/* Store address */
sin = (struct sockaddr_in *)&conn->aoip_rtp_addr_local;
sin = (struct sockaddr_in *)&conn->user_plane.aoip_rtp_addr_local;
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = inet_addr(r->audio_ip);
sin->sin_port = osmo_ntohs(r->audio_port);

View File

@ -385,8 +385,8 @@ int osmo_bsc_sigtran_del_conn(struct osmo_bsc_sccp_con *conn)
}
/* Remove mgcp context if existant */
if (conn->mgcp_ctx)
mgcp_free_ctx(conn->mgcp_ctx);
if (conn->user_plane.mgcp_ctx)
mgcp_free_ctx(conn->user_plane.mgcp_ctx);
llist_del(&conn->entry);
talloc_free(conn);