diff options
author | Harald Welte <laforge@gnumonks.org> | 2016-07-27 23:05:03 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-10-16 22:14:08 +0000 |
commit | 4ca5c53f7fd67a752512b33d8bbac30711c23866 (patch) | |
tree | 98a2df21eacf0783fdd7e9af2b503179f9c4db0f | |
parent | e1_input: Add E1 timeslot number to input_signal_data (diff) | |
download | libosmo-abis-4ca5c53f7fd67a752512b33d8bbac30711c23866.tar.xz libosmo-abis-4ca5c53f7fd67a752512b33d8bbac30711c23866.zip |
Convert e1inp_{sign,ts}type_name() to use struct value_string
Change-Id: I0546c3f5aefe5e1cc33d8d82f1783fa467e37ff0
-rw-r--r-- | include/osmocom/abis/e1_input.h | 2 | ||||
-rw-r--r-- | src/e1_input.c | 29 |
2 files changed, 16 insertions, 15 deletions
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 @@ 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 { 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 @@ 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) |