From 3fb20be356305ef2027ad403b8eb2d03f6c6e87d Mon Sep 17 00:00:00 2001 From: Bernd Eckenfels Date: Tue, 2 Aug 2005 22:28:10 +0000 Subject: [PATCH] make ipx in 2.6 work (perhaps). Fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=318503 --- lib/ipx_gr.c | 20 +++++++++++++------- lib/pathnames.h | 6 ++++-- netstat.c | 49 ++++++++++++++++++++++++++++++++++--------------- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/lib/ipx_gr.c b/lib/ipx_gr.c index 3d7ef1d..96fac80 100644 --- a/lib/ipx_gr.c +++ b/lib/ipx_gr.c @@ -38,21 +38,27 @@ int IPX_rprint(int options) char net[128], router_net[128]; char router_node[128]; int num; - FILE *fp = fopen(_PATH_PROCNET_IPX_ROUTE, "r"); + FILE *fp; struct aftype *ap; struct sockaddr sa; - if ((ap = get_afntype(AF_IPX)) == NULL) { - EINTERN("lib/ipx_rt.c", "AF_IPX missing"); - return (-1); - } + fp = fopen(_PATH_PROCNET_IPX_ROUTE1, "r"); if (!fp) { - perror(_PATH_PROCNET_IPX_ROUTE); - printf(_("IPX not configured in this system.\n")); + fp = fopen(_PATH_PROCNET_IPX_ROUTE2, "r"); + } + + if (!fp) { + perror(NULL); + printf(_("IPX routing not in file %s or %s found.\n"), _PATH_PROCNET_IPX_ROUTE1, _PATH_PROCNET_IPX_ROUTE2); return 1; } + if ((ap = get_afntype(AF_IPX)) == NULL) { + EINTERN("lib/ipx_rt.c", "AF_IPX missing"); + return (-1); + } + printf(_("Kernel IPX routing table\n")); /* xxx */ printf(_("Destination Router Net Router Node\n")); diff --git a/lib/pathnames.h b/lib/pathnames.h index 2d2c0a8..0764ce9 100644 --- a/lib/pathnames.h +++ b/lib/pathnames.h @@ -28,8 +28,10 @@ #define _PATH_PROCNET_NR_NODES "/proc/net/nr_nodes" #define _PATH_PROCNET_ARP "/proc/net/arp" #define _PATH_PROCNET_AX25 "/proc/net/ax25" -#define _PATH_PROCNET_IPX "/proc/net/ipx" -#define _PATH_PROCNET_IPX_ROUTE "/proc/net/ipx_route" +#define _PATH_PROCNET_IPX_SOCKET1 "/proc/net/ipx/socket" +#define _PATH_PROCNET_IPX_SOCKET2 "/proc/net/ipx" +#define _PATH_PROCNET_IPX_ROUTE1 "/proc/net/ipx/route" +#define _PATH_PROCNET_IPX_ROUTE2 "/proc/net/ipx_route" #define _PATH_PROCNET_ATALK "/proc/net/appletalk" #define _PATH_PROCNET_IP_BLK "/proc/net/ip_block" #define _PATH_PROCNET_IP_FWD "/proc/net/ip_forward" diff --git a/netstat.c b/netstat.c index 903c495..48bdee3 100644 --- a/netstat.c +++ b/netstat.c @@ -6,7 +6,7 @@ * NET-3 Networking Distribution for the LINUX operating * system. * - * Version: $Id: netstat.c,v 1.51 2004/06/03 22:27:37 ecki Exp $ + * Version: $Id: netstat.c,v 1.52 2005/08/02 22:28:10 ecki Exp $ * * Authors: Fred Baumgarten, * Fred N. van Kempen, @@ -1363,18 +1363,37 @@ static int ipx_info(void) char sad[50], dad[50]; struct sockaddr sa; unsigned sport = 0, dport = 0; - - if (!(f = fopen(_PATH_PROCNET_IPX, "r"))) { - if (errno != ENOENT) { - perror(_PATH_PROCNET_IPX); - return (-1); - } - if (flag_arg || flag_ver) - ESYSNOT("netstat", "AF IPX"); - if (flag_arg) - return (1); - else - return (0); + struct stat s; + + f = fopen(_PATH_PROCNET_IPX_SOCKET1, "r"); + if (!f) { + if (errno != ENOENT) { + perror(_PATH_PROCNET_IPX_SOCKET1); + return (-1); + } + f = fopen(_PATH_PROCNET_IPX_SOCKET2, "r"); + + /* We need to check for directory */ + if (f) { + fstat(fileno(f), &s); + if (!S_ISREG(s.st_mode)) { + fclose(f); + f=NULL; + } + } + + if (!f) { + if (errno != ENOENT) { + perror(_PATH_PROCNET_IPX_SOCKET2); + return (-1); + } + if (flag_arg || flag_ver) + ESYSNOT("netstat", "AF IPX"); + if (flag_arg) + return (1); + else + return (0); + } } printf(_("Active IPX sockets\nProto Recv-Q Send-Q Local Address Foreign Address State")); /* xxx */ if (flag_exp > 1) @@ -1394,7 +1413,7 @@ static int ipx_info(void) sscanf(st, "%X", &sport); /* net byt order */ sport = ntohs(sport); } else { - EINTERN("netstat.c", _PATH_PROCNET_IPX " sport format error"); + EINTERN("netstat.c", "ipx socket format error in source port"); return (-1); } nc = 0; @@ -1404,7 +1423,7 @@ static int ipx_info(void) sscanf(st, "%X", &dport); /* net byt order */ dport = ntohs(dport); } else { - EINTERN("netstat.c", _PATH_PROCNET_IPX " dport format error"); + EINTERN("netstat.c", "ipx soket format error in destination port"); return (-1); } } else -- 2.7.4