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
This commit is contained in:
Vadim Yanitskiy 2020-10-08 23:51:18 +07:00
parent 74750fe2b0
commit 6710438899
1 changed files with 4 additions and 2 deletions

View File

@ -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;