aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-05-02 09:37:45 +0200
committerHarald Welte <laforge@gnumonks.org>2010-05-04 07:20:43 +0200
commit345223ee9e48a5490bac7db9a0b54a3639b2e332 (patch)
treedacd1d87ca6e23e25654359f505b48692b5f96fe
parentdbab1c79e7cb8e2c5141f20b6b9ef4a52f33ab40 (diff)
[gprs] convert ns_cause_str to value_string
-rw-r--r--openbsc/src/gprs_ns.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/openbsc/src/gprs_ns.c b/openbsc/src/gprs_ns.c
index 18d189f5a..7f94b97b1 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);