- 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) {
-#ifndef KVMLIB
- if (klseek(kmem, (off_t)nl[N_SOFTC].n_value, 0) < 0)
- if(errno != EINTR)
- perror("kmem seek");
- if (read(kmem, (char *)sc, sizeof(STRUCT)) <= 0)
- perror("kmem read");
-#else
-#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");
-#endif
+ sprintf(req.ifr_name, "ppp%d", unit);
+ sprintf(creq.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);
+ }
+ if ((cflag || rflag) && ioctl(s, SIOCGPPPCSTATS, &creq) < 0) {
+ if (errno == ENOTTY) {
+ fprintf(stderr, "pppstats: no kernel compression support\n");
+ if (cflag)
+ exit(1);
+ rflag = 0;
+ } else {
+ perror("ioctl(SIOCGPPPCSTATS)");
+ exit(1);
+ }
+ }
+ (void)signal(SIGALRM, catchalarm);
+ signalled = 0;
+ (void)alarm(interval);
+
+ if ((line % 20) == 0) {
+ if (line > 0)
+ putchar('\n');
+ if (cflag) {
+
+ printf("%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
+ "ubyte", "upack", "cbyte", "cpack", "ibyte", "ipack", "ratio");
+ printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
+ "ubyte", "upack", "cbyte", "cpack", "ibyte", "ipack", "ratio");
+ putchar('\n');
+ } else {