Convert e1inp_{sign,ts}type_name() to use struct value_string

Change-Id: I0546c3f5aefe5e1cc33d8d82f1783fa467e37ff0
This commit is contained in:
Harald Welte 2016-07-27 23:05:03 +02:00
parent f35d8898ab
commit 4ca5c53f7f
2 changed files with 16 additions and 15 deletions

View File

@ -21,6 +21,7 @@ enum e1inp_sign_type {
E1INP_SIGN_OSMO, /* IPA CCM OSMO sub-type */
};
const char *e1inp_signtype_name(enum e1inp_sign_type tp);
const struct value_string e1inp_sign_type_names[5];
enum e1inp_ctr {
E1I_CTR_HDLC_ABORT,
@ -65,6 +66,7 @@ enum e1inp_ts_type {
E1INP_TS_TYPE_TRAU,
};
const char *e1inp_tstype_name(enum e1inp_ts_type tp);
const struct value_string e1inp_ts_type_names[5];
/* A timeslot in the E1 interface */
struct e1inp_ts {

View File

@ -200,30 +200,29 @@ static void write_pcap_packet(int direction, int sapi, int tei,
write(pcap_fd, msg->l2h, msgb_l2len(msg));
}
static const char *sign_types[] = {
[E1INP_SIGN_NONE] = "None",
[E1INP_SIGN_OML] = "OML",
[E1INP_SIGN_RSL] = "RSL",
[E1INP_SIGN_OSMO] = "OSMO",
const struct value_string e1inp_sign_type_names[5] = {
{ E1INP_SIGN_NONE, "None" },
{ E1INP_SIGN_OML, "OML" },
{ E1INP_SIGN_RSL, "RSL" },
{ E1INP_SIGN_OSMO, "OSMO" },
{ 0, NULL }
};
const char *e1inp_signtype_name(enum e1inp_sign_type tp)
{
if (tp >= ARRAY_SIZE(sign_types))
return "undefined";
return sign_types[tp];
return get_value_string(e1inp_sign_type_names, tp);
}
static const char *ts_types[] = {
[E1INP_TS_TYPE_NONE] = "None",
[E1INP_TS_TYPE_SIGN] = "Signalling",
[E1INP_TS_TYPE_TRAU] = "TRAU",
const struct value_string e1inp_ts_type_names[5] = {
{ E1INP_TS_TYPE_NONE, "None" },
{ E1INP_TS_TYPE_SIGN, "Signalling" },
{ E1INP_TS_TYPE_TRAU, "TRAU" },
{ 0, NULL }
};
const char *e1inp_tstype_name(enum e1inp_ts_type tp)
{
if (tp >= ARRAY_SIZE(ts_types))
return "undefined";
return ts_types[tp];
return get_value_string(e1inp_ts_type_names, tp);
}
int abis_sendmsg(struct msgb *msg)