Commit 238f0863 authored by Phil Knirsch's avatar Phil Knirsch Committed by Mike Frysinger

ipx: always byte swap fields

In the output of netstat --ipx, the network and port numbers are byteswapped.
For instance:

Proto Recv-Q Send-Q Local Address              Foreign Address            State
IPX        0      0 000A6F83:2E40              04036F83:000000000001:5104 ESTAB

The local network number is actually 836F0A00, and the NetWare server reports
my socket number as 402E.  Similarly, the server's address is
836F0304:000000000001, and the standard NCP port is 0415.

URL: https://bugzilla.redhat.com/show_bug.cgi?id=46434Reported-by: default avatarBen Harris <bjh21@cam.ac.uk>
parent 7af48590
......@@ -129,7 +129,6 @@ static int IPX_input(int type, char *bufp, struct sockaddr *sap)
struct sockaddr_ipx *sai = (struct sockaddr_ipx *) sap;
unsigned long netnum;
char *ep;
int nbo;
if (!sai)
return (-1);
......@@ -140,20 +139,12 @@ static int IPX_input(int type, char *bufp, struct sockaddr *sap)
sai->sipx_node[3] = sai->sipx_node[4] = sai->sipx_node[5] = '\0';
sai->sipx_port = 0;
if (type & 4)
nbo = 1;
else
nbo = 0;
type &= 3;
if (type <= 1) {
netnum = strtoul(bufp, &ep, 16);
if ((netnum == 0xffffffffL) || (netnum == 0L))
return (-1);
if (nbo)
sai->sipx_network = netnum;
else
sai->sipx_network = htonl(netnum);
sai->sipx_network = htonl(netnum);
}
if (type == 1) {
if (*ep != '\0')
......
......@@ -72,11 +72,11 @@ int IPX_rprint(int options)
continue;
/* Fetch and resolve the Destination */
(void) ap->input(5, net, &sa);
(void) ap->input(1, net, &sa);
safe_strncpy(net, ap->sprint(&sa, numeric), sizeof(net));
/* Fetch and resolve the Router Net */
(void) ap->input(5, router_net, &sa);
(void) ap->input(1, router_net, &sa);
safe_strncpy(router_net, ap->sprint(&sa, numeric), sizeof(router_net));
/* Fetch and resolve the Router Node */
......
......@@ -1749,13 +1749,13 @@ static int ipx_info(void)
}
/* Fetch and resolve the Source */
(void) ap->input(4, sad, &sa);
(void) ap->input(0, sad, &sa);
safe_strncpy(buf, ap->sprint(&sa, flag_not & FLAG_NUM_HOST), sizeof(buf));
snprintf(sad, sizeof(sad), "%s:%04X", buf, sport);
if (!nc) {
/* Fetch and resolve the Destination */
(void) ap->input(4, dad, &sa);
(void) ap->input(0, dad, &sa);
safe_strncpy(buf, ap->sprint(&sa, flag_not & FLAG_NUM_HOST), sizeof(buf));
snprintf(dad, sizeof(dad), "%s:%04X", buf, dport);
} else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment