aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-08 23:51:18 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-09 11:17:17 +0000
commit6710438899c49f9584b01baf816e6be71c600797 (patch)
treeb252d50b641b799f6ddb4ab81f828acbecaaa52a /src/common
parent74750fe2b0c19fdd4c9cf6524c89c13d985d024e (diff)
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
Diffstat (limited to 'src/common')
-rw-r--r--src/common/pcu_sock.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 6040de5a..efee5172 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -329,8 +329,10 @@ int pcu_tx_info_ind(void)
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;