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
This commit is contained in:
parent
98c75ef273
commit
668c804197
|
@ -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 */
|
||||
|
|
|
@ -1476,6 +1476,7 @@ static int _sctp_recvmsg_wrapper(int fd, struct msgb *msg)
|
|||
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:");
|
||||
|
|
Loading…
Reference in New Issue