laforge has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-netif/+/29414 )
Change subject: stream: Provide caller with SCTP flags during osmo_stream_*_recv()
......................................................................
stream: Provide caller with SCTP flags during osmo_stream_*_recv()
The user may want to check the flags in order to know if the content
pointed at by msgb is an sctp_notification structure, and not in-band
data.
This is useful for the user in order to gain connection state such as
SCTP RESET notification, which means the client reconnected reusing the
same socket, loosing all higher layers state.
The MSG_NOTIFICATION from netinet/sctp.h is not reused, and instead an
osmocom specific flag (and bitmask) is used. This is done in order to
fit the flags in one byte, since for instance MSG_NOTIFICATION requires
2 bytes in my system (0x8000).
Related: SYS#6113
Change-Id: I0ee94846a15a23950b9d70eaaef1251267296bdd
---
M include/osmocom/netif/stream.h
M src/stream.c
2 files changed, 5 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index b82dff1..489fc5d 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -9,6 +9,10 @@
* @{
*/
+/*! \brief Access SCTP flags from the msgb control buffer */
+#define OSMO_STREAM_SCTP_MSG_FLAGS_NOTIFICATION 0x80 /* sctp_recvmsg()
flags=MSG_NOTIFICATION, msgb_data() contains "union sctp_notification*" */
+#define msgb_sctp_msg_flags(msg) (msg)->cb[2]
+
/*! \brief Access the SCTP PPID from the msgb control buffer */
#define msgb_sctp_ppid(msg) (msg)->cb[3]
/*! \brief Access the SCTP Stream ID from the msgb control buffer */
diff --git a/src/stream.c b/src/stream.c
index bc209af..b45b730 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -1476,6 +1476,7 @@
if (flags & MSG_NOTIFICATION) {
union sctp_notification *notif = (union sctp_notification *)msgb_data(msg);
LOGP(DLINP, LOGL_DEBUG, "NOTIFICATION %u flags=0x%x\n",
notif->sn_header.sn_type, notif->sn_header.sn_flags);
+ msgb_sctp_msg_flags(msg) = OSMO_STREAM_SCTP_MSG_FLAGS_NOTIFICATION;
switch (notif->sn_header.sn_type) {
case SCTP_ASSOC_CHANGE:
LOGP(DLINP, LOGL_DEBUG, "===> ASSOC CHANGE:");
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-netif/+/29414
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I0ee94846a15a23950b9d70eaaef1251267296bdd
Gerrit-Change-Number: 29414
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged