remove code dup: add msc_mgcp_try_call_assignment()

Various places in the code check a flag whether assignment was started and
launch it. To fix incoming-call-during-ongoing-call, I will tweak that logic.
To be able to do that only in one place, remove code dup.

Cosmetic preparation for I1f8746e7babfcd3028a4d2c0ba260c608c686c76 and
I0ba216b737909e92080a722db26e3577726c63cb/

Depends: I11b182a03f5ecb6df7cd8f260757d3626c8e945d (libosmocore: LOGPFSMSL)
Change-Id: I11c0b7dc3f1a747028629b48e522bb3b864884ba
This commit is contained in:
Neels Hofmeyr 2018-12-20 02:57:56 +01:00 committed by Neels Hofmeyr
parent 7916ca1c2d
commit b16259f9ad
5 changed files with 24 additions and 27 deletions

View File

@ -57,6 +57,7 @@ struct mgcp_ctx {
mgcp_trans_id_t mgw_pending_trans; mgcp_trans_id_t mgw_pending_trans;
}; };
int msc_mgcp_try_call_assignment(struct gsm_trans *trans);
int msc_mgcp_call_assignment(struct gsm_trans *trans); int msc_mgcp_call_assignment(struct gsm_trans *trans);
int msc_mgcp_ass_complete(struct ran_conn *conn, uint16_t port, char *addr); int msc_mgcp_ass_complete(struct ran_conn *conn, uint16_t port, char *addr);
int msc_mgcp_call_complete(struct gsm_trans *trans, uint16_t port, char *addr); int msc_mgcp_call_complete(struct gsm_trans *trans, uint16_t port, char *addr);

View File

@ -736,12 +736,7 @@ static int gsm48_cc_rx_call_conf(struct gsm_trans *trans, struct msgb *msg)
new_cc_state(trans, GSM_CSTATE_MO_TERM_CALL_CONF); new_cc_state(trans, GSM_CSTATE_MO_TERM_CALL_CONF);
/* Assign call (if not done yet) */ /* Assign call (if not done yet) */
if (trans->assignment_done == false) { rc = msc_mgcp_try_call_assignment(trans);
rc = msc_mgcp_call_assignment(trans);
trans->assignment_done = true;
}
else
rc = 0;
/* don't continue, if there were problems with /* don't continue, if there were problems with
* the call assignment. */ * the call assignment. */
@ -780,14 +775,7 @@ static int gsm48_cc_tx_call_proc_and_assign(struct gsm_trans *trans, void *arg)
return rc; return rc;
/* Assign call (if not done yet) */ /* Assign call (if not done yet) */
if (trans->assignment_done == false) { return msc_mgcp_try_call_assignment(trans);
rc = msc_mgcp_call_assignment(trans);
trans->assignment_done = true;
}
else
rc = 0;
return rc;
} }
static int gsm48_cc_rx_alerting(struct gsm_trans *trans, struct msgb *msg) static int gsm48_cc_rx_alerting(struct gsm_trans *trans, struct msgb *msg)
@ -1706,7 +1694,6 @@ static void mncc_recv_rtp_err(struct gsm_network *net, uint32_t callref, int cmd
static int tch_rtp_create(struct gsm_network *net, uint32_t callref) static int tch_rtp_create(struct gsm_network *net, uint32_t callref)
{ {
struct gsm_trans *trans; struct gsm_trans *trans;
int rc;
/* Find callref */ /* Find callref */
trans = trans_find_by_callref(net, callref); trans = trans_find_by_callref(net, callref);
@ -1737,14 +1724,7 @@ static int tch_rtp_create(struct gsm_network *net, uint32_t callref)
trans->tch_rtp_create = true; trans->tch_rtp_create = true;
/* Assign call (if not done yet) */ /* Assign call (if not done yet) */
if (trans->assignment_done == false) { return msc_mgcp_try_call_assignment(trans);
rc = msc_mgcp_call_assignment(trans);
trans->assignment_done = true;
}
else
rc = 0;
return rc;
} }
/* Trigger TCH_RTP_CREATE acknowledgement */ /* Trigger TCH_RTP_CREATE acknowledgement */

View File

@ -951,6 +951,22 @@ static struct osmo_fsm fsm_msc_mgcp = {
.event_names = msc_mgcp_fsm_evt_names, .event_names = msc_mgcp_fsm_evt_names,
}; };
/* Try to invoke call assignment and set trans->assignment_done flag if invoked.
* This is relevant for already ongoing calls -- scenario:
* - subscriber is in an active voice call,
* - another call is coming in.
* For the second call coming in, we must wait to establish RTP and assignment until the first call is CC-Disconnected.
*/
int msc_mgcp_try_call_assignment(struct gsm_trans *trans)
{
struct ran_conn *conn = trans->conn;
if (trans->assignment_done)
return 0;
LOGPFSMSL(conn->fi, DMGCP, LOGL_INFO, "Starting call assignment\n");
trans->assignment_done = true;
return msc_mgcp_call_assignment(trans);
}
/* Notify that a new call begins. This will create a connection for the /* Notify that a new call begins. This will create a connection for the
* RAN and the CN on the MGW. * RAN and the CN on the MGW.
* Parameter: * Parameter:

View File

@ -32,7 +32,7 @@ AM_LDFLAGS = \
-Wl,--wrap=gsm340_gen_scts \ -Wl,--wrap=gsm340_gen_scts \
-Wl,--wrap=osmo_get_rand_id \ -Wl,--wrap=osmo_get_rand_id \
-Wl,--wrap=msc_mgcp_call_release \ -Wl,--wrap=msc_mgcp_call_release \
-Wl,--wrap=msc_mgcp_call_assignment \ -Wl,--wrap=msc_mgcp_try_call_assignment \
-Wl,--wrap=a_iface_tx_cipher_mode \ -Wl,--wrap=a_iface_tx_cipher_mode \
-Wl,--wrap=ranap_iu_tx_sec_mode_cmd \ -Wl,--wrap=ranap_iu_tx_sec_mode_cmd \
-Wl,--wrap=osmo_sccp_tx_data_msg \ -Wl,--wrap=osmo_sccp_tx_data_msg \

View File

@ -652,9 +652,9 @@ int __wrap_a_iface_tx_clear_cmd(struct ran_conn *conn)
return 0; return 0;
} }
/* override, requires '-Wl,--wrap=msc_mgcp_call_assignment' */ /* override, requires '-Wl,--wrap=msc_mgcp_try_call_assignment' */
int __real_msc_mgcp_call_assignment(struct gsm_trans *trans); int __real_msc_mgcp_try_call_assignment(struct gsm_trans *trans);
int __wrap_msc_mgcp_call_assignment(struct gsm_trans *trans) int __wrap_msc_mgcp_try_call_assignment(struct gsm_trans *trans)
{ {
log("MS <--Call Assignment-- MSC: subscr=%s callref=0x%x", log("MS <--Call Assignment-- MSC: subscr=%s callref=0x%x",
vlr_subscr_name(trans->vsub), trans->callref); vlr_subscr_name(trans->vsub), trans->callref);