summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-07-21 16:23:50 +0200
committerHarald Welte <laforge@gnumonks.org>2017-08-01 11:08:05 +0000
commit882f340b6c394f581f6c32cafefa10c7b57073b9 (patch)
tree7703e7c32fda45dec297767eb2a3b61423c61bf8
parent738756984f2479512514515e95610f0a1bde7bd1 (diff)
sccp: derive local address from given sccp instance
The most important parts of an SCCP address are the routing indicator and the pointcode. The latter one is always available via the SS7 instance, so a basic local address can be derived from there. Add function osmo_sccp_local_addr_by_instance() to derive a basic local SCCP address from a given SCCP instance Change-Id: I371dc9132871aad3d8321ea13cf9fd69d76eff8f
-rw-r--r--include/osmocom/sigtran/sccp_sap.h4
-rw-r--r--src/sccp_user.c22
2 files changed, 26 insertions, 0 deletions
diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h
index 24d64d9..732df2a 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -253,3 +253,7 @@ osmo_sccp_addr_by_name(struct osmo_sccp_addr *dest_addr,
const char *name);
const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr);
+
+void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
+ const struct osmo_sccp_instance *inst,
+ uint32_t ssn);
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 89a0320..495b6dc 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -22,6 +22,7 @@
*/
#include <stdbool.h>
+#include <string.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
@@ -30,6 +31,7 @@
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/sigtran/mtp_sap.h>
#include <osmocom/sigtran/protocol/mtp.h>
+#include <osmocom/sigtran/sccp_helpers.h>
#include "sccp_internal.h"
#include "xua_internal.h"
@@ -231,6 +233,26 @@ void osmo_sccp_instance_destroy(struct osmo_sccp_instance *inst)
talloc_free(inst);
}
+/*! \brief derive a basic local SCCP-Address from a given SCCP instance.
+ * \param[out] dest_addr pointer to output address memory
+ * \param[in] inst SCCP instance
+ * \param[in] ssn Subsystem Number */
+void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
+ const struct osmo_sccp_instance *inst,
+ uint32_t ssn)
+{
+ struct osmo_ss7_instance *ss7;
+
+ OSMO_ASSERT(dest_addr);
+ OSMO_ASSERT(inst);
+ ss7 = inst->ss7;
+ OSMO_ASSERT(ss7);
+
+ *dest_addr = (struct osmo_sccp_addr){};
+
+ osmo_sccp_make_addr_pc_ssn(dest_addr, ss7->cfg.primary_pc, ssn);
+}
+
/***********************************************************************
* Convenience function for CLIENT
***********************************************************************/