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
This commit is contained in:
parent
77a21cff1d
commit
0db165344c
|
@ -36,6 +36,12 @@ extern struct vty_app_info hnbgw_vty_info;
|
|||
#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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
@ -371,7 +359,7 @@ static int rua_rx_init_connect(struct msgb *msg, ANY_t *in)
|
|||
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,
|
||||
|
|
Loading…
Reference in New Issue