neels has uploaded this change for review.
add ranap_domain_name()
As simple as it may seem, turning the RANAP CS/PS domain indicator to a
string so far is cumbersome. It is usually only CS or PS, but to be
accurate we should also expect invalid values. After the umpteenth
switch statement breaking up otherwise trivial code, I decided that yes,
after all, a value_string[] is a good idea even for just two enum values
that have only two-letter names.
Callers will follow in upcoming patches.
Related: SYS#6412
Change-Id: Ib3c5d772ccea8c854eec007de5c996d1b6640bc0
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/hnbgw.c
M src/osmo-hnbgw/hnbgw_rua.c
3 files changed, 32 insertions(+), 13 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/74/33174/1
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index 90aee5b..3e1b6a4 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -36,6 +36,12 @@
#define DOMAIN_CS RANAP_CN_DomainIndicator_cs_domain
#define DOMAIN_PS RANAP_CN_DomainIndicator_ps_domain
+extern const struct value_string ranap_domain_names[];
+static inline const char *ranap_domain_name(RANAP_CN_DomainIndicator_t domain)
+{
+ return get_value_string(ranap_domain_names, domain);
+}
+
enum hnb_ctrl_node {
CTRL_NODE_HNB = _LAST_CTRL_NODE,
_LAST_CTRL_NODE_HNB
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index dfeda53..fdd6a86 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -41,6 +41,12 @@
struct hnbgw *g_hnbgw = NULL;
+const struct value_string ranap_domain_names[] = {
+ { DOMAIN_CS, "CS" },
+ { DOMAIN_PS, "PS" },
+ {}
+};
+
void g_hnbgw_alloc(void *ctx)
{
OSMO_ASSERT(!g_hnbgw);
diff --git a/src/osmo-hnbgw/hnbgw_rua.c b/src/osmo-hnbgw/hnbgw_rua.c
index 4e75c91..87563bf 100644
--- a/src/osmo-hnbgw/hnbgw_rua.c
+++ b/src/osmo-hnbgw/hnbgw_rua.c
@@ -42,18 +42,6 @@
#include <osmocom/hnbap/HNBAP_CN-DomainIndicator.h>
#include <osmocom/ranap/ranap_ies_defs.h>
-static const char *cn_domain_indicator_to_str(RUA_CN_DomainIndicator_t cN_DomainIndicator)
-{
- switch (cN_DomainIndicator) {
- case RUA_CN_DomainIndicator_cs_domain:
- return "IuCS";
- case RUA_CN_DomainIndicator_ps_domain:
- return "IuPS";
- default:
- return "(unknown-domain)";
- }
-}
-
static int hnbgw_rua_tx(struct hnb_context *ctx, struct msgb *msg)
{
if (!msg)
@@ -373,7 +361,7 @@
context_id = asn1bitstr_to_u24(&ies.context_ID);
LOGHNB(hnb, DRUA, LOGL_DEBUG, "RUA %s Connect.req(ctx=0x%x, %s)\n",
- cn_domain_indicator_to_str(ies.cN_DomainIndicator), context_id,
+ ranap_domain_name(ies.cN_DomainIndicator), context_id,
ies.establishment_Cause == RUA_Establishment_Cause_emergency_call ? "emergency" : "normal");
rc = rua_to_scu(hnb, ies.cN_DomainIndicator, RUA_ProcedureCode_id_Connect,
To view, visit change 33174. To unsubscribe, or for help writing mail filters, visit settings.