This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/5569
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
---
M include/osmocom/sigtran/sccp_sap.h
M src/sccp_user.c
2 files changed, 23 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/69/5569/1
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 @@
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 @@
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
***********************************************************************/
--
To view, visit https://gerrit.osmocom.org/5569
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7abf69cfcf4c56273223054b280458451e6c2f6
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>