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
changes/98/12398/5
Neels Hofmeyr 4 years ago committed by Neels Hofmeyr
parent 7916ca1c2d
commit b16259f9ad
  1. 1
      include/osmocom/msc/msc_mgcp.h
  2. 26
      src/libmsc/gsm_04_08_cc.c
  3. 16
      src/libmsc/msc_mgcp.c
  4. 2
      tests/msc_vlr/Makefile.am
  5. 6
      tests/msc_vlr/msc_vlr_tests.c

@ -57,6 +57,7 @@ struct mgcp_ctx {
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_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);

@ -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);
/* Assign call (if not done yet) */
if (trans->assignment_done == false) {
rc = msc_mgcp_call_assignment(trans);
trans->assignment_done = true;
}
else
rc = 0;
rc = msc_mgcp_try_call_assignment(trans);
/* don't continue, if there were problems with
* the call assignment. */
@ -780,14 +775,7 @@ static int gsm48_cc_tx_call_proc_and_assign(struct gsm_trans *trans, void *arg)
return rc;
/* Assign call (if not done yet) */
if (trans->assignment_done == false) {
rc = msc_mgcp_call_assignment(trans);
trans->assignment_done = true;
}
else
rc = 0;
return rc;
return msc_mgcp_try_call_assignment(trans);
}
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)
{
struct gsm_trans *trans;
int rc;
/* Find 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;
/* Assign call (if not done yet) */
if (trans->assignment_done == false) {
rc = msc_mgcp_call_assignment(trans);
trans->assignment_done = true;
}
else
rc = 0;
return rc;
return msc_mgcp_try_call_assignment(trans);
}
/* Trigger TCH_RTP_CREATE acknowledgement */

@ -951,6 +951,22 @@ static struct osmo_fsm fsm_msc_mgcp = {
.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
* RAN and the CN on the MGW.
* Parameter:

@ -32,7 +32,7 @@ AM_LDFLAGS = \
-Wl,--wrap=gsm340_gen_scts \
-Wl,--wrap=osmo_get_rand_id \
-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=ranap_iu_tx_sec_mode_cmd \
-Wl,--wrap=osmo_sccp_tx_data_msg \

@ -652,9 +652,9 @@ int __wrap_a_iface_tx_clear_cmd(struct ran_conn *conn)
return 0;
}
/* override, requires '-Wl,--wrap=msc_mgcp_call_assignment' */
int __real_msc_mgcp_call_assignment(struct gsm_trans *trans);
int __wrap_msc_mgcp_call_assignment(struct gsm_trans *trans)
/* override, requires '-Wl,--wrap=msc_mgcp_try_call_assignment' */
int __real_msc_mgcp_try_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",
vlr_subscr_name(trans->vsub), trans->callref);

Loading…
Cancel
Save