ip->ift_name[0] = '('; bcopy(ifnet.if_xname, ip->ift_name + 1, IFNAMSIZ - 1); if (interface && strcmp(ip->ift_name + 1, interface) == 0)
bzero(ip->ift_name, sizeof(ip->ift_name)); snprintf(ip->ift_name, IFNAMSIZ, "(%s)", ifnet.if_xname); if (interface && strcmp(ifnet.if_xname, interface) == 0)
sidewaysintpr(interval, off)	unsigned interval;	u_long off;{	struct ifnet ifnet;	u_long firstifnet;	register struct iftot *ip, *total;	register int line;	struct iftot *lastif, *sum, *interesting;	struct ifnet_head ifhead;	/* TAILQ_HEAD */	int oldmask;	/*	 * Find the pointer to the first ifnet structure.  Replace	 * the pointer to the TAILQ_HEAD with the actual pointer	 * to the first list element.	 */	if (kread(off, (char *)&ifhead, sizeof ifhead))		return;	firstifnet = (u_long)ifhead.tqh_first;	lastif = iftot;	sum = iftot + MAXIF - 1;	total = sum - 1;	interesting = (interface == NULL) ? iftot : NULL;	for (off = firstifnet, ip = iftot; off;) {		if (kread(off, (char *)&ifnet, sizeof ifnet))			break;		ip->ift_name[0] = '(';		bcopy(ifnet.if_xname, ip->ift_name + 1, IFNAMSIZ - 1);		if (interface &&		    strcmp(ip->ift_name + 1, interface) == 0)			interesting = ip;		ip->ift_name[IFNAMSIZ - 1] = '\0';		ip++;		if (ip >= iftot + MAXIF - 2)			break;		off = (u_long)ifnet.if_list.tqe_next;	}	if (interesting == NULL) {		fprintf(stderr, "%s: %s: unknown interface\n",		    __progname, interface);		exit(1);	}	lastif = ip;	(void)signal(SIGALRM, catchalarm);	signalled = NO;	(void)alarm(interval);banner:	printf("   input    %-6.6s    output       ", interesting->ift_name);	if (lastif - iftot > 0) {		if (dflag)			printf("      ");		printf("     input   (Total)    output");	}	for (ip = iftot; ip < iftot + MAXIF; ip++) {		ip->ift_ip = 0;		ip->ift_ie = 0;		ip->ift_op = 0;		ip->ift_oe = 0;		ip->ift_co = 0;		ip->ift_dr = 0;	}	putchar('\n');	printf("%8.8s %5.5s %8.8s %5.5s %5.5s ",		"packets", "errs", "packets", "errs", "colls");	if (dflag)		printf("%5.5s ", "drops");	if (lastif - iftot > 0)		printf(" %8.8s %5.5s %8.8s %5.5s %5.5s",			"packets", "errs", "packets", "errs", "colls");	if (dflag)		printf(" %5.5s", "drops");	putchar('\n');	fflush(stdout);	line = 0;loop:	sum->ift_ip = 0;	sum->ift_ie = 0;	sum->ift_op = 0;	sum->ift_oe = 0;	sum->ift_co = 0;	sum->ift_dr = 0;	for (off = firstifnet, ip = iftot; off && ip < lastif; ip++) {		if (kread(off, (char *)&ifnet, sizeof ifnet)) {			off = 0;			continue;		}		if (ip == interesting) {			printf("%8d %5d %8d %5d %5d",				ifnet.if_ipackets - ip->ift_ip,				ifnet.if_ierrors - ip->ift_ie,				ifnet.if_opackets - ip->ift_op,				ifnet.if_oerrors - ip->ift_oe,				ifnet.if_collisions - ip->ift_co);			if (dflag)				printf(" %5d",				    ifnet.if_snd.ifq_drops - ip->ift_dr);		}		ip->ift_ip = ifnet.if_ipackets;		ip->ift_ie = ifnet.if_ierrors;		ip->ift_op = ifnet.if_opackets;		ip->ift_oe = ifnet.if_oerrors;		ip->ift_co = ifnet.if_collisions;		ip->ift_dr = ifnet.if_snd.ifq_drops;		sum->ift_ip += ip->ift_ip;		sum->ift_ie += ip->ift_ie;		sum->ift_op += ip->ift_op;		sum->ift_oe += ip->ift_oe;		sum->ift_co += ip->ift_co;		sum->ift_dr += ip->ift_dr;		off = (u_long)ifnet.if_list.tqe_next;	}	if (lastif - iftot > 0) {		printf("  %8d %5d %8d %5d %5d",			sum->ift_ip - total->ift_ip,			sum->ift_ie - total->ift_ie,			sum->ift_op - total->ift_op,			sum->ift_oe - total->ift_oe,			sum->ift_co - total->ift_co);		if (dflag)			printf(" %5d", sum->ift_dr - total->ift_dr);	}	*total = *sum;	putchar('\n');	fflush(stdout);	line++;	oldmask = sigblock(sigmask(SIGALRM));	if (! signalled) {		sigpause(0);	}	sigsetmask(oldmask);	signalled = NO;	(void)alarm(interval);	if (line == 21)		goto banner;	goto loop;	/*NOTREACHED*/}