[MERGED] libosmo-sccp[master]: xUA: Fix endianness handling of PPID and STREAM_ID

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
Mon Apr 10 15:54:30 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: xUA: Fix endianness handling of PPID and STREAM_ID
......................................................................


xUA: 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: I51c87314ef9ba6415e7e89980699ab07e787ed5d
---
M src/osmo_ss7.c
1 file changed, 4 insertions(+), 4 deletions(-)

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



diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 103c05b..aa331b9 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -1209,9 +1209,9 @@
 		goto out;
 	}
 
-	ppid = ntohl(sinfo.sinfo_ppid);
+	ppid = ntohs(sinfo.sinfo_ppid);
 	msgb_sctp_ppid(msg) = ppid;
-	msgb_sctp_stream(msg) = ntohl(sinfo.sinfo_stream);
+	msgb_sctp_stream(msg) = sinfo.sinfo_stream;
 	msg->dst = asp;
 
 	if (ppid == SUA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_SUA)
@@ -1299,9 +1299,9 @@
 	if (rc == 0)
 		goto out;
 
-	ppid = ntohl(sinfo.sinfo_ppid);
+	ppid = ntohs(sinfo.sinfo_ppid);
 	msgb_sctp_ppid(msg) = ppid;
-	msgb_sctp_stream(msg) = ntohl(sinfo.sinfo_stream);
+	msgb_sctp_stream(msg) = sinfo.sinfo_stream;
 	msg->dst = asp;
 
 	if (ppid == SUA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_SUA)

-- 
To view, visit https://gerrit.osmocom.org/2291
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I51c87314ef9ba6415e7e89980699ab07e787ed5d
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list