From 2577d415269085d71fff62aead723c7d28522645 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 2 May 2010 09:37:45 +0200 Subject: [gprs] convert ns_cause_str to value_string --- openbsc/src/gprs_ns.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'openbsc/src') diff --git a/openbsc/src/gprs_ns.c b/openbsc/src/gprs_ns.c index 18d189f5..7f94b97b 100644 --- a/openbsc/src/gprs_ns.c +++ b/openbsc/src/gprs_ns.c @@ -124,29 +124,24 @@ static struct gprs_nsvc *nsvc_create(struct gprs_ns_inst *nsi, u_int16_t nsvci) } /* Section 10.3.2, Table 13 */ -static const char *ns_cause_str[] = { - [NS_CAUSE_TRANSIT_FAIL] = "Transit network failure", - [NS_CAUSE_OM_INTERVENTION] = "O&M intervention", - [NS_CAUSE_EQUIP_FAIL] = "Equipment failure", - [NS_CAUSE_NSVC_BLOCKED] = "NS-VC blocked", - [NS_CAUSE_NSVC_UNKNOWN] = "NS-VC unknown", - [NS_CAUSE_BVCI_UNKNOWN] = "BVCI unknown", - [NS_CAUSE_SEM_INCORR_PDU] = "Semantically incorrect PDU", - [NS_CAUSE_PDU_INCOMP_PSTATE] = "PDU not compatible with protocol state", - [NS_CAUSE_PROTO_ERR_UNSPEC] = "Protocol error, unspecified", - [NS_CAUSE_INVAL_ESSENT_IE] = "Invalid essential IE", - [NS_CAUSE_MISSING_ESSENT_IE] = "Missing essential IE", +static const struct value_string ns_cause_str[] = { + { NS_CAUSE_TRANSIT_FAIL, "Transit network failure" }, + { NS_CAUSE_OM_INTERVENTION, "O&M intervention" }, + { NS_CAUSE_EQUIP_FAIL, "Equipment failure" }, + { NS_CAUSE_NSVC_BLOCKED, "NS-VC blocked" }, + { NS_CAUSE_NSVC_UNKNOWN, "NS-VC unknown" }, + { NS_CAUSE_BVCI_UNKNOWN, "BVCI unknown" }, + { NS_CAUSE_SEM_INCORR_PDU, "Semantically incorrect PDU" }, + { NS_CAUSE_PDU_INCOMP_PSTATE, "PDU not compatible with protocol state" }, + { NS_CAUSE_PROTO_ERR_UNSPEC, "Protocol error }, unspecified" }, + { NS_CAUSE_INVAL_ESSENT_IE, "Invalid essential IE" }, + { NS_CAUSE_MISSING_ESSENT_IE, "Missing essential IE" }, + { 0, NULL } }; -static const char *gprs_ns_cause_str(enum ns_cause cause) +const char *gprs_ns_cause_str(enum ns_cause cause) { - if (cause >= ARRAY_SIZE(ns_cause_str)) - return "undefined"; - - if (ns_cause_str[cause]) - return ns_cause_str[cause]; - - return "undefined"; + return get_value_string(ns_cause_str, cause); } static int nsip_sendmsg(struct gprs_nsvc *nsvc, struct msgb *msg); -- cgit v1.2.3