aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-12-24 16:12:42 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2017-12-24 20:32:03 +0100
commite4a77d46735046c09c3b58e9c404539bb5b8e2af (patch)
treed453620a0f953277b266f8cdc254588d7953426f
parentd23e38020fdbb685570145acd3a35e22a5a91344 (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
-rw-r--r--include/osmocom/sigtran/sccp_sap.h2
-rw-r--r--src/sccp_user.c21
2 files changed, 23 insertions, 0 deletions
diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h
index 7a4f9bf..84d762c 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -275,3 +275,5 @@ void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
uint32_t ssn);
bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence);
+
+const char *osmo_sccp_user_name(struct osmo_sccp_user *scu);
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
***********************************************************************/