Initial import of xisp-2.5p4, a user-friendly X11 interface to pppd/chat.
[pkgsrc.git] / comms / xisp / patches / patch-ac
1 $NetBSD$
2
3 --- network.c.orig      Mon Oct 26 05:35:01 1998
4 +++ network.c   Mon Nov 30 18:25:26 1998
5 @@ -26,13 +26,14 @@
6  #include <net/if.h>
7  #include <arpa/inet.h>
8  #include <string.h>
9 +#include <sys/param.h>
10  #include <unistd.h>
11  
12  #ifdef SUNOS41x
13   extern int socket(), ioctl(), sscanf(), printf(), pclose();
14  #elif defined(SUNOS5x)
15   #include <sys/sockio.h>
16 -#else
17 +#elif !(defined(BSD) && BSD >= 199306)
18  
19  /* Returns kernel revision number (10*major+minor). Only used on Linux to
20     figure out what kind of parsing format to use for /proc/net/dev output */
21 @@ -92,6 +93,10 @@
22   #define AddrOpen   popen("/usr/bin/netstat -nr", "r")
23   #define AddrScanf  sscanf(routeLine, "%*s %*s %*s %*s %*s %s", IF)
24   #define AddrClose  while (fgets(routeLine,128,infofp) != NULL); pclose(infofp)
25 +#elif (defined(BSD) && BSD >= 199306)
26 + #define AddrOpen   popen("/usr/bin/netstat -nr", "r")
27 + #define AddrScanf  sscanf(routeLine, "%*s %*s %*s %*s %*s %*s %s", IF)
28 + #define AddrClose  while (fgets(routeLine,128,infofp) != NULL); pclose(infofp)
29  #else
30   #define AddrOpen   fopen("/proc/net/route", "r")
31   #define AddrScanf  sscanf(routeLine,"%s", IF)
32 @@ -137,6 +142,12 @@
33   #define PktsScanf sscanf(line, "%s %*s %*s %*s %u %*s %u", \
34                                                   interface, &recv, &trans)
35   #define PktsClose while (fgets(line,128,infofp) != NULL); pclose(infofp)
36 +#elif (defined(BSD) && BSD >= 199306)
37 + #define PktsOpen  popen((sprintf(line,"/usr/bin/netstat -n -I %s",IFName)) ? \
38 +                                                line:line, "r")
39 + #define PktsScanf sscanf(line, "%s %*s %s %*s %u %*s %u", \
40 +                                                 interface, network, &recv, &trans)
41 + #define PktsClose while (fgets(line,128,infofp) != NULL); pclose(infofp)
42  #else
43   #define PktsOpen  fopen("/proc/net/dev", "r")
44   #define PktsScanf sscanf(line, ((kernelRevNo()>20) ? \
45 @@ -151,16 +162,26 @@
46      int IFLen = strlen(IFName);
47      FILE *infofp;
48      char line[129], interface[16];
49 +#if (defined(BSD) && BSD >= 199306)
50 +    char network[16];
51 +#endif
52      unsigned recv = 0, trans = 0;
53  
54         infofp = PktsOpen;                                                      /* open IF stats info stream */
55      while (fgets(line, 128, infofp) != NULL) {
56                 PktsScanf;                                                              /* read line by line */
57                 if (!strncmp(interface,IFName,IFLen)) { /* scanning for interface */
58 +#if (defined(BSD) && BSD >= 199306)
59 +                       /* Discard non-conforming multicast line. */
60 +                       if (strncmp(network,"<Link>",strlen(network))) {
61 +#endif
62                         PktsClose;                                                      /* found, close info stream */
63                         if (pTX) *pTX = trans;                          /* if return storage avail */
64                         if (pRX) *pRX = recv;                           /* save TXed/RXed separately */
65                         return (recv + trans);                          /* return total I/O packets */
66 +#if (defined(BSD) && BSD >= 199306)
67 +                       }
68 +#endif
69                 }
70         }
71         PktsClose;                                                                      /* close info stream */