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.orgHello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/3398
to look at the new patch set (#2).
sccp: add function to check sccp addresses
In order to catch invalid CS7 configurations, It is necessary
to check if sccp addresses contain plausible address data.
Change-Id: Ic6245288b0171eae10aa708403c1ddb584c92f38
---
M include/osmocom/sigtran/sccp_sap.h
M src/sccp_user.c
2 files changed, 44 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/98/3398/2
diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h
index 732df2a..90da686 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -257,3 +257,5 @@
void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
const struct osmo_sccp_instance *inst,
uint32_t ssn);
+
+bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence);
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 495b6dc..71b3262 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -253,6 +253,48 @@
osmo_sccp_make_addr_pc_ssn(dest_addr, ss7->cfg.primary_pc, ssn);
}
+/*! \brief check whether a given SCCP-Address is consistent.
+ * \param[in] addr SCCP address to check
+ * \param[in] presence mask with minimum required address components
+ * \returns true when address data seems plausible */
+bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence)
+{
+ /* Minimum requirements do not match */
+ if ((addr->presence & presence) != presence)
+ return false;
+
+ /* GT ranges */
+ if (addr->presence & OSMO_SCCP_ADDR_T_GT) {
+ if (addr->gt.gti > 15)
+ return false;
+ if (addr->gt.npi > 15)
+ return false;
+ if (addr->gt.nai > 127)
+ return false;
+ }
+
+ /* Routing by GT, but no GT present */
+ if (addr->ri == OSMO_SCCP_RI_GT
+ && !(addr->presence & OSMO_SCCP_ADDR_T_GT))
+ return false;
+
+ /* Routing by PC/SSN, but no PC/SSN present */
+ if (addr->ri == OSMO_SCCP_RI_SSN_PC) {
+ if ((addr->presence & OSMO_SCCP_ADDR_T_PC) == 0)
+ return false;
+ if ((addr->presence & OSMO_SCCP_ADDR_T_SSN) == 0)
+ return false;
+ }
+
+ if (addr->ri == OSMO_SCCP_RI_SSN_IP) {
+ if ((addr->presence & OSMO_SCCP_ADDR_T_IPv4) == 0 &&
+ (addr->presence & OSMO_SCCP_ADDR_T_IPv6) == 0)
+ return false;
+ }
+
+ return true;
+}
+
/***********************************************************************
* Convenience function for CLIENT
***********************************************************************/
--
To view, visit https://gerrit.osmocom.org/3398
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ic6245288b0171eae10aa708403c1ddb584c92f38
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>