Change in osmo-bts[master]: pcu_sock: fix {local, remote}_port byte ordering in pcu_tx_info_ind()

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

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Fri Oct 9 11:17:17 UTC 2020


Vadim Yanitskiy has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/20492 )

Change subject: pcu_sock: fix {local,remote}_port byte ordering in pcu_tx_info_ind()
......................................................................

pcu_sock: fix {local,remote}_port byte ordering in pcu_tx_info_ind()

The PCUIF is a 'brilliant' protocol: some fields are expected to
be in the network byte order, some in the host order.  The NSVC
remote address and local/remote ports is a good example:

  - byte order of the address must be the network order, and
  - byte order of the ports must be the host order.

Change-Id: I383cab0b58b62734090023298da8c5a341c670d5
Fixes: I310699fabbfec4255f0474f31717f215c1201eca
Related: SYS#4915
---
M src/common/pcu_sock.c
1 file changed, 4 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 6040de5..efee517 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -329,8 +329,10 @@
 	for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
 		const struct gsm_bts_gprs_nsvc *nsvc = &bts->gprs.nsvc[i];
 		info_ind->nsvci[i] = nsvc->nsvci;
-		info_ind->local_port[i] = nsvc->local.u.sin.sin_port;
-		info_ind->remote_port[i] = nsvc->remote.u.sin.sin_port;
+		/* PCUIF beauty: the NSVC addresses are sent in the network byte order,
+		 * while the port numbers need to be send in the host order.  Sigh. */
+		info_ind->local_port[i] = ntohs(nsvc->local.u.sin.sin_port);
+		info_ind->remote_port[i] = ntohs(nsvc->remote.u.sin.sin_port);
 		switch (nsvc->remote.u.sas.ss_family) {
 		case AF_INET:
 			info_ind->address_type[i] = PCU_IF_ADDR_TYPE_IPV4;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/20492
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I383cab0b58b62734090023298da8c5a341c670d5
Gerrit-Change-Number: 20492
Gerrit-PatchSet: 3
Gerrit-Owner: Vadim Yanitskiy <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201009/6cc319a1/attachment.htm>


More information about the gerrit-log mailing list