summaryrefslogtreecommitdiff
path: root/comms/xisp/patches/patch-ac
blob: f1e579eaabe1e2c76ae499ecf0dfb80877beb2e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
$NetBSD: patch-ac,v 1.1.1.1 1998/12/03 15:08:53 frueauf Exp $

--- network.c.orig	Mon Oct 26 05:35:01 1998
+++ network.c	Mon Nov 30 18:25:26 1998
@@ -26,13 +26,14 @@
 #include <net/if.h>
 #include <arpa/inet.h>
 #include <string.h>
+#include <sys/param.h>
 #include <unistd.h>
 
 #ifdef SUNOS41x
  extern int socket(), ioctl(), sscanf(), printf(), pclose();
 #elif defined(SUNOS5x)
  #include <sys/sockio.h>
-#else
+#elif !(defined(BSD) && BSD >= 199306)
 
 /* Returns kernel revision number (10*major+minor). Only used on Linux to
    figure out what kind of parsing format to use for /proc/net/dev output */
@@ -92,6 +93,10 @@
  #define AddrOpen   popen("/usr/bin/netstat -nr", "r")
  #define AddrScanf  sscanf(routeLine, "%*s %*s %*s %*s %*s %s", IF)
  #define AddrClose  while (fgets(routeLine,128,infofp) != NULL); pclose(infofp)
+#elif (defined(BSD) && BSD >= 199306)
+ #define AddrOpen   popen("/usr/bin/netstat -nr", "r")
+ #define AddrScanf  sscanf(routeLine, "%*s %*s %*s %*s %*s %*s %s", IF)
+ #define AddrClose  while (fgets(routeLine,128,infofp) != NULL); pclose(infofp)
 #else
  #define AddrOpen   fopen("/proc/net/route", "r")
  #define AddrScanf  sscanf(routeLine,"%s", IF)
@@ -137,6 +142,12 @@
  #define PktsScanf sscanf(line, "%s %*s %*s %*s %u %*s %u", \
 						  interface, &recv, &trans)
  #define PktsClose while (fgets(line,128,infofp) != NULL); pclose(infofp)
+#elif (defined(BSD) && BSD >= 199306)
+ #define PktsOpen  popen((sprintf(line,"/usr/bin/netstat -n -I %s",IFName)) ? \
+						 line:line, "r")
+ #define PktsScanf sscanf(line, "%s %*s %s %*s %u %*s %u", \
+						  interface, network, &recv, &trans)
+ #define PktsClose while (fgets(line,128,infofp) != NULL); pclose(infofp)
 #else
  #define PktsOpen  fopen("/proc/net/dev", "r")
  #define PktsScanf sscanf(line, ((kernelRevNo()>20) ? \
@@ -151,16 +162,26 @@
     int IFLen = strlen(IFName);
     FILE *infofp;
     char line[129], interface[16];
+#if (defined(BSD) && BSD >= 199306)
+    char network[16];
+#endif
     unsigned recv = 0, trans = 0;
 
 	infofp = PktsOpen;							/* open IF stats info stream */
     while (fgets(line, 128, infofp) != NULL) {
 		PktsScanf;								/* read line by line */
 		if (!strncmp(interface,IFName,IFLen)) {	/* scanning for interface */
+#if (defined(BSD) && BSD >= 199306)
+			/* Discard non-conforming multicast line. */
+			if (strncmp(network,"<Link>",strlen(network))) {
+#endif
 			PktsClose;							/* found, close info stream */
 			if (pTX) *pTX = trans;				/* if return storage avail */
 			if (pRX) *pRX = recv;				/* save TXed/RXed separately */
 			return (recv + trans);				/* return total I/O packets */
+#if (defined(BSD) && BSD >= 199306)
+			}
+#endif
 		}
 	}
 	PktsClose;									/* close info stream */