diff options
-rw-r--r-- | include/osmocom/bsc/lchan_select.h | 1 | ||||
-rw-r--r-- | src/osmo-bsc/bsc_vty.c | 8 | ||||
-rw-r--r-- | src/osmo-bsc/lchan_select.c | 22 |
3 files changed, 21 insertions, 10 deletions
diff --git a/include/osmocom/bsc/lchan_select.h b/include/osmocom/bsc/lchan_select.h index aa2f40ec8..3bb0d1ce6 100644 --- a/include/osmocom/bsc/lchan_select.h +++ b/include/osmocom/bsc/lchan_select.h @@ -6,3 +6,4 @@ enum gsm_chan_t chan_mode_to_chan_type(enum gsm48_chan_mode chan_mode, enum chan struct gsm_lchan *lchan_select_by_chan_mode(struct gsm_bts *bts, enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate); struct gsm_lchan *lchan_avail_by_type(struct gsm_bts *bts, enum gsm_chan_t type, bool log); +void lchan_select_set_type(struct gsm_lchan *lchan, enum gsm_chan_t type); diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c index d76d02d82..9b6fa629d 100644 --- a/src/osmo-bsc/bsc_vty.c +++ b/src/osmo-bsc/bsc_vty.c @@ -6299,7 +6299,7 @@ static int lchan_act_single(struct vty *vty, struct gsm_lchan *lchan, const char } /* configure the lchan */ - lchan->type = lchan_t; + lchan_select_set_type(lchan, lchan_t); if (!strcmp(codec_str, "hr") || !strcmp(codec_str, "fr")) { info = (struct lchan_activate_info) { .activ_for = ACTIVATE_FOR_VTY, @@ -6792,9 +6792,9 @@ DEFUN(lchan_reassign, lchan_reassign_cmd, return CMD_WARNING; } - /* lchan_select_*() sets the lchan->type, we need to do the same here, so that activation will work out. */ - to_lchan->type = chan_mode_to_chan_type(from_lchan->current_ch_mode_rate.chan_mode, - from_lchan->current_ch_mode_rate.chan_rate); + /* Set lchan type, so that activation will work out. */ + lchan_select_set_type(to_lchan, chan_mode_to_chan_type(from_lchan->current_ch_mode_rate.chan_mode, + from_lchan->current_ch_mode_rate.chan_rate)); LOG_LCHAN(from_lchan, LOGL_NOTICE, "VTY requests re-assignment of this lchan to %s%s\n", gsm_lchan_name(to_lchan), to_lchan->vamos.is_secondary ? " (to VAMOS mode)" : ""); diff --git a/src/osmo-bsc/lchan_select.c b/src/osmo-bsc/lchan_select.c index 3618fb4e8..022d51647 100644 --- a/src/osmo-bsc/lchan_select.c +++ b/src/osmo-bsc/lchan_select.c @@ -296,16 +296,26 @@ struct gsm_lchan *lchan_select_by_type(struct gsm_bts *bts, enum gsm_chan_t type { struct gsm_lchan *lchan = NULL; - lchan = lchan_avail_by_type(bts, type, true); - LOG_BTS(bts, DRLL, LOGL_DEBUG, "lchan_select_by_type(%s)\n", gsm_lchant_name(type)); - if (lchan) { - lchan->type = type; - LOG_LCHAN(lchan, LOGL_INFO, "Selected\n"); - } else + lchan = lchan_avail_by_type(bts, type, true); + + if (!lchan) { LOG_BTS(bts, DRLL, LOGL_NOTICE, "Failed to select %s channel\n", gsm_lchant_name(type)); + return NULL; + } + lchan_select_set_type(lchan, type); return lchan; } + +/* Set available lchan to given type. Usually used on lchan obtained with + * lchan_avail_by_type. The next logical step is lchan_activate() on it, which + * would possibly cause dynamic timeslot pchan switching, taken care of by the + * lchan and timeslot FSMs. */ +void lchan_select_set_type(struct gsm_lchan *lchan, enum gsm_chan_t type) +{ + lchan->type = type; + LOG_LCHAN(lchan, LOGL_INFO, "Selected\n"); +} |