aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bsc
diff options
context:
space:
mode:
Diffstat (limited to 'src/osmo-bsc')
-rw-r--r--src/osmo-bsc/abis_rsl.c34
-rw-r--r--src/osmo-bsc/assignment_fsm.c15
-rw-r--r--src/osmo-bsc/bsc_subscr_conn_fsm.c2
-rw-r--r--src/osmo-bsc/gsm_data.c2
-rw-r--r--src/osmo-bsc/gsm_timers.c15
-rw-r--r--src/osmo-bsc/handover_decision_2.c2
-rw-r--r--src/osmo-bsc/handover_fsm.c6
-rw-r--r--src/osmo-bsc/handover_logic.c2
-rw-r--r--src/osmo-bsc/lchan_fsm.c12
-rw-r--r--src/osmo-bsc/mgw_endpoint_fsm.c4
-rw-r--r--src/osmo-bsc/osmo_bsc_bssap.c7
11 files changed, 55 insertions, 46 deletions
diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c
index 860350ccc..bb89ab289 100644
--- a/src/osmo-bsc/abis_rsl.c
+++ b/src/osmo-bsc/abis_rsl.c
@@ -177,12 +177,21 @@ static int build_encr_info(uint8_t *out, struct gsm_lchan *lchan)
return lchan->encr.key_len + 1;
}
-static const char *rsl_cause_name(struct tlv_parsed *tp)
+/* If the TLV contain an RSL Cause IE, return the RSL cause name and point *rsl_cause_pp at the cause
+ * value. If there is no Cause IE, return NULL and write NULL to *rsl_cause_pp. If NULL is passed as
+ * rsl_cause_pp, ignore it. Implementation choice: presence of a Cause IE cannot be indicated by a zero
+ * cause, because that would mean RSL_ERR_RADIO_IF_FAIL; a pointer-to-pointer can return NULL or point to
+ * a cause value. */
+static const char *rsl_cause_name(struct tlv_parsed *tp, const uint8_t **rsl_cause_pp)
{
static char buf[128];
+ if (rsl_cause_pp)
+ *rsl_cause_pp = NULL;
if (TLVP_PRESENT(tp, RSL_IE_CAUSE)) {
const uint8_t *cause = TLVP_VAL(tp, RSL_IE_CAUSE);
+ if (rsl_cause_pp)
+ *rsl_cause_pp = cause;
snprintf(buf, sizeof(buf), " (cause=%s [ %s])",
rsl_err_name(*cause),
osmo_hexdump(cause, TLVP_LEN(tp, RSL_IE_CAUSE)));
@@ -848,7 +857,7 @@ static int rsl_rx_chan_act_nack(struct msgb *msg)
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
struct tlv_parsed tp;
struct gsm_lchan *lchan = msg->lchan;
- const uint8_t *cause = NULL;
+ const uint8_t *cause_p;
rate_ctr_inc(&msg->lchan->ts->trx->bts->bts_ctrs->ctr[BTS_CTR_CHAN_ACT_NACK]);
@@ -859,12 +868,12 @@ static int rsl_rx_chan_act_nack(struct msgb *msg)
}
rsl_tlv_parse(&tp, dh->data, msgb_l2len(msg)-sizeof(*dh));
- LOG_LCHAN(lchan, LOGL_ERROR, "CHANNEL ACTIVATE NACK%s", rsl_cause_name(&tp));
+ LOG_LCHAN(lchan, LOGL_ERROR, "CHANNEL ACTIVATE NACK%s", rsl_cause_name(&tp, &cause_p));
if (msg_for_osmocom_dyn_ts(msg))
- osmo_fsm_inst_dispatch(lchan->ts->fi, TS_EV_PDCH_ACT_NACK, (void*)cause);
+ osmo_fsm_inst_dispatch(lchan->ts->fi, TS_EV_PDCH_ACT_NACK, (void*)cause_p);
else
- osmo_fsm_inst_dispatch(lchan->fi, LCHAN_EV_RSL_CHAN_ACTIV_NACK, (void*)cause);
+ osmo_fsm_inst_dispatch(lchan->fi, LCHAN_EV_RSL_CHAN_ACTIV_NACK, (void*)cause_p);
return 0;
}
@@ -874,18 +883,21 @@ static int rsl_rx_conn_fail(struct msgb *msg)
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
struct gsm_lchan *lchan = msg->lchan;
struct tlv_parsed tp;
- uint8_t cause = 0;
+ const uint8_t *cause_p;
rsl_tlv_parse(&tp, dh->data, msgb_l2len(msg)-sizeof(*dh));
- LOG_LCHAN(lchan, LOGL_ERROR, "CONNECTION FAIL%s", rsl_cause_name(&tp));
+ LOG_LCHAN(lchan, LOGL_ERROR, "CONNECTION FAIL%s", rsl_cause_name(&tp, &cause_p));
rate_ctr_inc(&lchan->ts->trx->bts->bts_ctrs->ctr[BTS_CTR_CHAN_RF_FAIL]);
+ /* If the lchan is associated with a conn, we shall notify the MSC of the RSL Conn Failure, and
+ * the connection will presumably be torn down and lead to an lchan release. During initial
+ * Channel Request from the MS, an lchan has no conn yet, so in that case release now. */
if (!lchan->conn) {
- lchan_release(lchan, false, true, cause);
+ lchan_release(lchan, false, true, *cause_p);
} else
- osmo_fsm_inst_dispatch(lchan->conn->fi, GSCON_EV_RSL_CONN_FAIL, &cause);
+ osmo_fsm_inst_dispatch(lchan->conn->fi, GSCON_EV_RSL_CONN_FAIL, (void*)cause_p);
return 0;
}
@@ -1193,7 +1205,7 @@ static int rsl_rx_error_rep(struct msgb *msg)
rsl_tlv_parse(&tp, rslh->data, msgb_l2len(msg)-sizeof(*rslh));
LOGP(DRSL, LOGL_ERROR, "%s ERROR REPORT%s\n",
- gsm_trx_name(sign_link->trx), rsl_cause_name(&tp));
+ gsm_trx_name(sign_link->trx), rsl_cause_name(&tp, NULL));
return 0;
}
@@ -1908,7 +1920,7 @@ static int abis_rsl_rx_ipacc_dlcx_ind(struct msgb *msg)
rsl_tlv_parse(&tv, dh->data, msgb_l2len(msg)-sizeof(*dh));
LOG_LCHAN(msg->lchan, LOGL_NOTICE, "Rx IPACC DLCX IND%s",
- rsl_cause_name(&tv));
+ rsl_cause_name(&tv, NULL));
return 0;
}
diff --git a/src/osmo-bsc/assignment_fsm.c b/src/osmo-bsc/assignment_fsm.c
index c12f27b5a..f24766180 100644
--- a/src/osmo-bsc/assignment_fsm.c
+++ b/src/osmo-bsc/assignment_fsm.c
@@ -45,7 +45,7 @@ static struct osmo_fsm assignment_fsm;
struct gsm_subscriber_connection *conn = fi->priv; \
OSMO_ASSERT((fi)->fsm == &assignment_fsm && (fi)->priv)
-struct state_timeout assignment_fsm_timeouts[32] = {
+static const struct state_timeout assignment_fsm_timeouts[32] = {
[ASSIGNMENT_ST_WAIT_LCHAN_ACTIVE] = { .T=10 },
[ASSIGNMENT_ST_WAIT_RR_ASS_COMPLETE] = { .keep_timer=true },
[ASSIGNMENT_ST_WAIT_LCHAN_ESTABLISHED] = { .keep_timer=true },
@@ -346,19 +346,12 @@ void assignment_fsm_start(struct gsm_subscriber_connection *conn, struct gsm_bts
return;
}
- /* FIXME */
+ /* FIXME: send Channel Mode Modify to put the current lchan in the right mode, and kick
+ * off its RTP stream setup code path. See gsm48_lchan_modify() and
+ * gsm48_rx_rr_modif_ack(), and see lchan_fsm.h LCHAN_EV_CHAN_MODE_MODIF_* */
LOG_ASSIGNMENT(conn, LOGL_ERROR,
"NOT IMPLEMENTED:"
" Current lchan would be compatible, we should send Channel Mode Modify");
-#if 0
- case GSM48_MT_RR_CHAN_MODE_MODIF_ACK:
- rc = gsm48_rx_rr_modif_ack(msg);
- if (rc < 0)
- bsc_assign_fail(conn, GSM0808_CAUSE_NO_RADIO_RESOURCE_AVAILABLE, NULL);
- else
- bsc_assign_compl(conn, 0);
- break;
-#endif
}
conn->assignment.new_lchan = lchan_select_by_chan_mode(bts, req->chan_mode, req->full_rate);
diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c
index b9239bd92..03cde133b 100644
--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c
+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c
@@ -682,7 +682,7 @@ static void gscon_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *d
case GSCON_EV_RSL_CONN_FAIL:
if (conn->lchan) {
conn->lchan->release_in_error = true;
- conn->lchan->error_cause = data ? *(uint8_t*)data : RSL_ERR_IE_ERROR;
+ conn->lchan->rsl_error_cause = data ? *(uint8_t*)data : RSL_ERR_IE_ERROR;
}
gscon_bssmap_clear(conn, GSM0808_CAUSE_RADIO_INTERFACE_FAILURE);
break;
diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c
index fee54b78b..7477e732f 100644
--- a/src/osmo-bsc/gsm_data.c
+++ b/src/osmo-bsc/gsm_data.c
@@ -1712,7 +1712,7 @@ bool sockaddr_to_str_and_uint(char *rtp_addr, size_t rtp_addr_len, uint16_t *rtp
const struct sockaddr_in *sin;
sin = (const struct sockaddr_in *)sa;
- *rtp_port = osmo_ntohs(sin->sin_port);
+ *rtp_port = ntohs(sin->sin_port);
rc = osmo_strlcpy(rtp_addr, inet_ntoa(sin->sin_addr), rtp_addr_len);
if (rc <= 0 || rc >= rtp_addr_len)
diff --git a/src/osmo-bsc/gsm_timers.c b/src/osmo-bsc/gsm_timers.c
index 2f737934c..72cf7ef01 100644
--- a/src/osmo-bsc/gsm_timers.c
+++ b/src/osmo-bsc/gsm_timers.c
@@ -95,9 +95,9 @@ static int T_round(int val, enum T_unit from_unit, enum T_unit to_unit)
*
* val = T_def_get(global_T_defs, 99, T_S, 3); // not defined, returns 3
*/
-int T_def_get(struct T_def *T_defs, int T, enum T_unit as_unit, int val_if_not_present)
+int T_def_get(const struct T_def *T_defs, int T, enum T_unit as_unit, int val_if_not_present)
{
- struct T_def *d = T_def_get_entry(T_defs, T);
+ const struct T_def *d = T_def_get_entry((struct T_def*)T_defs, T);
if (!d) {
OSMO_ASSERT(val_if_not_present >= 0);
return val_if_not_present;
@@ -142,9 +142,10 @@ struct T_def *T_def_get_entry(struct T_def *T_defs, int T)
* The intention is then to obtain the timer like T_def_get(global_T_defs, T=235); see also
* fsm_inst_state_chg_T() below.
*/
-struct state_timeout *get_state_timeout(uint32_t state, struct state_timeout *timeouts_array)
+const struct state_timeout *get_state_timeout(uint32_t state,
+ const struct state_timeout *timeouts_array)
{
- struct state_timeout *t;
+ const struct state_timeout *t;
OSMO_ASSERT(state < 32);
t = &timeouts_array[state];
if (!t->keep_timer && !t->T)
@@ -176,11 +177,11 @@ struct state_timeout *get_state_timeout(uint32_t state, struct state_timeout *ti
*
*/
int _fsm_inst_state_chg_T(struct osmo_fsm_inst *fi, uint32_t state,
- struct state_timeout *timeouts_array,
- struct T_def *T_defs, int default_timeout,
+ const struct state_timeout *timeouts_array,
+ const struct T_def *T_defs, int default_timeout,
const char *file, int line)
{
- struct state_timeout *t = get_state_timeout(state, timeouts_array);
+ const struct state_timeout *t = get_state_timeout(state, timeouts_array);
int val;
/* No timeout defined for this state? */
diff --git a/src/osmo-bsc/handover_decision_2.c b/src/osmo-bsc/handover_decision_2.c
index 447615167..8bb7f04f8 100644
--- a/src/osmo-bsc/handover_decision_2.c
+++ b/src/osmo-bsc/handover_decision_2.c
@@ -578,7 +578,7 @@ static uint8_t check_requirements(struct gsm_lchan *lchan, struct gsm_bts *bts,
/* the maximum number of unsynchonized handovers must no be exceeded */
if (current_bts != bts
- && handover_count(bts, HO_SCOPE_ALL) >= ho_get_hodec2_ho_max(bts->ho)) {
+ && bts_handover_count(bts, HO_SCOPE_ALL) >= ho_get_hodec2_ho_max(bts->ho)) {
LOGPHOLCHANTOBTS(lchan, bts, LOGL_DEBUG,
"not a candidate, number of allowed handovers (%d) would be exceeded\n",
ho_get_hodec2_ho_max(bts->ho));
diff --git a/src/osmo-bsc/handover_fsm.c b/src/osmo-bsc/handover_fsm.c
index 3ec761eb6..5a97a79bb 100644
--- a/src/osmo-bsc/handover_fsm.c
+++ b/src/osmo-bsc/handover_fsm.c
@@ -62,7 +62,8 @@
bsc_subscr_name(conn->bsub), \
handover_scope_name(conn->ho.scope)
-/* Assume presence of local var 'conn' as struct gsm_subscriber_connection */
+/* Assume presence of local var 'conn' as struct gsm_subscriber_connection.
+ * This is a macro to preserve the source file and line number in logging. */
#define ho_count(counter) do { \
LOG_HO(conn, LOGL_DEBUG, "incrementing rate counter: %s %s", \
bsc_ctr_description[counter].name, \
@@ -146,7 +147,7 @@ static struct osmo_fsm ho_fsm;
GET_CONN(); \
struct handover *ho = &conn->ho
-struct state_timeout ho_fsm_timeouts[32] = {
+static const struct state_timeout ho_fsm_timeouts[32] = {
[HO_ST_WAIT_LCHAN_ACTIVE] = { .T = 23042 },
[HO_ST_WAIT_RR_HO_DETECT] = { .T = 23042 },
[HO_ST_WAIT_RR_HO_COMPLETE] = { .T = 23042 },
@@ -642,7 +643,6 @@ static int result_counter(enum handover_scope scope, enum handover_result result
return result_counter_INTER_BSC_HO_MO(result);
case HO_INTER_BSC_MT:
return result_counter_INTER_BSC_HO_MT(result);
- return result_counter_HANDOVER(result);
}
}
diff --git a/src/osmo-bsc/handover_logic.c b/src/osmo-bsc/handover_logic.c
index 0c6f29252..8e96ffff3 100644
--- a/src/osmo-bsc/handover_logic.c
+++ b/src/osmo-bsc/handover_logic.c
@@ -96,7 +96,7 @@ static void ho_meas_rep(struct gsm_meas_rep *mr)
/* Count ongoing handovers within the given BTS.
* ho_scopes is an OR'd combination of enum handover_scope values to include in the count. */
-int handover_count(struct gsm_bts *bts, int ho_scopes)
+int bts_handover_count(struct gsm_bts *bts, int ho_scopes)
{
struct gsm_bts_trx *trx;
int count = 0;
diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c
index 83f5b7e37..f9a778143 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -563,9 +563,9 @@ static void lchan_fsm_wait_activ_ack(struct osmo_fsm_inst *fi, uint32_t event, v
case LCHAN_EV_RSL_CHAN_ACTIV_NACK:
if (data) {
uint32_t next_state;
- lchan->error_cause = *(uint8_t*)data;
+ lchan->rsl_error_cause = *(uint8_t*)data;
lchan->release_in_error = true;
- if (lchan->error_cause != RSL_ERR_RCH_ALR_ACTV_ALLOC)
+ if (lchan->rsl_error_cause != RSL_ERR_RCH_ALR_ACTV_ALLOC)
next_state = LCHAN_ST_BORKEN;
else
/* Taking this over from legacy code: send an RF Chan Release even though
@@ -573,9 +573,9 @@ static void lchan_fsm_wait_activ_ack(struct osmo_fsm_inst *fi, uint32_t event, v
next_state = LCHAN_ST_WAIT_RF_RELEASE_ACK;
lchan_fail_to(next_state, "Chan Activ NACK: %s (0x%x)",
- rsl_err_name(lchan->error_cause), lchan->error_cause);
+ rsl_err_name(lchan->rsl_error_cause), lchan->rsl_error_cause);
} else {
- lchan->error_cause = RSL_ERR_IE_NONEXIST;
+ lchan->rsl_error_cause = RSL_ERR_IE_NONEXIST;
lchan->release_in_error = true;
lchan_fail_to(LCHAN_ST_BORKEN, "Chan Activ NACK without cause IE");
}
@@ -1063,7 +1063,7 @@ static void lchan_fsm_wait_rf_release_ack(struct osmo_fsm_inst *fi, uint32_t eve
switch (event) {
case LCHAN_EV_RSL_RF_CHAN_REL_ACK:
- if (lchan->error_cause)
+ if (lchan->rsl_error_cause)
lchan_fsm_state_chg(LCHAN_ST_WAIT_AFTER_ERROR);
else
lchan_fsm_state_chg(LCHAN_ST_UNUSED);
@@ -1383,7 +1383,7 @@ void lchan_release(struct gsm_lchan *lchan, bool sacch_deact,
return;
struct osmo_fsm_inst *fi = lchan->fi;
lchan->release_in_error = err;
- lchan->error_cause = cause_rr;
+ lchan->rsl_error_cause = cause_rr;
lchan->deact_sacch = sacch_deact;
/* This would also happen later, but better to do this a sooner. */
diff --git a/src/osmo-bsc/mgw_endpoint_fsm.c b/src/osmo-bsc/mgw_endpoint_fsm.c
index 14d0b03b0..1095628ac 100644
--- a/src/osmo-bsc/mgw_endpoint_fsm.c
+++ b/src/osmo-bsc/mgw_endpoint_fsm.c
@@ -371,7 +371,7 @@ bool mgwep_ci_get_crcx_info_to_sockaddr(const struct mgwep_ci *ci, struct sockad
}
-struct state_timeout mgwep_fsm_timeouts[32] = {
+static const struct state_timeout mgwep_fsm_timeouts[32] = {
[MGWEP_ST_WAIT_MGW_RESPONSE] = { .T=23042 },
};
@@ -681,7 +681,7 @@ static const struct osmo_fsm_state mgwep_fsm_states[] = {
},
};
-int mgwep_fsm_timer_cb(struct osmo_fsm_inst *fi)
+static int mgwep_fsm_timer_cb(struct osmo_fsm_inst *fi)
{
int i;
GET_MGWEP();
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index 1a271e78b..b1850debc 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -754,7 +754,8 @@ static int bssmap_handle_handover_cmd(struct gsm_subscriber_connection *conn,
struct tlv_parsed tp;
if (!conn->ho.fi) {
- LOGP(DMSC, LOGL_ERROR, "Received Handover Command, but no handover was requested");
+ LOGPFSML(conn->fi, LOGL_ERROR,
+ "Received Handover Command, but no handover was requested");
/* Should we actually allow the MSC to make us handover without us having requested it
* first? Doesn't make any practical sense AFAICT. */
return -EINVAL;
@@ -764,7 +765,9 @@ static int bssmap_handle_handover_cmd(struct gsm_subscriber_connection *conn,
/* Check for channel type element, if its missing, immediately reject */
if (!TLVP_PRESENT(&tp, GSM0808_IE_LAYER_3_INFORMATION)) {
- LOGP(DMSC, LOGL_ERROR, "Mandatory IE not present: Layer 3 Information\n");
+ LOGPFSML(conn->fi, LOGL_ERROR,
+ "Received Handover Command,"
+ " but mandatory IE not present: Layer 3 Information\n");
goto reject;
}