Convert e1inp_{sign,ts}type_name() to use struct value_string
Change-Id: I0546c3f5aefe5e1cc33d8d82f1783fa467e37ff0
diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h
index c175649..8ef33d5 100644
--- a/include/osmocom/abis/e1_input.h
+++ b/include/osmocom/abis/e1_input.h
@@ -21,6 +21,7 @@
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 @@
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 {
diff --git a/src/e1_input.c b/src/e1_input.c
index c9ae8e6..df990d5 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -200,30 +200,29 @@
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)