Harald Welte has submitted this change and it was merged.
Change subject: stream.c: Fix endianness handling of PPID and STREAM_ID
......................................................................
stream.c: Fix endianness handling of PPID and STREAM_ID
In their infinite wisdom, the inventors of SCTP designed an API (the
sockets API described in RFC6458), where some members are in host byte
order (like the stream identifier), while other members are in network
byte order (like the PPID).
Let's handle this properly (we assumed both are network byte order), and
also use 16-bit htons/ntohs fo the PPID, rather than htonl/ntohl.
Change-Id: I777174ca2915c6de0063db41a745c71b4a09bbec
---
M src/stream.c
1 file changed, 6 insertions(+), 6 deletions(-)
Approvals:
Harald Welte: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/stream.c b/src/stream.c
index f899a41..f5ead17 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -162,8 +162,8 @@
#ifdef HAVE_LIBSCTP
case IPPROTO_SCTP:
memset(&sinfo, 0, sizeof(sinfo));
- sinfo.sinfo_ppid = htonl(msgb_sctp_ppid(msg));
- sinfo.sinfo_stream = htonl(msgb_sctp_stream(msg));
+ sinfo.sinfo_ppid = htons(msgb_sctp_ppid(msg));
+ sinfo.sinfo_stream = msgb_sctp_stream(msg);
ret = sctp_send(cli->ofd.fd, msg->data, msgb_length(msg),
&sinfo, MSG_NOSIGNAL);
break;
@@ -692,8 +692,8 @@
#ifdef HAVE_LIBSCTP
case IPPROTO_SCTP:
memset(&sinfo, 0, sizeof(sinfo));
- sinfo.sinfo_ppid = htonl(msgb_sctp_ppid(msg));
- sinfo.sinfo_stream = htonl(msgb_sctp_stream(msg));
+ sinfo.sinfo_ppid = htons(msgb_sctp_ppid(msg));
+ sinfo.sinfo_stream = msgb_sctp_stream(msg);
ret = sctp_send(conn->ofd.fd, msg->data, msgb_length(msg),
&sinfo, MSG_NOSIGNAL);
break;
@@ -871,8 +871,8 @@
}
return -EAGAIN;
}
- msgb_sctp_ppid(msg) = ntohl(sinfo.sinfo_ppid);
- msgb_sctp_stream(msg) = ntohl(sinfo.sinfo_stream);
+ msgb_sctp_ppid(msg) = ntohs(sinfo.sinfo_ppid);
+ msgb_sctp_stream(msg) = sinfo.sinfo_stream;
break;
#endif
case IPPROTO_TCP:
--
To view, visit https://gerrit.osmocom.org/2290
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I777174ca2915c6de0063db41a745c71b4a09bbec
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder