aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-05-18 00:04:02 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-05-23 13:32:02 +0200
commit74e4daa6956404485027f17ed5c5a0c2acd39250 (patch)
treec66bc47d365dde0352bcd336e727b3ee74139c94
parent163f631f08ecf7095bf102b777ac745dab43ddac (diff)
cosmetic: logging and ordering in handle_ass_compl()
* Check the message length once at the start, before any other actions. * Use only one local gsm48_hdr pointer. * Read the cause value once near the top, re-use it. * Log "ASSIGNMENT COMPLETE" always, not only during handover. * Fully initialize local struct lchan_signal_data. Change-Id: Idcfd932d3dfb0b621ed6d8c4f92c0231abcdcec8
-rw-r--r--src/libbsc/bsc_api.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 71cc0f01f..8ae781e96 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -344,18 +344,27 @@ int gsm0808_page(struct gsm_bts *bts, unsigned int page_group, unsigned int mi_l
static void handle_ass_compl(struct gsm_subscriber_connection *conn,
struct msgb *msg)
{
- struct gsm48_hdr *gh;
+ struct gsm48_hdr *gh = msgb_l3(msg);
struct bsc_api *api = conn->network->bsc_api;
+ enum gsm48_rr_cause cause;
- if (conn->ho) {
- struct lchan_signal_data sig;
- struct gsm48_hdr *gh = msgb_l3(msg);
+ /* Expecting gsm48_hdr + cause value */
+ if (msgb_l3len(msg) != sizeof(*gh) + 1) {
+ LOGPLCHAN(msg->lchan, DRR, LOGL_ERROR,
+ "RR Assignment Complete: length invalid: %u, expected %zu\n",
+ msgb_l3len(msg), sizeof(*gh) + 1);
+ return;
+ }
- LOGPLCHAN(msg->lchan, DRR, LOGL_DEBUG, "ASSIGNMENT COMPLETE cause = %s\n",
- rr_cause_name(gh->data[0]));
+ cause = gh->data[0];
- sig.lchan = msg->lchan;
- sig.mr = NULL;
+ LOGPLCHAN(msg->lchan, DRR, LOGL_DEBUG, "ASSIGNMENT COMPLETE cause = %s\n",
+ rr_cause_name(cause));
+
+ if (conn->ho) {
+ struct lchan_signal_data sig = {
+ .lchan = msg->lchan,
+ };
osmo_signal_dispatch(SS_LCHAN, S_LCHAN_ASSIGNMENT_COMPL, &sig);
/* FIXME: release old channel */
@@ -366,15 +375,8 @@ static void handle_ass_compl(struct gsm_subscriber_connection *conn,
}
if (conn->secondary_lchan != msg->lchan) {
- LOGPLCHAN(msg->lchan, DMSC, LOGL_ERROR,
- "Assignment Compl should occur on second lchan.\n");
- return;
- }
-
- gh = msgb_l3(msg);
- if (msgb_l3len(msg) - sizeof(*gh) != 1) {
- LOGPLCHAN(msg->lchan, DMSC, LOGL_ERROR, "Assignment Compl invalid: %zu\n",
- msgb_l3len(msg) - sizeof(*gh));
+ LOGPLCHAN(msg->lchan, DRR, LOGL_ERROR,
+ "RR Assignment Complete does not match conn's secondary lchan.\n");
return;
}
@@ -391,7 +393,7 @@ static void handle_ass_compl(struct gsm_subscriber_connection *conn,
if (is_ipaccess_bts(conn_get_bts(conn)) && conn->lchan->tch_mode != GSM48_CMODE_SIGN)
rsl_ipacc_crcx(conn->lchan);
- api->assign_compl(conn, gh->data[0]);
+ api->assign_compl(conn, cause);
}
static void handle_ass_fail(struct gsm_subscriber_connection *conn,