diff options
-rw-r--r-- | include/osmocom/bsc/bsc_subscr_conn_fsm.h | 9 | ||||
-rw-r--r-- | include/osmocom/bsc/gsm_data.h | 3 | ||||
-rw-r--r-- | src/osmo-bsc/bsc_subscr_conn_fsm.c | 15 | ||||
-rw-r--r-- | src/osmo-bsc/gsm_04_08_rr.c | 2 | ||||
-rw-r--r-- | src/osmo-bsc/gsm_data.c | 27 | ||||
-rw-r--r-- | src/osmo-bsc/lchan_fsm.c | 4 | ||||
-rw-r--r-- | src/osmo-bsc/osmo_bsc_bssap.c | 16 |
7 files changed, 64 insertions, 12 deletions
diff --git a/include/osmocom/bsc/bsc_subscr_conn_fsm.h b/include/osmocom/bsc/bsc_subscr_conn_fsm.h index 5475272b0..1a827d95c 100644 --- a/include/osmocom/bsc/bsc_subscr_conn_fsm.h +++ b/include/osmocom/bsc/bsc_subscr_conn_fsm.h @@ -1,4 +1,6 @@ #pragma once +#include <osmocom/gsm/protocol/gsm_08_08.h> +#include <osmocom/gsm/protocol/gsm_04_08.h> #include <osmocom/core/fsm.h> enum gscon_fsm_event { @@ -40,6 +42,11 @@ enum gscon_fsm_event { GSCON_EV_FORGET_MGW_ENDPOINT, }; +struct gscon_clear_cmd_data { + enum gsm0808_cause cause_0808; + bool is_csfb; +}; + struct gsm_subscriber_connection; struct gsm_network; struct msgb; @@ -71,7 +78,7 @@ void gscon_start_assignment(struct gsm_subscriber_connection *conn, struct assignment_request *req); void gscon_change_primary_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *new_lchan); -void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release); +void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release, enum gsm48_rr_cause cause_rr); void gscon_lchan_releasing(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan); void gscon_forget_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan); diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 5336ebef2..43d7040fc 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -571,6 +571,7 @@ struct gsm_lchan { * flag, so that the lchan will gracefully release at the next sensible junction. */ bool requested; bool do_rr_release; + enum gsm48_rr_cause rr_cause; /* There is an RSL error cause of value 0, so we need a separate flag. */ bool in_error; @@ -1896,4 +1897,6 @@ int bts_count_free_ts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan); bool trx_has_valid_pchan_config(const struct gsm_bts_trx *trx); +enum gsm48_rr_cause bsc_gsm48_rr_cause_from_gsm0808_cause(enum gsm0808_cause c); + #endif /* _GSM_DATA_H */ diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c index 1d3024610..0ed6715be 100644 --- a/src/osmo-bsc/bsc_subscr_conn_fsm.c +++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c @@ -182,14 +182,14 @@ static void gscon_release_lchan(struct gsm_subscriber_connection *conn, struct g lchan_release(lchan, do_rr_release, err, cause_rr); } -void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release) +void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release, enum gsm48_rr_cause cause_rr) { if (conn->ho.fi) handover_end(conn, HO_RESULT_CONN_RELEASE); assignment_reset(conn); - gscon_release_lchan(conn, conn->lchan, do_rr_release, false, 0); + gscon_release_lchan(conn, conn->lchan, do_rr_release, false, cause_rr); } static void handle_bssap_n_connect(struct osmo_fsm_inst *fi, struct osmo_scu_prim *scu_prim) @@ -746,17 +746,20 @@ void gscon_forget_mgw_endpoint_ci(struct gsm_subscriber_connection *conn, struct static void gscon_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct gsm_subscriber_connection *conn = fi->priv; + const struct gscon_clear_cmd_data *ccd; /* Regular allstate event processing */ switch (event) { case GSCON_EV_A_CLEAR_CMD: + OSMO_ASSERT(data); + ccd = data; if (conn->lchan) - conn->lchan->release.is_csfb = *(bool *)data; + conn->lchan->release.is_csfb = ccd->is_csfb; /* MSC tells us to cleanly shut down */ if (conn->fi->state != ST_CLEARING) osmo_fsm_inst_state_chg(fi, ST_CLEARING, 60, 999); LOGPFSML(fi, LOGL_DEBUG, "Releasing all lchans (if any) after BSSMAP Clear Command\n"); - gscon_release_lchans(conn, true); + gscon_release_lchans(conn, true, bsc_gsm48_rr_cause_from_gsm0808_cause(ccd->cause_0808)); /* FIXME: Release all terestrial resources in ST_CLEARING */ /* According to 3GPP 48.008 3.1.9.1. "The BSS need not wait for the radio channel * release to be completed or for the guard timer to expire before returning the @@ -833,7 +836,9 @@ static void gscon_pre_term(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause ca } LOGPFSML(fi, LOGL_DEBUG, "Releasing all lchans (if any) because this conn is terminating\n"); - gscon_release_lchans(conn, true); + /* when things go smoothly, the lchan should have been released before FSM instance termination. So if this is + * necessary it's probably "abnormal". */ + gscon_release_lchans(conn, true, GSM48_RR_CAUSE_ABNORMAL_UNSPEC); /* drop pending messages */ gscon_dtap_queue_flush(conn, 0); diff --git a/src/osmo-bsc/gsm_04_08_rr.c b/src/osmo-bsc/gsm_04_08_rr.c index f425b1636..07978de30 100644 --- a/src/osmo-bsc/gsm_04_08_rr.c +++ b/src/osmo-bsc/gsm_04_08_rr.c @@ -303,7 +303,7 @@ int gsm48_send_rr_release(struct gsm_lchan *lchan) gh->msg_type = GSM48_MT_RR_CHAN_REL; cause = msgb_put(msg, 1); - cause[0] = GSM48_RR_CAUSE_NORMAL; + cause[0] = lchan->release.rr_cause; if (lchan->release.is_csfb) { uint8_t buf[CELL_SEL_IND_AFTER_REL_MAX_BYTES]; diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c index f790b90d8..860e236fe 100644 --- a/src/osmo-bsc/gsm_data.c +++ b/src/osmo-bsc/gsm_data.c @@ -1840,3 +1840,30 @@ bool trx_has_valid_pchan_config(const struct gsm_bts_trx *trx) return result; } + +/* This may be specific to RR Channel Release, and the mappings were chosen by pure naive guessing without a proper + * specification available. */ +enum gsm48_rr_cause bsc_gsm48_rr_cause_from_gsm0808_cause(enum gsm0808_cause c) +{ + switch (c) { + case GSM0808_CAUSE_PREEMPTION: + return GSM48_RR_CAUSE_PREMPTIVE_REL; + case GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE: + case GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS: + case GSM0808_CAUSE_INFORMATION_ELEMENT_OR_FIELD_MISSING: + case GSM0808_CAUSE_INCORRECT_VALUE: + case GSM0808_CAUSE_UNKNOWN_MESSAGE_TYPE: + case GSM0808_CAUSE_UNKNOWN_INFORMATION_ELEMENT: + return GSM48_RR_CAUSE_PROT_ERROR_UNSPC; + case GSM0808_CAUSE_CALL_CONTROL: + case GSM0808_CAUSE_HANDOVER_SUCCESSFUL: + case GSM0808_CAUSE_BETTER_CELL: + case GSM0808_CAUSE_DIRECTED_RETRY: + case GSM0808_CAUSE_REDUCE_LOAD_IN_SERVING_CELL: + case GSM0808_CAUSE_RELOCATION_TRIGGERED: + case GSM0808_CAUSE_ALT_CHAN_CONFIG_REQUESTED: + return GSM48_RR_CAUSE_NORMAL; + default: + return GSM48_RR_CAUSE_ABNORMAL_UNSPEC; + } +} diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c index 68eef4b8b..dfb8a053d 100644 --- a/src/osmo-bsc/lchan_fsm.c +++ b/src/osmo-bsc/lchan_fsm.c @@ -402,6 +402,8 @@ static void lchan_reset(struct gsm_lchan *lchan) .meas_rep_last_seen_nr = 255, .last_error = lchan->last_error, + + .release.rr_cause = GSM48_RR_CAUSE_NORMAL, }; } @@ -1369,8 +1371,8 @@ void lchan_release(struct gsm_lchan *lchan, bool do_rr_release, struct osmo_fsm_inst *fi = lchan->fi; lchan->release.in_error = err; - lchan->release.rsl_error_cause = cause_rr; lchan->release.do_rr_release = do_rr_release; + lchan->release.rr_cause = cause_rr; /* States waiting for events will notice the desire to release when done waiting, so it is enough * to mark for release. */ diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c index 2deb7f46b..1cacfe935 100644 --- a/src/osmo-bsc/osmo_bsc_bssap.c +++ b/src/osmo-bsc/osmo_bsc_bssap.c @@ -453,15 +453,23 @@ static int bssmap_handle_clear_cmd(struct gsm_subscriber_connection *conn, struct msgb *msg, unsigned int length) { struct tlv_parsed tp; - bool is_csfb = false; + struct gscon_clear_cmd_data ccd = { + .is_csfb = false, + }; tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l4h + 1, length - 1, 0, 0); - /* FIXME: Check for mandatory cause IE, and use that in RR RELEASE cause! */ + ccd.cause_0808 = gsm0808_get_cause(&tp); + if (ccd.cause_0808 < 0) { + LOGPFSML(conn->fi, LOGL_ERROR, "Clear Command: Mandatory Cause IE not present.\n"); + /* Clear anyway, but without a proper cause. */ + ccd.cause_0808 = GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE; + } + if (TLVP_PRESENT(&tp, GSM0808_IE_CSFB_INDICATION)) - is_csfb = true; + ccd.is_csfb = true; - osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CLEAR_CMD, &is_csfb); + osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CLEAR_CMD, &ccd); return 0; } |