From fe65ece24cb25f44b587c16d102bf57da1acbb42 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 9 Nov 2018 13:36:11 +0100 Subject: LCLS: update parameter representation * use osmo_lcls struct from libosmocore * use enum values instead of magic numbers Change-Id: I5e962d4fbb24bf1fb2398dc13e142a4a3304d858 Related: OS#3659 --- include/osmocom/bsc/gsm_data.h | 4 ++-- src/osmo-bsc/bsc_subscr_conn_fsm.c | 6 +++--- src/osmo-bsc/osmo_bsc_lcls.c | 26 ++++++++++---------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 738bad349..cf34c6f16 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -275,8 +275,8 @@ struct gsm_subscriber_connection { struct { uint8_t global_call_ref[15]; uint8_t global_call_ref_len; /* length of global_call_ref */ - uint8_t config; /* TS 48.008 3.2.2.116 */ - uint8_t control;/* TS 48.008 3.2.2.117 */ + enum gsm0808_lcls_config config; /* TS 48.008 3.2.2.116 */ + enum gsm0808_lcls_control control; /* TS 48.008 3.2.2.117 */ /* LCLS FSM */ struct osmo_fsm_inst *fi; /* pointer to "other" connection, if Call Leg Relocation was successful */ diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c index fac0bc0b7..85e754fa4 100644 --- a/src/osmo-bsc/bsc_subscr_conn_fsm.c +++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c @@ -883,9 +883,9 @@ struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *ne return NULL; } - /* initialize to some magic values that indicate "IE not [yet] received" */ - conn->lcls.config = 0xff; - conn->lcls.control = 0xff; + /* indicate "IE not [yet] received" */ + conn->lcls.config = GSM0808_LCLS_CFG_NA; + conn->lcls.control = GSM0808_LCLS_CSC_NA; conn->lcls.fi = osmo_fsm_inst_alloc_child(&lcls_fsm, conn->fi, GSCON_EV_LCLS_FAIL); if (!conn->lcls.fi) { osmo_fsm_inst_term(conn->fi, OSMO_FSM_TERM_ERROR, NULL); diff --git a/src/osmo-bsc/osmo_bsc_lcls.c b/src/osmo-bsc/osmo_bsc_lcls.c index cdd655798..622611d06 100644 --- a/src/osmo-bsc/osmo_bsc_lcls.c +++ b/src/osmo-bsc/osmo_bsc_lcls.c @@ -156,22 +156,16 @@ static int lcls_perform_correlation(struct gsm_subscriber_connection *conn_local return 0; } - -struct lcls_cfg_csc { - enum gsm0808_lcls_config config; - enum gsm0808_lcls_control control; -}; - /* Update the connections LCLS configuration and return old/previous configuration. * \returns (staticallly allocated) old configuration; NULL if new config not supported */ -static struct lcls_cfg_csc *update_lcls_cfg_csc(struct gsm_subscriber_connection *conn, - struct lcls_cfg_csc *new_cfg_csc) +static struct osmo_lcls *update_lcls_cfg_csc(struct gsm_subscriber_connection *conn, + struct osmo_lcls *new_cfg_csc) { - static struct lcls_cfg_csc old_cfg_csc; + static struct osmo_lcls old_cfg_csc = { 0 }; old_cfg_csc.config = conn->lcls.config; old_cfg_csc.control = conn->lcls.control; - if (new_cfg_csc->config != 0xff) { + if (new_cfg_csc->config != GSM0808_LCLS_CFG_NA) { if (!lcls_is_supported_config(new_cfg_csc->config)) return NULL; if (conn->lcls.config != new_cfg_csc->config) { @@ -179,7 +173,7 @@ static struct lcls_cfg_csc *update_lcls_cfg_csc(struct gsm_subscriber_connection conn->lcls.config = new_cfg_csc->config; } } - if (new_cfg_csc->control != 0xff) { + if (new_cfg_csc->control != GSM0808_LCLS_CSC_NA) { if (conn->lcls.control != new_cfg_csc->control) { /* TODO: logging */ conn->lcls.control = new_cfg_csc->control; @@ -193,9 +187,9 @@ static struct lcls_cfg_csc *update_lcls_cfg_csc(struct gsm_subscriber_connection * unsupported, change into LCLS NOT SUPPORTED state and return -EINVAL. */ static int lcls_handle_cfg_update(struct gsm_subscriber_connection *conn, void *data) { - struct lcls_cfg_csc *new_cfg_csc, *old_cfg_csc; + struct osmo_lcls *new_cfg_csc, *old_cfg_csc; - new_cfg_csc = (struct lcls_cfg_csc *) data; + new_cfg_csc = (struct osmo_lcls *) data; old_cfg_csc = update_lcls_cfg_csc(conn, new_cfg_csc); if (!old_cfg_csc) { osmo_fsm_inst_state_chg(conn->lcls.fi, ST_REQ_LCLS_NOT_SUPP, 0, 0); @@ -208,9 +202,9 @@ static int lcls_handle_cfg_update(struct gsm_subscriber_connection *conn, void * void lcls_update_config(struct gsm_subscriber_connection *conn, const uint8_t *config, const uint8_t *control) { - struct lcls_cfg_csc new_cfg = { - .config = 0xff, - .control = 0xff, + struct osmo_lcls new_cfg = { + .config = GSM0808_LCLS_CFG_NA, + .control = GSM0808_LCLS_CSC_NA, }; /* nothing to update, skip it */ if (!config && !control) -- cgit v1.2.3