From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96076332421588.tru64-unix-managers.marc@archive.invalid> From: Andrew Brennan Date: Wed, 29 May 1996 18:57:28 +0000 To: tru64-unix-managers Subject: SUMMARY: Zero'ng the interface counters?? X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96076332421588 Two weeks ago, I posted a request for a way to zero out the counters on an ethernet interface without rebooting the machine. I received a note relaying DEC info that it's not possible without downing the interface (from Andy Saylor - asaylor@alpha.comsource.net) and one from Dan Riley (dsr@lns598.lns.cornell.edu) with a small program to zero the counters. I've included Dan's message in case someone else needs the same & would rather not reboot their machine (and lose an RZ74 like we did :^p ) andrew. (brennan@crashprone.hahnemann.edu) ---Dan Riley's message/program--- There's an ioctl to do it. The following program shows how (takes one arg, the name of the interface, should be run as root): #include #include #include #include #include #include #include #include #include #include #include main(int argc, char **argv) { int af = AF_INET; int s; struct ctrreq ifctr; if (argc != 2) { fprintf(stderr, "usage: %s interface", argv[0]); exit(1); } argc--, argv++; strncpy(ifctr.ctr_name, *argv, sizeof(ifctr.ctr_name)); s = socket(af, SOCK_DGRAM, 0); if (s < 0) { perror("ifclr: socket"); exit(1); } if (ioctl(s, SIOCRDZCTRS, &ifctr) < 0) { perror("ioctl (SIOCRDZCTRS)"); exit(1); } printf("rec %d sent %d col %d %d\n", ifctr.ctr_ether.est_blokrcvd, ifctr.ctr_ether.est_bloksent, ifctr.ctr_ether.est_single, ifctr.ctr_ether.est_multiple); }