Use libosmocore available API to get value_list

This API has been available since 1.0.0, and we actually require
libosmocore >= 1.7.0 nowadays, so it's totally fine using the
libosmocore API and drops the local duplicate.

Change-Id: I95c59b31cf1b08e1d513b589ef386d2dd55f09a2
changes/78/28978/4
Pau Espin 2022-08-08 15:07:35 +02:00 committed by pespin
parent 842592c529
commit 742bb99ed9
15 changed files with 40 additions and 47 deletions

View File

@ -622,7 +622,7 @@ struct gsm_encr {
LOGP(ss, level, "%s (ss=%d,%s) (%s) " fmt, \
lchan ? gsm_ts_and_pchan_name(lchan->ts) : "-", \
lchan ? lchan->nr : 0, \
lchan ? gsm_lchant_name(lchan->type) : "-", \
lchan ? gsm_chan_t_name(lchan->type) : "-", \
bsc_subscr_name(lchan && lchan->conn ? lchan->conn->bsub : NULL), \
## args)
@ -1148,7 +1148,6 @@ const char *gsm_pchan_name(enum gsm_phys_chan_config c);
static inline const char *gsm_pchan_id(enum gsm_phys_chan_config c)
{ return get_value_string(gsm_pchan_ids, c); }
enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
const char *gsm_lchant_name(enum gsm_chan_t c);
const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);

View File

@ -7,7 +7,7 @@
/* This macro automatically includes a final \n, if omitted. */
#define LOG_LCHAN(lchan, level, fmt, args...) do { \
if ((lchan)->fi) \
LOGPFSML((lchan)->fi, level, "(type=%s) " fmt, gsm_lchant_name((lchan)->type), ## args); \
LOGPFSML((lchan)->fi, level, "(type=%s) " fmt, gsm_chan_t_name((lchan)->type), ## args); \
else \
LOGP(DRSL, level, "%s (not initialized) " fmt, gsm_lchan_name(lchan), ## args); \
} while (0)

View File

@ -439,7 +439,7 @@ static int channel_mode_from_lchan(struct rsl_ie_chan_mode *cm,
default:
LOGP(DRSL, LOGL_ERROR,
"unsupported activation lchan->type %u %s\n",
lchan->type, gsm_lchant_name(lchan->type));
lchan->type, gsm_chan_t_name(lchan->type));
return -EINVAL;
}
@ -2095,7 +2095,7 @@ struct gsm_lchan *_select_sdcch_for_call(struct gsm_bts *bts, const struct chan_
if (free_tchf == 0 && free_tchh == 0) {
LOG_BTS(bts, DRSL, LOGL_INFO,
"CHAN RQD: 0x%x Requesting %s reason=call but no TCH available\n",
rqd->ref.ra, gsm_lchant_name(lctype));
rqd->ref.ra, gsm_chan_t_name(lctype));
return NULL;
}
@ -2124,7 +2124,7 @@ struct gsm_lchan *_select_sdcch_for_call(struct gsm_bts *bts, const struct chan_
LOG_BTS(bts, DRSL, LOGL_INFO,
"CHAN RQD: 0x%x Requesting %s reason=call but dyn TS switch to "
"SDCCH would starve the single available TCH timeslot\n",
rqd->ref.ra, gsm_lchant_name(lctype));
rqd->ref.ra, gsm_chan_t_name(lctype));
return NULL;
}
@ -2187,16 +2187,16 @@ void abis_rsl_chan_rqd_queue_poll(struct gsm_bts *bts)
rqd->reason == GSM_CHREQ_REASON_EMERG)) {
if (!lchan) {
LOG_BTS(bts, DRSL, LOGL_NOTICE, "CHAN RQD[%s]: no resources for %s 0x%x, retrying with %s\n",
get_value_string(gsm_chreq_descs, rqd->reason), gsm_lchant_name(GSM_LCHAN_SDCCH),
rqd->ref.ra, gsm_lchant_name(GSM_LCHAN_TCH_H));
get_value_string(gsm_chreq_descs, rqd->reason), gsm_chan_t_name(GSM_LCHAN_SDCCH),
rqd->ref.ra, gsm_chan_t_name(GSM_LCHAN_TCH_H));
lchan = lchan_select_by_type(bts, GSM_LCHAN_TCH_H,
SELECT_FOR_MS_CHAN_REQ,
NULL);
}
if (!lchan) {
LOG_BTS(bts, DRSL, LOGL_NOTICE, "CHAN RQD[%s]: no resources for %s 0x%x, retrying with %s\n",
get_value_string(gsm_chreq_descs, rqd->reason), gsm_lchant_name(GSM_LCHAN_SDCCH),
rqd->ref.ra, gsm_lchant_name(GSM_LCHAN_TCH_F));
get_value_string(gsm_chreq_descs, rqd->reason), gsm_chan_t_name(GSM_LCHAN_SDCCH),
rqd->ref.ra, gsm_chan_t_name(GSM_LCHAN_TCH_F));
lchan = lchan_select_by_type(bts, GSM_LCHAN_TCH_F,
SELECT_FOR_MS_CHAN_REQ,
NULL);
@ -2204,7 +2204,7 @@ void abis_rsl_chan_rqd_queue_poll(struct gsm_bts *bts)
}
if (!lchan) {
LOG_BTS(bts, DRSL, LOGL_NOTICE, "CHAN RQD[%s]: no resources for %s 0x%x\n",
get_value_string(gsm_chreq_descs, rqd->reason), gsm_lchant_name(lctype), rqd->ref.ra);
get_value_string(gsm_chreq_descs, rqd->reason), gsm_chan_t_name(lctype), rqd->ref.ra);
rate_ctr_inc(rate_ctr_group_get_ctr(bts->bts_ctrs, BTS_CTR_CHREQ_NO_CHANNEL));
rsl_tx_imm_ass_rej(bts, &rqd->ref);
llist_del(&rqd->entry);

View File

@ -190,7 +190,7 @@ static void send_assignment_complete(struct gsm_subscriber_connection *conn)
assignment_fail(GSM0808_CAUSE_EQUIPMENT_FAILURE,
"Unable to compose Chosen Channel for mode=%s type=%s",
get_value_string(gsm48_chan_mode_names, lchan->current_ch_mode_rate.chan_mode),
gsm_lchant_name(lchan->type));
gsm_chan_t_name(lchan->type));
return;
}
@ -597,7 +597,7 @@ void assignment_fsm_start(struct gsm_subscriber_connection *conn, struct gsm_bts
"Assignment of lchan %s to %s type %s requested, but lchan is not compatible",
gsm_lchan_name(conn->lchan),
gsm_lchan_name(req->target_lchan),
gsm_lchant_name(conn->assignment.new_lchan->type));
gsm_chan_t_name(conn->assignment.new_lchan->type));
return;
}
} else {

View File

@ -775,7 +775,7 @@ static int trigger_as(struct vty *vty, struct gsm_lchan *from_lchan, struct gsm_
SELECT_FOR_ASSIGNMENT,
from_lchan);
vty_out(vty, "Error: cannot find free lchan of type %s%s",
gsm_lchant_name(from_lchan->type), VTY_NEWLINE);
gsm_chan_t_name(from_lchan->type), VTY_NEWLINE);
}
if (reassignment_request_to_lchan(ASSIGN_FOR_VTY, from_lchan, to_lchan, -1, -1)) {
vty_out(vty, "Error: not allowed to start assignment for %s%s",
@ -965,13 +965,13 @@ static struct gsm_bts *find_other_bts_with_free_slots(struct vty *vty, struct gs
continue;
vty_out(vty, "Found unused %s slot: %s%s",
gsm_lchant_name(free_type), gsm_lchan_name(lchan), VTY_NEWLINE);
gsm_chan_t_name(free_type), gsm_lchan_name(lchan), VTY_NEWLINE);
lchan_dump_full_vty(vty, lchan);
return bts;
}
}
vty_out(vty, "%% Cannot find any BTS (other than BTS %u) with free %s lchan%s",
not_this_bts? not_this_bts->nr : 255, gsm_lchant_name(free_type), VTY_NEWLINE);
not_this_bts ? not_this_bts->nr : 255, gsm_chan_t_name(free_type), VTY_NEWLINE);
return NULL;
}

View File

@ -568,7 +568,7 @@ void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u: Type %s%s",
lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
lchan->nr, gsm_chan_t_name(lchan->type), VTY_NEWLINE);
if (lchan->activate.concluded) {
vty_out(vty, " Active for: %s seconds%s",
@ -661,7 +661,7 @@ void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
}
vty_out(vty, ", Type %s%s TSC-s%dc%u, State %s - L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
gsm_lchant_name(lchan->type),
gsm_chan_t_name(lchan->type),
lchan->vamos.enabled ? " (VAMOS)" : "",
lchan->tsc_set > 0 ? lchan->tsc_set : 1,
lchan->tsc,

View File

@ -101,7 +101,7 @@ int chan_counts_to_str_buf(char *buf, size_t buflen, const struct chan_counts *c
OSMO_STRBUF_PRINTF(sb, " %s.%s{", chan_counts_dim1_name[i1],
chan_counts_dim2_name[i2]);
}
OSMO_STRBUF_PRINTF(sb, " %s=%d", gsm_lchant_name(i3), v);
OSMO_STRBUF_PRINTF(sb, " %s=%d", gsm_chan_t_name(i3), v);
}
}

View File

@ -235,12 +235,6 @@ enum gsm_phys_chan_config gsm_pchan_parse(const char *name)
return get_string_value(gsm_pchant_names, name);
}
/* TODO: move to libosmocore, next to gsm_chan_t_names? */
const char *gsm_lchant_name(enum gsm_chan_t c)
{
return get_value_string(gsm_chan_t_names, c);
}
static const struct value_string chreq_names[] = {
{ GSM_CHREQ_REASON_EMERG, "EMERGENCY" },
{ GSM_CHREQ_REASON_PAG, "PAGING" },

View File

@ -53,7 +53,7 @@
lchan->ts->trx->nr, \
lchan->ts->nr, \
lchan->nr, \
gsm_lchant_name(lchan->type), \
gsm_chan_t_name(lchan->type), \
gsm48_chan_mode_name(lchan->current_ch_mode_rate.chan_mode), \
bsc_subscr_name(lchan->conn? lchan->conn->bsub : NULL), \
## args)
@ -64,7 +64,7 @@
lchan->ts->trx->nr, \
lchan->ts->nr, \
lchan->nr, \
gsm_lchant_name(lchan->type), \
gsm_chan_t_name(lchan->type), \
gsm48_chan_mode_name(lchan->current_ch_mode_rate.chan_mode), \
new_bts->nr, \
bsc_subscr_name(lchan->conn? lchan->conn->bsub : NULL), \
@ -76,7 +76,7 @@
lchan->ts->trx->nr, \
lchan->ts->nr, \
lchan->nr, \
gsm_lchant_name(lchan->type), \
gsm_chan_t_name(lchan->type), \
gsm48_chan_mode_name(lchan->current_ch_mode_rate.chan_mode), \
gsm0808_cell_id_list_name(remote_cil), \
bsc_subscr_name(lchan->conn? lchan->conn->bsub : NULL), \
@ -519,7 +519,7 @@ static void check_requirements(struct ho_candidate *c)
"tch_mode='%s' type='%s' not supported\n",
get_value_string(gsm48_chan_mode_names,
c->current.lchan->current_ch_mode_rate.chan_mode),
gsm_lchant_name(c->current.lchan->type));
gsm_chan_t_name(c->current.lchan->type));
break;
}
if (codec_type_is_supported(c->current.lchan->conn, GSM0808_SCT_HR1))

View File

@ -60,7 +60,7 @@
lchan ? lchan->ts->trx->bts->nr : 0, \
lchan ? lchan->ts->trx->nr : 0, \
lchan ? lchan->ts->nr : 0, \
lchan ? gsm_lchant_name(lchan->type) : "?", \
lchan ? gsm_chan_t_name(lchan->type) : "?", \
lchan ? lchan->nr : 0, \
lchan ? gsm48_chan_mode_name(lchan->current_ch_mode_rate.chan_mode) : "?"
@ -138,7 +138,7 @@ const char *handover_status(struct gsm_subscriber_connection *conn)
"("LOG_FMT_FROM_LCHAN") --HO-> ("LOG_FMT_BTS",%s) " LOG_FMT_HO_SCOPE,
LOG_ARGS_FROM_LCHAN(conn->lchan),
LOG_ARGS_BTS(ho->new_bts),
gsm_lchant_name(ho->new_lchan_type),
gsm_chan_t_name(ho->new_lchan_type),
LOG_ARGS_HO_SCOPE(conn));
else
snprintf(buf, sizeof(buf),
@ -167,14 +167,14 @@ const char *handover_status(struct gsm_subscriber_connection *conn)
ho->inter_bsc_in.cell_id_serving_name,
ho->inter_bsc_in.cell_id_target_name,
LOG_ARGS_BTS(ho->new_bts),
gsm_lchant_name(ho->new_lchan_type),
gsm_chan_t_name(ho->new_lchan_type),
LOG_ARGS_HO_SCOPE(conn));
else
snprintf(buf, sizeof(buf),
"(remote:%s) --HO-> (local:%s,%s) " LOG_FMT_HO_SCOPE,
ho->inter_bsc_in.cell_id_serving_name,
ho->inter_bsc_in.cell_id_target_name,
gsm_lchant_name(ho->new_lchan_type),
gsm_chan_t_name(ho->new_lchan_type),
LOG_ARGS_HO_SCOPE(conn));
} else
snprintf(buf, sizeof(buf), LOG_FMT_HO_SCOPE, LOG_ARGS_HO_SCOPE(conn));
@ -396,7 +396,7 @@ static void handover_start_intra_bsc(struct gsm_subscriber_connection *conn)
if (!ho->new_lchan) {
ho_fail(HO_RESULT_FAIL_NO_CHANNEL,
"No %s lchan available on BTS %u",
gsm_lchant_name(ho->new_lchan_type), ho->new_bts->nr);
gsm_chan_t_name(ho->new_lchan_type), ho->new_bts->nr);
return;
}
LOG_HO(conn, LOGL_DEBUG, "Selected lchan %s\n", gsm_lchan_name(ho->new_lchan));

View File

@ -770,7 +770,7 @@ static void lchan_fsm_wait_ts_ready_onenter(struct osmo_fsm_inst *fi, uint32_t p
lchan->activate.info.requires_voice_stream ?
(use_mgwep_ci ? osmo_mgcpc_ep_ci_name(use_mgwep_ci) : "new")
: "none",
gsm_lchant_name(lchan->type),
gsm_chan_t_name(lchan->type),
gsm48_chan_mode_name(lchan->activate.ch_mode_rate.chan_mode),
lchan->activate.info.encr.alg_a5_n,
lchan->activate.info.encr.key_len ? osmo_hexdump_nospc(lchan->activate.info.encr.key,
@ -1309,7 +1309,7 @@ static void lchan_fsm_established(struct osmo_fsm_inst *fi, uint32_t event, void
lchan->modify.info.requires_voice_stream ?
(use_mgwep_ci ? osmo_mgcpc_ep_ci_name(use_mgwep_ci) : "new")
: "none",
gsm_lchant_name(lchan->type),
gsm_chan_t_name(lchan->type),
gsm48_chan_mode_name(lchan->modify.ch_mode_rate.chan_mode),
lchan->modify.tsc_set, lchan->modify.tsc);

View File

@ -272,7 +272,7 @@ static void lchan_rtp_fsm_wait_ipacc_crcx_ack_onenter(struct osmo_fsm_inst *fi,
if (val < 0) {
lchan_rtp_fail("Cannot determine Abis/IP speech mode for tch_mode=%s type=%s",
get_value_string(gsm48_chan_mode_names, lchan->activate.ch_mode_rate.chan_mode),
gsm_lchant_name(lchan->type));
gsm_chan_t_name(lchan->type));
return;
}
lchan->abis_ip.speech_mode = val;
@ -281,7 +281,7 @@ static void lchan_rtp_fsm_wait_ipacc_crcx_ack_onenter(struct osmo_fsm_inst *fi,
if (val < 0) {
lchan_rtp_fail("Cannot determine Abis/IP payload type for tch_mode=%s type=%s",
get_value_string(gsm48_chan_mode_names, lchan->activate.ch_mode_rate.chan_mode),
gsm_lchant_name(lchan->type));
gsm_chan_t_name(lchan->type));
return;
}
lchan->abis_ip.rtp_payload = val;
@ -848,7 +848,7 @@ void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *l
if (codec < 0) {
LOG_LCHAN(lchan, LOGL_ERROR,
"Unable to determine MGCP codec type for %s in chan-mode %s\n",
gsm_lchant_name(lchan->type), gsm48_chan_mode_name(lchan->activate.ch_mode_rate.chan_mode));
gsm_chan_t_name(lchan->type), gsm48_chan_mode_name(lchan->activate.ch_mode_rate.chan_mode));
verb_info->codecs_len = 0;
return;
}

View File

@ -101,7 +101,7 @@ static struct gsm_lchan *_lc_find(struct lchan_select_ts_list *ts_list,
if (lchan->fi->state != LCHAN_ST_UNUSED) {
LOGPLCHANALLOC("%s ss=%d in type=%s,state=%s not suitable\n",
gsm_ts_and_pchan_name(ts), lchan->nr,
gsm_lchant_name(lchan->type),
gsm_chan_t_name(lchan->type),
osmo_fsm_inst_state_name(lchan->fi));
continue;
}
@ -327,7 +327,7 @@ struct gsm_lchan *lchan_avail_by_type(struct gsm_bts *bts,
if (log) {
LOG_BTS(bts, DRLL, LOGL_DEBUG, "lchan_avail_by_type(type=%s, reason=%s)\n",
gsm_lchant_name(type), lchan_select_reason_name(reason));
gsm_chan_t_name(type), lchan_select_reason_name(reason));
}
switch (reason) {
@ -422,13 +422,13 @@ struct gsm_lchan *lchan_select_by_type(struct gsm_bts *bts,
struct gsm_lchan *lchan = NULL;
LOG_BTS(bts, DRLL, LOGL_DEBUG, "lchan_select_by_type(type=%s, reason=%s)\n",
gsm_lchant_name(type), lchan_select_reason_name(reason));
gsm_chan_t_name(type), lchan_select_reason_name(reason));
lchan = lchan_avail_by_type(bts, type, reason, ctx, true);
if (!lchan) {
LOG_BTS(bts, DRLL, LOGL_NOTICE, "Failed to select %s channel (%s)\n",
gsm_lchant_name(type), lchan_select_reason_name(reason));
gsm_chan_t_name(type), lchan_select_reason_name(reason));
return NULL;
}

View File

@ -633,7 +633,7 @@ static void ts_fsm_in_use_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
if (!ok && lchan_state_is(lchan, LCHAN_ST_WAIT_TS_READY)) {
LOG_TS(ts, LOGL_ERROR, "lchan activation of %s is not permitted for %s (%s)\n",
gsm_lchant_name(lchan->type), gsm_pchan_name(ts->pchan_on_init),
gsm_chan_t_name(lchan->type), gsm_pchan_name(ts->pchan_on_init),
gsm_lchan_name(lchan));
lchan_dispatch(lchan, LCHAN_EV_TS_ERROR);
}
@ -645,7 +645,7 @@ static void ts_fsm_in_use_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
activating_type = lchan->type;
else if (activating_type != lchan->type) {
LOG_TS(ts, LOGL_ERROR, "lchan type %s mismatches %s (%s)\n",
gsm_lchant_name(lchan->type), gsm_lchant_name(activating_type),
gsm_chan_t_name(lchan->type), gsm_chan_t_name(activating_type),
gsm_lchan_name(lchan));
lchan_dispatch(lchan, LCHAN_EV_TS_ERROR);
}
@ -664,7 +664,7 @@ static void ts_fsm_in_use_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
break;
default:
LOG_TS(ts, LOGL_ERROR, "cannot use timeslot as %s\n", gsm_lchant_name(activating_type));
LOG_TS(ts, LOGL_ERROR, "cannot use timeslot as %s\n", gsm_chan_t_name(activating_type));
ts_lchans_dispatch(ts, LCHAN_ST_WAIT_TS_READY, LCHAN_EV_TS_ERROR);
break;
}

View File

@ -99,7 +99,7 @@ static void print_chan_info_json(struct meas_feed_meas *mfm)
{
printf("\"lchan_type\":\"%s\", \"pchan_type\":\"%s\", "
"\"bts_nr\":%d, \"trx_nr\":%d, \"ts_nr\":%d, \"ss_nr\":%d",
gsm_lchant_name(mfm->lchan_type), gsm_pchan_name(mfm->pchan_type),
gsm_chan_t_name(mfm->lchan_type), gsm_pchan_name(mfm->pchan_type),
mfm->bts_nr, mfm->trx_nr, mfm->ts_nr, mfm->ss_nr);
}