Change in libosmo-sccp[master]: Introduce osmo_ss7_register_rx_unknown_cb() for unknown PPID/StreamID

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Jun 8 18:47:44 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9439 )

Change subject: Introduce osmo_ss7_register_rx_unknown_cb() for unknown PPID/StreamID
......................................................................

Introduce osmo_ss7_register_rx_unknown_cb() for unknown PPID/StreamID

Applications may be interested in handling data for those SCTP PPID or
IPA StreamID which libosmo-sigtran doesn't implement
natively/internally.

Let's add osmo_ss7_register_rx_unknown_cb() using which applications
can register a call-back to implement whatever behaviour they'd want for
those PPID/StreamIDs.

Change-Id: I8616f914192000df0ec6547ff4ada80e0f9042a2
---
M include/osmocom/sigtran/osmo_ss7.h
M src/ipa.c
M src/osmo_ss7.c
M src/xua_internal.h
4 files changed, 44 insertions(+), 13 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index fd3f103..a93c663 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -408,6 +408,17 @@
 int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp);
 int osmo_ss7_asp_use_default_lm(struct osmo_ss7_asp *asp, int log_level);
 
+/*! Weak function to handle payload for unknown/unsupported PPID or IPA StreamID.
+ *  This function can be overridden by application code to implement whatever handling
+ *  it wants for such additional payloads/streams.
+ *  \param[in] asp Application Server Process through which data was received
+ *  \param[in] ppid_sid SCTP PPID (in sigtran case) or IPA Stream ID
+ *  \param[in] msg Message buffer containing received data. Continues to be owned by caller!
+ *  \return 0 on success; negative on error */
+typedef int osmo_ss7_asp_rx_unknown_cb(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg);
+
+void osmo_ss7_register_rx_unknown_cb(osmo_ss7_asp_rx_unknown_cb *cb);
+
 #define LOGPASP(asp, subsys, level, fmt, args ...)		\
 	LOGP(subsys, level, "asp-%s: " fmt, (asp)->cfg.name, ## args)
 
diff --git a/src/ipa.c b/src/ipa.c
index 9f04746..0e6f683 100644
--- a/src/ipa.c
+++ b/src/ipa.c
@@ -288,9 +288,7 @@
 		rc = ipa_rx_msg_sccp(asp, msg);
 		break;
 	default:
-		LOGPASP(asp, DLSS7, LOGL_DEBUG, "Unknown Stream ID 0x%02x: %s\n",
-			hh->proto, msgb_hexdump(msg));
-		rc = -1;
+		rc = ss7_asp_rx_unknown(asp, hh->proto, msg);
 	}
 
 	return rc;
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 275469e..025c21c 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -1450,11 +1450,8 @@
 		rc = sua_rx_msg(asp, msg);
 	else if (ppid == M3UA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA)
 		rc = m3ua_rx_msg(asp, msg);
-	else {
-		LOGPASP(asp, DLSS7, LOGL_NOTICE, "SCTP chunk for unknown PPID %u "
-			"received\n", ppid);
-		rc = 0;
-	}
+	else
+		rc = ss7_asp_rx_unknown(asp, ppid, msg);
 
 out:
 	msgb_free(msg);
@@ -1591,11 +1588,8 @@
 		rc = sua_rx_msg(asp, msg);
 	else if (ppid == M3UA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA)
 		rc = m3ua_rx_msg(asp, msg);
-	else {
-		LOGPASP(asp, DLSS7, LOGL_NOTICE, "SCTP chunk for unknown PPID %u "
-			"received\n", ppid);
-		rc = 0;
-	}
+	else
+		rc = ss7_asp_rx_unknown(asp, ppid, msg);
 
 out:
 	msgb_free(msg);
@@ -1918,3 +1912,29 @@
 		return OSMO_SS7_AS_TMOD_BCAST;
 	}
 }
+
+static osmo_ss7_asp_rx_unknown_cb *g_osmo_ss7_asp_rx_unknown_cb;
+
+int ss7_asp_rx_unknown(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg)
+{
+	if (g_osmo_ss7_asp_rx_unknown_cb)
+		return (*g_osmo_ss7_asp_rx_unknown_cb)(asp, ppid_mux, msg);
+
+	switch(asp->cfg.proto) {
+	case OSMO_SS7_ASP_PROT_IPA:
+		LOGPASP(asp, DLSS7, LOGL_NOTICE, "Rx IPA for unknown Stream ID 0x%02x: %s\n",
+			ppid_mux, msgb_hexdump(msg));
+		break;
+	default:
+		LOGPASP(asp, DLSS7, LOGL_NOTICE, "Rx SCTP chunk for unknown PPID %u: %s\n",
+			ppid_mux, msgb_hexdump(msg));
+		break;
+	}
+	return 0;
+}
+
+/*! Register a call-back function for unknown SCTP PPID / IPA Stream ID */
+void osmo_ss7_register_rx_unknown_cb(osmo_ss7_asp_rx_unknown_cb *cb)
+{
+	g_osmo_ss7_asp_rx_unknown_cb = cb;
+}
diff --git a/src/xua_internal.h b/src/xua_internal.h
index 96bd153..d836fae 100644
--- a/src/xua_internal.h
+++ b/src/xua_internal.h
@@ -78,3 +78,5 @@
 int osmo_sccp_addr_parse(struct osmo_sccp_addr *out,
 			const uint8_t *addr, unsigned int addrlen);
 int osmo_sccp_addr_encode(struct msgb *msg, const struct osmo_sccp_addr *in);
+
+int ss7_asp_rx_unknown(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg);

-- 
To view, visit https://gerrit.osmocom.org/9439
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8616f914192000df0ec6547ff4ada80e0f9042a2
Gerrit-Change-Number: 9439
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-CC: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180608/88e3193a/attachment.htm>


More information about the gerrit-log mailing list