diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-06-15 15:52:23 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2019-06-17 21:01:09 +0700 |
commit | 10c3ce563b620bb0a373d00fc373b0a95df3f839 (patch) | |
tree | 3cbbe7f3de7939971458d1d8cc25efe00a92b2e0 /src | |
parent | 58abc67caaf8889d637fe2e6f3feb132e89c87f2 (diff) |
libmsc/gsm_09_11.c: do not abuse LOG_TRANS() and early trans allocation
In case of network-originated SS/USSD session establishment, we
need to verify the received GSUP PROC_SS_REQ message and make
sure that all mandatory IEs are present.
There is no sensible need to allocate a new transaction before
doing all the checks, other than the ability to use LOG_TRANS().
This complicates the code, so let's avoid the early allocation.
Change-Id: I4e027b19e8065a39324a1647957cef4066b82ce7
Diffstat (limited to 'src')
-rw-r--r-- | src/libmsc/gsm_09_11.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c index 4a7c34885..adf13b141 100644 --- a/src/libmsc/gsm_09_11.c +++ b/src/libmsc/gsm_09_11.c @@ -317,52 +317,42 @@ static struct gsm_trans *establish_nc_ss_trans(struct gsm_network *net, struct gsm_trans *trans, *transt; int tid; - /* Allocate transaction first, for log context */ - trans = trans_alloc(net, vsub, TRANS_USSD, - TRANS_ID_UNASSIGNED, gsup_msg->session_id); - - if (!trans) { - LOG_TRANS(trans, LOGL_ERROR, " -> No memory for trans\n"); - return NULL; - } - if (gsup_msg->session_state != OSMO_GSUP_SESSION_STATE_BEGIN) { - LOG_TRANS(trans, LOGL_ERROR, "Received non-BEGIN message " - "for non-existing transaction\n"); - trans_free(trans); + LOGP(DSS, LOGL_ERROR, "Received non-BEGIN message for non-existing transaction\n"); return NULL; } + LOGP(DSS, LOGL_DEBUG, "(%s) Establishing a network-originated session (id=0x%x)\n", + vlr_subscr_name(vsub), gsup_msg->session_id); + if (!gsup_msg->ss_info || gsup_msg->ss_info_len < 2) { - LOG_TRANS(trans, LOGL_ERROR, "Missing mandatory Facility IE\n"); - trans_free(trans); + LOGP(DSS, LOGL_ERROR, "Missing mandatory Facility IE\n"); return NULL; } /* If subscriber is not "attached" */ if (!vsub->cgi.lai.lac) { - LOG_TRANS(trans, LOGL_ERROR, "Network-originated session " + LOGP(DSS, LOGL_ERROR, "Network-originated session " "rejected - subscriber is not attached\n"); - trans_free(trans); return NULL; } - LOG_TRANS(trans, LOGL_DEBUG, "Establishing network-originated session\n"); - - /* Count active NC SS/USSD sessions */ - osmo_counter_inc(net->active_nc_ss); - - /* Assign transaction ID */ - tid = trans_assign_trans_id(trans->net, trans->vsub, TRANS_USSD); + /* Obtain an unused transaction ID */ + tid = trans_assign_trans_id(net, vsub, TRANS_USSD); if (tid < 0) { - LOG_TRANS(trans, LOGL_ERROR, "No free transaction ID\n"); - /* TODO: inform HLR about this */ - /* TODO: release connection with subscriber */ - trans->callref = 0; - trans_free(trans); + LOGP(DSS, LOGL_ERROR, "No free transaction ID\n"); return NULL; } - trans->transaction_id = tid; + + /* Allocate a new NCSS transaction */ + trans = trans_alloc(net, vsub, TRANS_USSD, tid, gsup_msg->session_id); + if (!trans) { + LOGP(DSS, LOGL_ERROR, " -> No memory for trans\n"); + return NULL; + } + + /* Count active NC SS/USSD sessions */ + osmo_counter_inc(net->active_nc_ss); /* Init inactivity timer */ osmo_timer_setup(&trans->ss.timer_guard, |