const char *Rext = "b"; const char *Text = "b";
const char *Rext = "B"; const char *Text = "B";
void ife_print_long(struct interface *ptr){    struct aftype *ap;    struct hwtype *hw;    int hf;    int can_compress = 0;    unsigned long long rx, tx, short_rx, short_tx;    const char *Rext = "b";    const char *Text = "b";    static char flags[200];    #if HAVE_AFIPX    static struct aftype *ipxtype = NULL;#endif#if HAVE_AFECONET    static struct aftype *ectype = NULL;#endif#if HAVE_AFATALK    static struct aftype *ddptype = NULL;#endif#if HAVE_AFINET6    FILE *f;    char addr6[40], devname[20];    struct sockaddr_in6 sap;    int plen, scope, dad_status, if_idx;    extern struct aftype inet6_aftype;    char addr6p[8][5];#endif    ap = get_afntype(ptr->addr.sa_family);    if (ap == NULL)	ap = get_afntype(0);    hf = ptr->type;    if (hf == ARPHRD_CSLIP || hf == ARPHRD_CSLIP6)	can_compress = 1;    hw = get_hwntype(hf);    if (hw == NULL)	hw = get_hwntype(-1);    sprintf(flags, "flags=%d<", ptr->flags);    /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */    if (ptr->flags == 0)	strcat(flags,">");    if (ptr->flags & IFF_UP)	strcat(flags,_("UP,"));    if (ptr->flags & IFF_BROADCAST)	strcat(flags,_("BROADCAST,"));    if (ptr->flags & IFF_DEBUG)	strcat(flags,_("DEBUG,"));    if (ptr->flags & IFF_LOOPBACK)	strcat(flags,_("LOOPBACK,"));    if (ptr->flags & IFF_POINTOPOINT)	strcat(flags,_("POINTOPOINT,"));    if (ptr->flags & IFF_NOTRAILERS)	strcat(flags,_("NOTRAILERS,"));    if (ptr->flags & IFF_RUNNING)	strcat(flags,_("RUNNING,"));    if (ptr->flags & IFF_NOARP)	strcat(flags,_("NOARP,"));    if (ptr->flags & IFF_PROMISC)	strcat(flags,_("PROMISC,"));    if (ptr->flags & IFF_ALLMULTI)	strcat(flags,_("ALLMULTI,"));    if (ptr->flags & IFF_SLAVE)	strcat(flags,_("SLAVE,"));    if (ptr->flags & IFF_MASTER)	strcat(flags,_("MASTER,"));    if (ptr->flags & IFF_MULTICAST)	strcat(flags,_("MULTICAST,"));#ifdef HAVE_DYNAMIC    if (ptr->flags & IFF_DYNAMIC)	strcat(flags,_("DYNAMIC,"));#endif    /* DONT FORGET TO ADD THE FLAGS IN ife_print_short */    if (flags[strlen(flags)-1] == ',')      flags[strlen(flags)-1] = '>';    else      flags[strlen(flags)-1] = 0;          printf(_("%s: %s  mtu %d  metric %d"),	   ptr->name, flags, ptr->mtu, ptr->metric ? ptr->metric : 1);#ifdef SIOCSKEEPALIVE    if (ptr->outfill || ptr->keepalive)	printf(_("  outfill %d  keepalive %d"),	       ptr->outfill, ptr->keepalive);#endif    printf("\n");#if HAVE_AFINET    if (ptr->has_ip) {	printf(_("        %s %s"), ap->name,	       ap->sprint(&ptr->addr, 1));	printf(_("  netmask %s"), ap->sprint(&ptr->netmask, 1));	if (ptr->flags & IFF_BROADCAST) {	    printf(_("  broadcast %s"), ap->sprint(&ptr->broadaddr, 1));	}	if (ptr->flags & IFF_POINTOPOINT) {	    printf(_("  destination %s"), ap->sprint(&ptr->dstaddr, 1));	}	printf("\n");    }#endif#if HAVE_AFINET6    /* FIXME: should be integrated into interface.c.   */    if ((f = fopen(_PATH_PROCNET_IFINET6, "r")) != NULL) {	while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n",		      addr6p[0], addr6p[1], addr6p[2], addr6p[3],		      addr6p[4], addr6p[5], addr6p[6], addr6p[7],		  &if_idx, &plen, &scope, &dad_status, devname) != EOF) {	    if (!strcmp(devname, ptr->name)) {		sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",			addr6p[0], addr6p[1], addr6p[2], addr6p[3],			addr6p[4], addr6p[5], addr6p[6], addr6p[7]);		inet6_aftype.input(1, addr6, (struct sockaddr *) &sap);		printf(_("        %s %s  prefixlen %d"),			inet6_aftype.name, 			inet6_aftype.sprint((struct sockaddr *) &sap, 1), 			plen);		printf(_("  scopeid 0x%x"), scope);		flags[0] = '<'; flags[1] = 0;		if (scope & IPV6_ADDR_COMPATv4) {		    	strcat(flags, _("compat,"));		    	scope -= IPV6_ADDR_COMPATv4;		}		if (scope == 0)			strcat(flags, _("global,"));		if (scope & IPV6_ADDR_LINKLOCAL)			strcat(flags, _("link,"));		if (scope & IPV6_ADDR_SITELOCAL)			strcat(flags, _("site,"));		if (scope & IPV6_ADDR_LOOPBACK)			strcat(flags, _("host,"));		if (flags[strlen(flags)-1] == ',')			flags[strlen(flags)-1] = '>';		else			flags[strlen(flags)-1] = 0;		printf("%s\n", flags);	    }	}	fclose(f);    }#endif#if HAVE_AFIPX    if (ipxtype == NULL)	ipxtype = get_afntype(AF_IPX);    if (ipxtype != NULL) {	if (ptr->has_ipx_bb)	    printf(_("        %s Ethernet-II   %s\n"),		   ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_bb, 1));	if (ptr->has_ipx_sn)	    printf(_("        %s Ethernet-SNAP %s\n"),		   ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_sn, 1));	if (ptr->has_ipx_e2)	    printf(_("        %s Ethernet802.2 %s\n"),		   ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_e2, 1));	if (ptr->has_ipx_e3)	    printf(_("        %s Ethernet802.3 %s\n"),		   ipxtype->name, ipxtype->sprint(&ptr->ipxaddr_e3, 1));    }#endif#if HAVE_AFATALK    if (ddptype == NULL)	ddptype = get_afntype(AF_APPLETALK);    if (ddptype != NULL) {	if (ptr->has_ddp)	    printf(_("        %s %s\n"), ddptype->name, ddptype->sprint(&ptr->ddpaddr, 1));    }#endif#if HAVE_AFECONET    if (ectype == NULL)	ectype = get_afntype(AF_ECONET);    if (ectype != NULL) {	if (ptr->has_econet)	    printf(_("        %s %s\n"), ectype->name, ectype->sprint(&ptr->ecaddr, 1));    }#endif    /* For some hardware types (eg Ash, ATM) we don't print the        hardware address if it's null.  */    if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&				  hw->suppress_null_addr)))	printf(_("        %s %s"), hw->name, hw->print(ptr->hwaddr));    else	printf(_("        %s"), hw->name);    if (ptr->tx_queue_len != -1)    	printf(_("  txqueuelen %d"), ptr->tx_queue_len);    printf("  (%s)\n", hw->title);#ifdef IFF_PORTSEL    if (ptr->flags & IFF_PORTSEL) {	printf(_("        media %s"), if_port_text[ptr->map.port][0]);	if (ptr->flags & IFF_AUTOMEDIA)	    printf(_("autoselect"));    	printf("\n");    }#endif    /* If needed, display the interface statistics. */    if (ptr->statistics_valid) {	/* XXX: statistics are currently only printed for the primary address,	 *      not for the aliases, although strictly speaking they're shared	 *      by all addresses.	 */	rx = ptr->stats.rx_bytes;  	short_rx = rx * 10;  	if (rx > 1125899906842624ull) {	    short_rx /= 1125899906842624ull;	    Rext = "PiB";	} else if (rx > 1099511627776ull) {	    short_rx /= 1099511627776ull;	    Rext = "TiB";	} else if (rx > 1073741824ull) {	    short_rx /= 1073741824ull;	    Rext = "GiB";	} else if (rx > 1048576) {	    short_rx /= 1048576;	    Rext = "MiB";	} else if (rx > 1024) {	    short_rx /= 1024;	    Rext = "KiB";	}	tx = ptr->stats.tx_bytes;	short_tx = tx * 10;	if (tx > 1125899906842624ull) {	    short_tx /= 1125899906842624ull;	    Text = "PiB";	} else 	if (tx > 1099511627776ull) {	    short_tx /= 1099511627776ull;	    Text = "TiB";	} else if (tx > 1073741824ull) {	    short_tx /= 1073741824ull;	    Text = "GiB";	} else if (tx > 1048576) {	    short_tx /= 1048576;	    Text = "MiB";	} else if (tx > 1024) {	    short_tx /= 1024;	    Text = "KiB";	}	printf("        ");	printf(_("RX packets %llu  bytes %llu (%lu.%lu %s)\n"), 		ptr->stats.rx_packets, 	       rx, (unsigned long)(short_rx / 10), 	       (unsigned long)(short_rx % 10), Rext);	if (can_compress) {  	    printf("        ");	    printf(_("RX compressed:%lu\n"), ptr->stats.rx_compressed);	}	printf("        ");	printf(_("RX errors %lu  dropped %lu  overruns %lu  frame %lu\n"),	       ptr->stats.rx_errors, ptr->stats.rx_dropped, 	       ptr->stats.rx_fifo_errors, ptr->stats.rx_frame_errors);	printf("        ");	printf(_("TX packets %llu  bytes %llu (%lu.%lu %s)\n"),		ptr->stats.tx_packets, 	        tx, (unsigned long)(short_tx / 10), 	        (unsigned long)(short_tx % 10), Text);	if (can_compress) {  	    printf("        ");	    printf(_("TX compressed %lu\n"), ptr->stats.tx_compressed);	}	printf("        ");	printf(_("TX errors %lu  dropped %lu overruns %lu  carrier %lu  collisions %lu\n"),	       ptr->stats.tx_errors,	       ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,	       ptr->stats.tx_carrier_errors, ptr->stats.collisions);    }    if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||	 ptr->map.base_addr >= 0x100)) {	printf("        device ");	if (ptr->map.irq)	    printf(_("interrupt %d  "), ptr->map.irq);	if (ptr->map.base_addr >= 0x100)	/* Only print devices using it for 						   I/O maps */	    printf(_("base 0x%x  "), ptr->map.base_addr);	if (ptr->map.mem_start) {	    printf(_("memory 0x%lx-%lx  "), ptr->map.mem_start, ptr->map.mem_end);	}	if (ptr->map.dma)	    printf(_("  dma 0x%x"), ptr->map.dma);	printf("\n");    }    printf("\n");}