tag 318503 help
thanks
the following patch makes the filenames dynamic, it also handles the ipx
sockets. Can you please try it on an 2.4 and 2.6 IPX system?
Index: lib/pathnames.h
===================================================================
RCS file: /cvs/net-tools/lib/pathnames.h,v
retrieving revision 1.7
diff -u -r1.7 pathnames.h
--- lib/pathnames.h 2 Jun 2002 05:25:15 -0000 1.7
+++ lib/pathnames.h 2 Aug 2005 22:22:08 -0000
@@ -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"
Index: lib/ipx_gr.c
===================================================================
RCS file: /cvs/net-tools/lib/ipx_gr.c,v
retrieving revision 1.6
diff -u -r1.6 ipx_gr.c
--- lib/ipx_gr.c 8 Oct 2000 01:00:44 -0000 1.6
+++ lib/ipx_gr.c 2 Aug 2005 22:22:09 -0000
@@ -38,19 +38,25 @@
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 */
Index: netstat.c
===================================================================
RCS file: /cvs/net-tools/netstat.c,v
retrieving revision 1.51
diff -u -r1.51 netstat.c
--- netstat.c 3 Jun 2004 22:27:37 -0000 1.51
+++ netstat.c 2 Aug 2005 22:22:09 -0000
@@ -1363,18 +1363,37 @@
char sad[50], dad[50];
struct sockaddr sa;
unsigned sport = 0, dport = 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");
- 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);
+ /* 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 @@
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 @@
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