add osmo_sccp_addr_name() and three value_string[]s

osmo_sccp_addr_dump() just prints the raw values. In osmo_sccp_addr_name(), use
osmo_ss7_pointcode_print() and newly added RI, SSN and GT value_string[] to
print more human readable log output.

Change-Id: Ie1aedd7894acd69ddc887cd65a8a0df4b888838c
This commit is contained in:
Neels Hofmeyr 2017-07-26 18:07:53 +02:00
parent c881c49127
commit 603e065f43
3 changed files with 84 additions and 0 deletions

View File

@ -60,6 +60,11 @@ enum osmo_sccp_routing_ind {
OSMO_SCCP_RI_SSN_IP,
};
extern const struct value_string osmo_sccp_routing_ind_names[];
static inline const char *osmo_sccp_routing_ind_name(enum osmo_sccp_routing_ind val)
{ return get_value_string(osmo_sccp_routing_ind_names, val); }
/* Q.713 3.4.1 + RFC 3868 3.10.2.3 */
enum osmo_sccp_gti {
OSMO_SCCP_GTI_NO_GT,
@ -69,6 +74,10 @@ enum osmo_sccp_gti {
OSMO_SCCP_GTI_TT_NPL_ENC_NAI,
};
extern const struct value_string osmo_sccp_gti_names[];
static inline const char *osmo_sccp_gti_name(enum osmo_sccp_gti val)
{ return get_value_string(osmo_sccp_gti_names, val); }
/* RFC 3868 3.10.2.3 */
enum osmo_sccp_npi {
OSMO_SCCP_NPI_UNKNOWN = 0,
@ -126,6 +135,10 @@ enum osmo_sccp_ssn {
OSMO_SCCP_SSN_BSS_OAM = 253,
};
extern const struct value_string osmo_sccp_ssn_names[];
static inline const char *osmo_sccp_ssn_name(enum osmo_sccp_ssn val)
{ return get_value_string(osmo_sccp_ssn_names, val); }
struct osmo_sccp_gt {
uint8_t gti;
uint8_t tt;

View File

@ -274,6 +274,7 @@ char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt)
return buf;
}
/* Return string representation of SCCP address raw bytes in a static string. */
char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr)
{
static char buf[256];
@ -295,3 +296,26 @@ char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr)
return buf;
}
/* Like osmo_sccp_addr_dump() but print human readable representations instead of raw values. */
char *osmo_sccp_addr_name(const struct osmo_ss7_instance *ss7, const struct osmo_sccp_addr *addr)
{
static char buf[256];
bool comma = false;
buf[0] = '\0';
append_to_buf(buf, &comma, "RI=%s", osmo_sccp_routing_ind_name(addr->ri));
if (addr->presence & OSMO_SCCP_ADDR_T_PC)
append_to_buf(buf, &comma, "PC=%s", osmo_ss7_pointcode_print(ss7, addr->pc));
if (addr->presence & OSMO_SCCP_ADDR_T_SSN)
append_to_buf(buf, &comma, "SSN=%s", osmo_sccp_ssn_name(addr->ssn));
if (addr->presence & OSMO_SCCP_ADDR_T_IPv4)
append_to_buf(buf, &comma, "IP=%s", inet_ntoa(addr->ip.v4));
append_to_buf(buf, &comma, "GTI=%s", osmo_sccp_gti_name(addr->gt.gti));
if (addr->presence & OSMO_SCCP_ADDR_T_GT)
append_to_buf(buf, &comma, "GT=(%s)", osmo_sccp_gt_dump(&addr->gt));
return buf;
}

View File

@ -85,3 +85,50 @@ char *osmo_xlm_prim_name(struct osmo_prim_hdr *oph)
return prim_name_buf;
}
const struct value_string osmo_sccp_routing_ind_names[] = {
{ OSMO_SCCP_RI_NONE, "NONE" },
{ OSMO_SCCP_RI_GT, "GT" },
{ OSMO_SCCP_RI_SSN_PC, "SSN_PC" },
{ OSMO_SCCP_RI_SSN_IP, "SSN_IP" },
{ 0, NULL }
};
const struct value_string osmo_sccp_gti_names[] = {
{ OSMO_SCCP_GTI_NO_GT, "NO_GT" },
{ OSMO_SCCP_GTI_NAI_ONLY, "NAI_ONLY" },
{ OSMO_SCCP_GTI_TT_ONLY, "TT_ONLY" },
{ OSMO_SCCP_GTI_TT_NPL_ENC, "TT_NPL_ENC" },
{ OSMO_SCCP_GTI_TT_NPL_ENC_NAI, "TT_NPL_ENC_NAI" },
{ 0, NULL }
};
const struct value_string osmo_sccp_ssn_names[] = {
{ OSMO_SCCP_SSN_MGMT, "MGMT" },
{ OSMO_SCCP_SSN_ISUP, "ISUP" },
{ OSMO_SCCP_SSN_OMAP, "OMAP" },
{ OSMO_SCCP_SSN_MAP, "MAP" },
{ OSMO_SCCP_SSN_HLR, "HLR" },
{ OSMO_SCCP_SSN_VLR, "VLR" },
{ OSMO_SCCP_SSN_MSC, "MSC" },
{ OSMO_SCCP_SSN_EIR, "EIR" },
{ OSMO_SCCP_SSN_AUC, "AUC" },
{ OSMO_SCCP_SSN_ISDN_SS, "ISDN_SS" },
{ OSMO_SCCP_SSN_RES_INTL, "RES_INTL" },
{ OSMO_SCCP_SSN_BISDN, "BISDN" },
{ OSMO_SCCP_SSN_TC_TEST, "TC_TEST" },
{ OSMO_SCCP_SSN_RANAP, "RANAP" },
{ OSMO_SCCP_SSN_RNSAP, "RNSAP" },
{ OSMO_SCCP_SSN_GMLC_MAP, "GMLC_MAP" },
{ OSMO_SCCP_SSN_CAP, "CAP" },
{ OSMO_SCCP_SSN_gsmSCF_MAP, "gsmSCF_MAP" },
{ OSMO_SCCP_SSN_SIWF_MAP, "SIWF_MAP" },
{ OSMO_SCCP_SSN_SGSN_MAP, "SGSN_MAP" },
{ OSMO_SCCP_SSN_GGSN_MAP, "GGSN_MAP" },
{ OSMO_SCCP_SSN_PCAP, "PCAP" },
{ OSMO_SCCP_SSN_BSC_BSSAP, "BSC_BSSAP" },
{ OSMO_SCCP_SSN_MSC_BSSAP, "MSC_BSSAP" },
{ OSMO_SCCP_SSN_SMLC_BSSAP, "SMLC_BSSAP" },
{ OSMO_SCCP_SSN_BSS_OAM, "BSS_OAM" },
{ 0, NULL }
};