diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2017-12-24 16:12:42 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2017-12-24 20:32:03 +0100 |
commit | e4a77d46735046c09c3b58e9c404539bb5b8e2af (patch) | |
tree | d453620a0f953277b266f8cdc254588d7953426f /src/sccp_user.c | |
parent | d23e38020fdbb685570145acd3a35e22a5a91344 (diff) |
add osmo_sccp_user_name()
There is a naming dilemma: though the osmo_ prefix is now reserved for
libosmocore, all surrounding API already has the osmo_ prefix.
This will be used by osmo-hnbgw's VTY 'show cnlink' command.
Change-Id: Ib7abf69cfcf4c56273223054b280458451e6c2f6
Diffstat (limited to 'src/sccp_user.c')
-rw-r--r-- | src/sccp_user.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/sccp_user.c b/src/sccp_user.c index cd89c88..a6161c0 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -293,6 +293,27 @@ bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence) return true; } +/*! Compose a human readable string to describe the SCCP user's connection. + * The output follows ['<scu.name>':]<local-sccp-addr>, e.g. "'OsmoHNBW':RI=SSN_PC,PC=0.23.5,SSN=RANAP", + * or just "RI=SSN_PC,PC=0.23.5,SSN=RANAP" if no scu->name is set. + * This calls osmo_sccp_addr_name(), which returns a static buffer; hence calling this function and + * osmo_sccp_addr_name() in the same printf statement is likely to conflict. */ +const char *osmo_sccp_user_name(struct osmo_sccp_user *scu) +{ + static char buf[128]; + struct osmo_sccp_addr sca; + /* Interestingly enough, the osmo_sccp_user stores an SSN and PC, but not in an osmo_sccp_addr + * struct. To be able to use osmo_sccp_addr_name(), we need to first create an osmo_sccp_addr. */ + osmo_sccp_make_addr_pc_ssn(&sca, scu->pc, scu->ssn); + snprintf(buf, sizeof(buf), + "%s%s%s", + scu->name && *scu->name ? scu->name : "", + scu->name && *scu->name ? ":" : "", + osmo_sccp_addr_name(scu->inst->ss7, &sca)); + buf[sizeof(buf)-1] = '\0'; + return buf; +} + /*********************************************************************** * Convenience function for CLIENT ***********************************************************************/ |