- register int line = 0;
- int oldmask;
-#ifdef __STDC__
- void catchalarm(int);
-#else
- void catchalarm();
-#endif
-
-#ifdef STREAMS
-#define STRUCT struct ppp_if_info
-#else
-#define STRUCT struct ppp_softc
-#endif
-
- STRUCT *sc, *osc;
-
- nl[N_SOFTC].n_value += unit * sizeof(struct ppp_softc);
- sc = (STRUCT *)malloc(sizeof(STRUCT));
- osc = (STRUCT *)malloc(sizeof(STRUCT));
-
- bzero((char *)osc, sizeof(STRUCT));
-
- while (1) {
-#ifdef sun
- if (kvm_read(kd, nl[N_SOFTC].n_value,
-#else
- if (kvm_read(nl[N_SOFTC].n_value,
-#endif
- sc, sizeof(STRUCT)) !=
- sizeof(STRUCT))
- perror("kvm_read");
-
- (void)signal(SIGALRM, catchalarm);
- signalled = 0;
- (void)alarm(interval);
-
- if ((line % 20) == 0) {
- printf("%6.6s %6.6s %6.6s %6.6s %6.6s",
- "in", "pack", "comp", "uncomp", "err");
- if (vflag)
- printf(" %6.6s %6.6s", "toss", "ip");
- printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s",
- "out", "pack", "comp", "uncomp", "ip");
- if (vflag)
- printf(" %6.6s %6.6s", "search", "miss");
- putchar('\n');
- }
-
-#ifdef STREAMS
-#define COMP pii_sc_comp
-#define STATS pii_ifnet
-#else
-#define COMP sc_comp
-#define STATS sc_if
-#endif
-
- printf("%6d %6d %6d %6d %6d",
-#if BSD > 43
- V(STATS.if_ibytes),
-#else
- 0,
-#endif
- V(STATS.if_ipackets),
- V(COMP.sls_compressedin),
- V(COMP.sls_uncompressedin),
- V(COMP.sls_errorin));
- if (vflag)
- printf(" %6d %6d",
- V(COMP.sls_tossed),
- V(STATS.if_ipackets) -
- V(COMP.sls_compressedin) -
- V(COMP.sls_uncompressedin) -
- V(COMP.sls_errorin));
- printf(" | %6d %6d %6d %6d %6d",
-#if BSD > 43
- V(STATS.if_obytes),
-#else
- 0,
-#endif
- V(STATS.if_opackets),
- V(COMP.sls_compressed),
- V(COMP.sls_packets) - V(COMP.sls_compressed),
- V(STATS.if_opackets) - V(COMP.sls_packets));
- if (vflag)
- printf(" %6d %6d",
- V(COMP.sls_searches),
- V(COMP.sls_misses));
+ register int line = 0;
+ int oldmask;
+ struct ifpppstatsreq req;
+ struct ppp_stats osc;
+
+ bzero(&osc, sizeof(osc));
+
+ sprintf(req.ifr_name, "ppp%d", unit);
+ while (1) {
+ if (ioctl(s, SIOCGPPPSTATS, &req) < 0) {
+ if (errno == ENOTTY)
+ fprintf(stderr, "pppstats: kernel support missing\n");
+ else
+ perror("ioctl(SIOCGPPPSTATS)");
+ exit(1);
+ }
+ (void)signal(SIGALRM, catchalarm);
+ signalled = 0;
+ (void)alarm(interval);
+
+ if ((line % 20) == 0) {
+ printf("%6.6s %6.6s %6.6s %6.6s %6.6s",
+ "in", "pack", "comp", "uncomp", "err");
+ if (vflag)
+ printf(" %6.6s %6.6s", "toss", "ip");
+ printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s",
+ "out", "pack", "comp", "uncomp", "ip");
+ if (vflag)
+ printf(" %6.6s %6.6s", "search", "miss");
+ putchar('\n');
+ }