/*
 * stolen from net-tools-1.59 and stripped down for busybox by
 *			Erik Andersen <andersen@codepoet.org>
 *
 * Heavily modified by Manuel Novoa III       Mar 12, 2001
 *
 * Pruned unused code using KEEP_UNUSED define.
 * Added print_bytes_scaled function to reduce code size.
 * Added some (potentially) missing defines.
 * Improved display support for -a and for a named interface.
 *
 * -----------------------------------------------------------
 *
 * ifconfig   This file contains an implementation of the command
 *              that either displays or sets the characteristics of
 *              one or more of the system's networking interfaces.
 *
 * Version:     $Id: interface.c,v 1.25 2004/08/26 21:45:21 andersen Exp $
 *
 * Author:      Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
 *              and others.  Copyright 1993 MicroWalt Corporation
 *
 *              This program is free software; you can redistribute it
 *              and/or  modify it under  the terms of  the GNU General
 *              Public  License as  published  by  the  Free  Software
 *              Foundation;  either  version 2 of the License, or  (at
 *              your option) any later version.
 *
 * Patched to support 'add' and 'del' keywords for INET(4) addresses
 * by Mrs. Brisby <mrs.brisby@nimh.org>
 *
 * {1.34} - 19980630 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
 *                     - gettext instead of catgets for i18n
 *          10/1998  - Andi Kleen. Use interface list primitives.
 *	    20001008 - Bernd Eckenfels, Patch from RH for setting mtu
 *			(default AF was wrong)
 */

/* #define KEEP_UNUSED */

/*
 *
 * Protocol Families.
 *
 */
#define HAVE_AFINET 1

/*
 *
 * Device Hardware types.
 *
 */
#define HAVE_HWETHER	1
#define HAVE_HWPPP	1
#undef HAVE_HWSLIP


#include "inet_common.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <net/if.h>
#include <net/if_arp.h>
#include "busybox.h"

#ifdef CONFIG_FEATURE_IPV6
# define HAVE_AFINET6 1
#else
# undef HAVE_AFINET6
#endif

#define _PATH_PROCNET_DEV               "/proc/net/dev"
#define _PATH_PROCNET_IFINET6           "/proc/net/if_inet6"
#define new(p) ((p) = xcalloc(1,sizeof(*(p))))
#define KRELEASE(maj,min,patch) ((maj) * 65536 + (min)*256 + (patch))

#ifdef HAVE_HWSLIP
#include <net/if_slip.h>
#endif

#if HAVE_AFINET6

#ifndef _LINUX_IN6_H
/*
 *    This is in linux/include/net/ipv6.h.
 */

struct in6_ifreq {
	struct in6_addr ifr6_addr;
	uint32_t ifr6_prefixlen;
	unsigned int ifr6_ifindex;
};

#endif

#endif							/* HAVE_AFINET6 */

/* Defines for glibc2.0 users. */
#ifndef SIOCSIFTXQLEN
#define SIOCSIFTXQLEN      0x8943
#define SIOCGIFTXQLEN      0x8942
#endif

/* ifr_qlen is ifru_ivalue, but it isn't present in 2.0 kernel headers */
#ifndef ifr_qlen
#define ifr_qlen        ifr_ifru.ifru_mtu
#endif

#ifndef HAVE_TXQUEUELEN
#define HAVE_TXQUEUELEN 1
#endif

#ifndef IFF_DYNAMIC
#define IFF_DYNAMIC     0x8000	/* dialup device with changing addresses */
#endif

/* This structure defines protocol families and their handlers. */
struct aftype {
	const char *name;
	const char *title;
	int af;
	int alen;
	char *(*print) (unsigned char *);
	char *(*sprint) (struct sockaddr *, int numeric);
	int (*input) (int type, char *bufp, struct sockaddr *);
	void (*herror) (char *text);
	int (*rprint) (int options);
	int (*rinput) (int typ, int ext, char **argv);

	/* may modify src */
	int (*getmask) (char *src, struct sockaddr * mask, char *name);

	int fd;
	char *flag_file;
};

#ifdef KEEP_UNUSED

static int flag_unx;
static int flag_inet;

static struct aftrans_t {
	char *alias;
	char *name;
	int *flag;
} aftrans[] = {

	{
	"ip", "inet", &flag_inet},
#ifdef HAVE_AFINET6
	{
	"ip6", "inet6", &flag_inet6},
#endif
	{
	"inet", "inet", &flag_inet},
#ifdef HAVE_AFINET6
	{
	"inet6", "inet6", &flag_inet6},
#endif
	{
	"unix", "unix", &flag_unx}, {
	"tcpip", "inet", &flag_inet},
	{
	0, 0, 0}
};

static char afname[256] = "";
#endif							/* KEEP_UNUSED */

#if HAVE_AFUNIX

/* Display a UNIX domain address. */
static char *UNIX_print(unsigned char *ptr)
{
	return (ptr);
}


/* Display a UNIX domain address. */
static char *UNIX_sprint(struct sockaddr *sap, int numeric)
{
	static char buf[64];

	if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
		return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
	return (UNIX_print(sap->sa_data));
}


static struct aftype unix_aftype = {
	"unix", "UNIX Domain", AF_UNIX, 0,
	UNIX_print, UNIX_sprint, NULL, NULL,
	NULL, NULL, NULL,
	-1,
	"/proc/net/unix"
};
#endif							/* HAVE_AFUNIX */

#if HAVE_AFINET

#ifdef KEEP_UNUSED
static void INET_reserror(char *text)
{
	herror(text);
}

/* Display an Internet socket address. */
static char *INET_print(unsigned char *ptr)
{
	return (inet_ntoa((*(struct in_addr *) ptr)));
}
#endif							/* KEEP_UNUSED */

/* Display an Internet socket address. */
static char *INET_sprint(struct sockaddr *sap, int numeric)
{
	static char buff[128];

	if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
		return safe_strncpy(buff, _("[NONE SET]"), sizeof(buff));

	if (INET_rresolve(buff, sizeof(buff), (struct sockaddr_in *) sap,
					  numeric, 0xffffff00) != 0)
		return (NULL);

	return (buff);
}

#ifdef KEEP_UNUSED
static char *INET_sprintmask(struct sockaddr *sap, int numeric,
							 unsigned int netmask)
{
	static char buff[128];

	if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
		return safe_strncpy(buff, _("[NONE SET]"), sizeof(buff));
	if (INET_rresolve(buff, sizeof(buff), (struct sockaddr_in *) sap,
					  numeric, netmask) != 0)
		return (NULL);
	return (buff);
}

static int INET_getsock(char *bufp, struct sockaddr *sap)
{
	char *sp = bufp, *bp;
	unsigned int i;
	unsigned val;
	struct sockaddr_in *sin;

	sin = (struct sockaddr_in *) sap;
	sin->sin_family = AF_INET;
	sin->sin_port = 0;

	val = 0;
	bp = (char *) &val;
	for (i = 0; i < sizeof(sin->sin_addr.s_addr); i++) {
		*sp = toupper(*sp);

		if ((*sp >= 'A') && (*sp <= 'F'))
			bp[i] |= (int) (*sp - 'A') + 10;
		else if ((*sp >= '0') && (*sp <= '9'))
			bp[i] |= (int) (*sp - '0');
		else
			return (-1);

		bp[i] <<= 4;
		sp++;
		*sp = toupper(*sp);

		if ((*sp >= 'A') && (*sp <= 'F'))
			bp[i] |= (int) (*sp - 'A') + 10;
		else if ((*sp >= '0') && (*sp <= '9'))
			bp[i] |= (int) (*sp - '0');
		else
			return (-1);

		sp++;
	}
	sin->sin_addr.s_addr = htonl(val);

	return (sp - bufp);
}

static int INET_input(int type, char *bufp, struct sockaddr *sap)
{
	switch (type) {
	case 1:
		return (INET_getsock(bufp, sap));
	case 256:
		return (INET_resolve(bufp, (struct sockaddr_in *) sap, 1));
	default:
		return (INET_resolve(bufp, (struct sockaddr_in *) sap, 0));
	}
}

static int INET_getnetmask(char *adr, struct sockaddr *m, char *name)
{
	struct sockaddr_in *mask = (struct sockaddr_in *) m;
	char *slash, *end;
	int prefix;

	if ((slash = strchr(adr, '/')) == NULL)
		return 0;

	*slash++ = '\0';
	prefix = strtoul(slash, &end, 0);
	if (*end != '\0')
		return -1;

	if (name) {
		sprintf(name, "/%d", prefix);
	}
	mask->sin_family = AF_INET;
	mask->sin_addr.s_addr = htonl(~(0xffffffffU >> prefix));
	return 1;
}
#endif							/* KEEP_UNUSED */

static struct aftype inet_aftype = {
	"inet", "DARPA Internet", AF_INET, sizeof(unsigned long),
	NULL /* UNUSED INET_print */ , INET_sprint,
	NULL /* UNUSED INET_input */ , NULL /* UNUSED INET_reserror */ ,
	NULL /*INET_rprint */ , NULL /*INET_rinput */ ,
	NULL /* UNUSED INET_getnetmask */ ,
	-1,
	NULL
};

#endif							/* HAVE_AFINET */

#if HAVE_AFINET6

#ifdef KEEP_UNUSED
static void INET6_reserror(char *text)
{
	herror(text);
}

/* Display an Internet socket address. */
static char *INET6_print(unsigned char *ptr)
{
	static char name[80];

	inet_ntop(AF_INET6, (struct in6_addr *) ptr, name, 80);
	return name;
}
#endif							/* KEEP_UNUSED */

/* Display an Internet socket address. */
/* dirty! struct sockaddr usually doesn't suffer for inet6 addresses, fst. */
static char *INET6_sprint(struct sockaddr *sap, int numeric)
{
	static char buff[128];

	if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
		return safe_strncpy(buff, _("[NONE SET]"), sizeof(buff));
	if (INET6_rresolve
		(buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric) != 0)
		return safe_strncpy(buff, _("[UNKNOWN]"), sizeof(buff));
	return (buff);
}

#ifdef KEEP_UNUSED
static int INET6_getsock(char *bufp, struct sockaddr *sap)
{
	struct sockaddr_in6 *sin6;

	sin6 = (struct sockaddr_in6 *) sap;
	sin6->sin6_family = AF_INET6;
	sin6->sin6_port = 0;

	if (inet_pton(AF_INET6, bufp, sin6->sin6_addr.s6_addr) <= 0)
		return (-1);

	return 16;			/* ?;) */
}

static int INET6_input(int type, char *bufp, struct sockaddr *sap)
{
	switch (type) {
	case 1:
		return (INET6_getsock(bufp, sap));
	default:
		return (INET6_resolve(bufp, (struct sockaddr_in6 *) sap));
	}
}
#endif							/* KEEP_UNUSED */

static struct aftype inet6_aftype = {
	"inet6", "IPv6", AF_INET6, sizeof(struct in6_addr),
	NULL /* UNUSED INET6_print */ , INET6_sprint,
	NULL /* UNUSED INET6_input */ , NULL /* UNUSED INET6_reserror */ ,
	NULL /*INET6_rprint */ , NULL /*INET6_rinput */ ,
	NULL /* UNUSED INET6_getnetmask */ ,
	-1,
	NULL
};

#endif							/* HAVE_AFINET6 */

/* Display an UNSPEC address. */
static char *UNSPEC_print(unsigned char *ptr)
{
	static char buff[sizeof(struct sockaddr) * 3 + 1];
	char *pos;
	unsigned int i;

	pos = buff;
	for (i = 0; i < sizeof(struct sockaddr); i++) {
		/* careful -- not every libc's sprintf returns # bytes written */
		sprintf(pos, "%02X-", (*ptr++ & 0377));
		pos += 3;
	}
	/* Erase trailing "-".  Works as long as sizeof(struct sockaddr) != 0 */
	*--pos = '\0';
	return (buff);
}

/* Display an UNSPEC socket address. */
static char *UNSPEC_sprint(struct sockaddr *sap, int numeric)
{
	static char buf[64];

	if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
		return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
	return (UNSPEC_print((unsigned char *)sap->sa_data));
}

static struct aftype unspec_aftype = {
	"unspec", "UNSPEC", AF_UNSPEC, 0,
	UNSPEC_print, UNSPEC_sprint, NULL, NULL,
	NULL,
};

static struct aftype * const aftypes[] = {
#if HAVE_AFUNIX
	&unix_aftype,
#endif
#if HAVE_AFINET
	&inet_aftype,
#endif
#if HAVE_AFINET6
	&inet6_aftype,
#endif
	&unspec_aftype,
	NULL
};

#ifdef KEEP_UNUSED
static short sVafinit = 0;

static void afinit()
{
	unspec_aftype.title = _("UNSPEC");
#if HAVE_AFUNIX
	unix_aftype.title = _("UNIX Domain");
#endif
#if HAVE_AFINET
	inet_aftype.title = _("DARPA Internet");
#endif
#if HAVE_AFINET6
	inet6_aftype.title = _("IPv6");
#endif
	sVafinit = 1;
}

static int aftrans_opt(const char *arg)
{
	struct aftrans_t *paft;
	char *tmp1, *tmp2;
	char buf[256];

	safe_strncpy(buf, arg, sizeof(buf));

	tmp1 = buf;

	while (tmp1) {

		tmp2 = strchr(tmp1, ',');

		if (tmp2)
			*(tmp2++) = '\0';

		paft = aftrans;
		for (paft = aftrans; paft->alias; paft++) {
			if (strcmp(tmp1, paft->alias))
				continue;
			if (strlen(paft->name) + strlen(afname) + 1 >= sizeof(afname)) {
				bb_error_msg(_("Too many address family arguments."));
				return (0);
			}
			if (paft->flag)
				(*paft->flag)++;
			if (afname[0])
				strcat(afname, ",");
			strcat(afname, paft->name);
			break;
		}
		if (!paft->alias) {
			bb_error_msg(_("Unknown address family `%s'."), tmp1);
			return (1);
		}
		tmp1 = tmp2;
	}

	return (0);
}

/* set the default AF list from the program name or a constant value    */
static void aftrans_def(char *tool, char *argv0, char *dflt)
{
	char *tmp;
	char *buf;

	strcpy(afname, dflt);

	if (!(tmp = strrchr(argv0, '/')))
		tmp = argv0;	/* no slash?! */
	else
		tmp++;

	if (!(buf = strdup(tmp)))
		return;

	if (strlen(tool) >= strlen(tmp)) {
		free(buf);
		return;
	}
	tmp = buf + (strlen(tmp) - strlen(tool));

	if (strcmp(tmp, tool) != 0) {
		free(buf);
		return;
	}
	*tmp = '\0';
	if ((tmp = strchr(buf, '_')))
		*tmp = '\0';

	afname[0] = '\0';
	if (aftrans_opt(buf))
		strcpy(afname, buf);

	free(buf);
}

/* Check our protocol family table for this family. */
static struct aftype *get_aftype(const char *name)
{
	struct aftype * const *afp;

#ifdef KEEP_UNUSED
	if (!sVafinit)
		afinit();
#endif							/* KEEP_UNUSED */

	afp = aftypes;
	while (*afp != NULL) {
		if (!strcmp((*afp)->name, name))
			return (*afp);
		afp++;
	}
	if (strchr(name, ','))
		bb_error_msg(_("Please don't supply more than one address family."));
	return (NULL);
}
#endif							/* KEEP_UNUSED */

/* Check our protocol family table for this family. */
static struct aftype *get_afntype(int af)
{
	struct aftype * const *afp;

#ifdef KEEP_UNUSED
	if (!sVafinit)
		afinit();
#endif							/* KEEP_UNUSED */

	afp = aftypes;
	while (*afp != NULL) {
		if ((*afp)->af == af)
			return (*afp);
		afp++;
	}
	return (NULL);
}

/* Check our protocol family table for this family and return its socket */
static int get_socket_for_af(int af)
{
	struct aftype * const *afp;

#ifdef KEEP_UNUSED
	if (!sVafinit)
		afinit();
#endif							/* KEEP_UNUSED */

	afp = aftypes;
	while (*afp != NULL) {
		if ((*afp)->af == af)
			return (*afp)->fd;
		afp++;
	}
	return -1;
}

#ifdef KEEP_UNUSED
/* type: 0=all, 1=getroute */
static void print_aflist(int type)
{
	int count = 0;
	char *txt;
	struct aftype * const *afp;

#ifdef KEEP_UNUSED
	if (!sVafinit)
		afinit();
#endif							/* KEEP_UNUSED */

	afp = aftypes;
	while (*afp != NULL) {
		if ((type == 1 && ((*afp)->rprint == NULL)) || ((*afp)->af == 0)) {
			afp++;
			continue;
		}
		if ((count % 3) == 0)
			fprintf(stderr, count ? "\n    " : "    ");
		txt = (*afp)->name;
		if (!txt)
			txt = "..";
		fprintf(stderr, "%s (%s) ", txt, _((*afp)->title));
		count++;
		afp++;
	}
	fprintf(stderr, "\n");
}
#endif							/* KEEP_UNUSED */

struct user_net_device_stats {
	unsigned long long rx_packets;	/* total packets received       */
	unsigned long long tx_packets;	/* total packets transmitted    */
	unsigned long long rx_bytes;	/* total bytes received         */
	unsigned long long tx_bytes;	/* total bytes transmitted      */
	unsigned long rx_errors;	/* bad packets received         */
	unsigned long tx_errors;	/* packet transmit problems     */
	unsigned long rx_dropped;	/* no space in linux buffers    */
	unsigned long tx_dropped;	/* no space available in linux  */
	unsigned long rx_multicast;	/* multicast packets received   */
	unsigned long rx_compressed;
	unsigned long tx_compressed;
	unsigned long collisions;

	/* detailed rx_errors: */
	unsigned long rx_length_errors;
	unsigned long rx_over_errors;	/* receiver ring buff overflow  */
	unsigned long rx_crc_errors;	/* recved pkt with crc error    */
	unsigned long rx_frame_errors;	/* recv'd frame alignment error */
	unsigned long rx_fifo_errors;	/* recv'r fifo overrun          */
	unsigned long rx_missed_errors;	/* receiver missed packet     */
	/* detailed tx_errors */
	unsigned long tx_aborted_errors;
	unsigned long tx_carrier_errors;
	unsigned long tx_fifo_errors;
	unsigned long tx_heartbeat_errors;
	unsigned long tx_window_errors;
};

struct interface {
	struct interface *next, *prev;
	char name[IFNAMSIZ];	/* interface name        */
	short type;			/* if type               */
	short flags;		/* various flags         */
	int metric;			/* routing metric        */
	int mtu;			/* MTU value             */
	int tx_queue_len;	/* transmit queue length */
	struct ifmap map;	/* hardware setup        */
	struct sockaddr addr;	/* IP address            */
	struct sockaddr dstaddr;	/* P-P IP address        */
	struct sockaddr broadaddr;	/* IP broadcast address  */
	struct sockaddr netmask;	/* IP network mask       */
	int has_ip;
	char hwaddr[32];	/* HW address            */
	int statistics_valid;
	struct user_net_device_stats stats;	/* statistics            */
	int keepalive;		/* keepalive value for SLIP */
	int outfill;		/* outfill value for SLIP */
};


int interface_opt_a = 0;	/* show all interfaces          */

#ifdef KEEP_UNUSED
static int opt_i = 0;	/* show the statistics          */
static int opt_v = 0;	/* debugging output flag        */

static int addr_family = 0;	/* currently selected AF        */
#endif							/* KEEP_UNUSED */

static struct interface *int_list, *int_last;
static int skfd = -1;	/* generic raw socket desc.     */


static int sockets_open(int family)
{
	struct aftype * const *aft;
	int sfd = -1;
	static int force = -1;

	if (force < 0) {
		force = 0;
		if (get_kernel_revision() < KRELEASE(2, 1, 0))
			force = 1;
		if (access("/proc/net", R_OK))
			force = 1;
	}
	for (aft = aftypes; *aft; aft++) {
		struct aftype *af = *aft;
		int type = SOCK_DGRAM;

		if (af->af == AF_UNSPEC)
			continue;
		if (family && family != af->af)
			continue;
		if (af->fd != -1) {
			sfd = af->fd;
			continue;
		}
		/* Check some /proc file first to not stress kmod */
		if (!family && !force && af->flag_file) {
			if (access(af->flag_file, R_OK))
				continue;
		}
		af->fd = socket(af->af, type, 0);
		if (af->fd >= 0)
			sfd = af->fd;
	}
	if (sfd < 0) {
		bb_error_msg(_("No usable address families found."));
	}
	return sfd;
}

#ifdef CONFIG_FEATURE_CLEAN_UP
static void sockets_close(void)
{
	struct aftype * const *aft;
	for (aft = aftypes; *aft != NULL; aft++) {
		struct aftype *af = *aft;
		if( af->fd != -1 ) {
			close(af->fd);
			af->fd = -1;
		}
	}
}
#endif

/* like strcmp(), but knows about numbers */
static int nstrcmp(const char *a, const char *b)
{
	const char *a_ptr = a;
	const char *b_ptr = b;

	while (*a == *b) {
		if (*a == '\0') {
			return 0;
		}
		if (!isdigit(*a) && isdigit(*(a+1))) {
			a_ptr = a+1;
			b_ptr = b+1;
		}
		a++;
		b++;
	}

	if (isdigit(*a) && isdigit(*b)) {
		return atoi(a_ptr) > atoi(b_ptr) ? 1 : -1;
	}
	return *a - *b;
}

static struct interface *add_interface(char *name)
{
	struct interface *ife, **nextp, *new;

	for (ife = int_last; ife; ife = ife->prev) {
		int n = nstrcmp(ife->name, name);

		if (n == 0)
			return ife;
		if (n < 0)
			break;
	}
	new(new);
	safe_strncpy(new->name, name, IFNAMSIZ);
	nextp = ife ? &ife->next : &int_list;
	new->prev = ife;
	new->next = *nextp;
	if (new->next)
		new->next->prev = new;
	else
		int_last = new;
	*nextp = new;
	return new;
}


static int if_readconf(void)
{
	int numreqs = 30;
	struct ifconf ifc;
	struct ifreq *ifr;
	int n, err = -1;
	int skfd2;

	/* SIOCGIFCONF currently seems to only work properly on AF_INET sockets
	   (as of 2.1.128) */
	skfd2 = get_socket_for_af(AF_INET);
	if (skfd2 < 0) {
		bb_perror_msg(("warning: no inet socket available"));
		/* Try to soldier on with whatever socket we can get hold of.  */
		skfd2 = sockets_open(0);
		if (skfd2 < 0)
			return -1;
	}

	ifc.ifc_buf = NULL;
	for (;;) {
		ifc.ifc_len = sizeof(struct ifreq) * numreqs;
		ifc.ifc_buf = xrealloc(ifc.ifc_buf, ifc.ifc_len);

		if (ioctl(skfd2, SIOCGIFCONF, &ifc) < 0) {
			perror("SIOCGIFCONF");
			goto out;
		}
		if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) {
			/* assume it overflowed and try again */
			numreqs += 10;
			continue;
		}
		break;
	}

	ifr = ifc.ifc_req;
	for (n = 0; n < ifc.ifc_len; n += sizeof(struct ifreq)) {
		add_interface(ifr->ifr_name);
		ifr++;
	}
	err = 0;

  out:
	free(ifc.ifc_buf);
	return err;
}

static char *get_name(char *name, char *p)
{
	/* Extract <name>[:<alias>] from nul-terminated p where p matches
	   <name>[:<alias>]: after leading whitespace.
	   If match is not made, set name empty and return unchanged p */
	int namestart=0, nameend=0, aliasend;
	while (isspace(p[namestart]))
		namestart++;
	nameend=namestart;
	while (p[nameend] && p[nameend]!=':' && !isspace(p[nameend]))
		nameend++;
	if (p[nameend]==':') {
		aliasend=nameend+1;
		while (p[aliasend] && isdigit(p[aliasend]))
			aliasend++;
		if (p[aliasend]==':') {
			nameend=aliasend;
		}
		if ((nameend-namestart)<IFNAMSIZ) {
			memcpy(name,&p[namestart],nameend-namestart);
			name[nameend-namestart]='\0';
			p=&p[nameend];
		} else {
			/* Interface name too large */
			name[0]='\0';
		}
	} else {
		/* first ':' not found - return empty */
		name[0]='\0';
	}
	return p + 1;
}

/* If scanf supports size qualifiers for %n conversions, then we can
 * use a modified fmt that simply stores the position in the fields
 * having no associated fields in the proc string.  Of course, we need
 * to zero them again when we're done.  But that is smaller than the
 * old approach of multiple scanf occurrences with large numbers of
 * args. */

/* static const char * const ss_fmt[] = { */
/*	"%lln%llu%lu%lu%lu%lu%ln%ln%lln%llu%lu%lu%lu%lu%lu", */
/*	"%llu%llu%lu%lu%lu%lu%ln%ln%llu%llu%lu%lu%lu%lu%lu", */
/*	"%llu%llu%lu%lu%lu%lu%lu%lu%llu%llu%lu%lu%lu%lu%lu%lu" */
/* }; */

	/* Lie about the size of the int pointed to for %n. */
#if INT_MAX == LONG_MAX
static const char * const ss_fmt[] = {
	"%n%llu%u%u%u%u%n%n%n%llu%u%u%u%u%u",
	"%llu%llu%u%u%u%u%n%n%llu%llu%u%u%u%u%u",
	"%llu%llu%u%u%u%u%u%u%llu%llu%u%u%u%u%u%u"
};
#else
static const char * const ss_fmt[] = {
	"%n%llu%lu%lu%lu%lu%n%n%n%llu%lu%lu%lu%lu%lu",
	"%llu%llu%lu%lu%lu%lu%n%n%llu%llu%lu%lu%lu%lu%lu",
	"%llu%llu%lu%lu%lu%lu%lu%lu%llu%llu%lu%lu%lu%lu%lu%lu"
};

#endif

static void get_dev_fields(char *bp, struct interface *ife, int procnetdev_vsn)
{
	memset(&ife->stats, 0, sizeof(struct user_net_device_stats));

	sscanf(bp, ss_fmt[procnetdev_vsn],
		   &ife->stats.rx_bytes, /* missing for 0 */
		   &ife->stats.rx_packets,
		   &ife->stats.rx_errors,
		   &ife->stats.rx_dropped,
		   &ife->stats.rx_fifo_errors,
		   &ife->stats.rx_frame_errors,
		   &ife->stats.rx_compressed, /* missing for <= 1 */
		   &ife->stats.rx_multicast, /* missing for <= 1 */
		   &ife->stats.tx_bytes, /* missing for 0 */
		   &ife->stats.tx_packets,
		   &ife->stats.tx_errors,
		   &ife->stats.tx_dropped,
		   &ife->stats.tx_fifo_errors,
		   &ife->stats.collisions,
		   &ife->stats.tx_carrier_errors,
		   &ife->stats.tx_compressed /* missing for <= 1 */
		   );

	if (procnetdev_vsn <= 1) {
		if (procnetdev_vsn == 0) {
			ife->stats.rx_bytes = 0;
			ife->stats.tx_bytes = 0;
		}
		ife->stats.rx_multicast = 0;
		ife->stats.rx_compressed = 0;
		ife->stats.tx_compressed = 0;
	}
}

static inline int procnetdev_version(char *buf)
{
	if (strstr(buf, "compressed"))
		return 2;
	if (strstr(buf, "bytes"))
		return 1;
	return 0;
}

static int if_readlist_proc(char *target)
{
	static int proc_read;
	FILE *fh;
	char buf[512];
	struct interface *ife;
	int err, procnetdev_vsn;

	if (proc_read)
		return 0;
	if (!target)
		proc_read = 1;

	fh = fopen(_PATH_PROCNET_DEV, "r");
	if (!fh) {
		bb_perror_msg(_("Warning: cannot open %s. Limited output."), _PATH_PROCNET_DEV);
		return if_readconf();
	}
	fgets(buf, sizeof buf, fh);	/* eat line */
	fgets(buf, sizeof buf, fh);

	procnetdev_vsn = procnetdev_version(buf);

	err = 0;
	while (fgets(buf, sizeof buf, fh)) {
		char *s, name[128];

		s = get_name(name, buf);
		ife = add_interface(name);
		get_dev_fields(s, ife, procnetdev_vsn);
		ife->statistics_valid = 1;
		if (target && !strcmp(target, name))
			break;
	}
	if (ferror(fh)) {
		perror(_PATH_PROCNET_DEV);
		err = -1;
		proc_read = 0;
	}
	fclose(fh);
	return err;
}

static int if_readlist(void)
{
	int err = if_readlist_proc(NULL);

	if (!err)
		err = if_readconf();
	return err;
}

static int for_all_interfaces(int (*doit) (struct interface *, void *),
							  void *cookie)
{
	struct interface *ife;

	if (!int_list && (if_readlist() < 0))
		return -1;
	for (ife = int_list; ife; ife = ife->next) {
		int err = doit(ife, cookie);

		if (err)
			return err;
	}
	return 0;
}

/* Fetch the interface configuration from the kernel. */
static int if_fetch(struct interface *ife)
{
	struct ifreq ifr;
	int fd;
	char *ifname = ife->name;

	strcpy(ifr.ifr_name, ifname);
	if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0)
		return (-1);
	ife->flags = ifr.ifr_flags;

	strcpy(ifr.ifr_name, ifname);
	if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
		memset(ife->hwaddr, 0, 32);
	else
		memcpy(ife->hwaddr, ifr.ifr_hwaddr.sa_data, 8);

	ife->type = ifr.ifr_hwaddr.sa_family;

	strcpy(ifr.ifr_name, ifname);
	if (ioctl(skfd, SIOCGIFMETRIC, &ifr) < 0)
		ife->metric = 0;
	else
		ife->metric = ifr.ifr_metric;

	strcpy(ifr.ifr_name, ifname);
	if (ioctl(skfd, SIOCGIFMTU, &ifr) < 0)
		ife->mtu = 0;
	else
		ife->mtu = ifr.ifr_mtu;

#ifdef HAVE_HWSLIP
	if (ife->type == ARPHRD_SLIP || ife->type == ARPHRD_CSLIP ||
		ife->type == ARPHRD_SLIP6 || ife->type == ARPHRD_CSLIP6 ||
		ife->type == ARPHRD_ADAPT) {
#ifdef SIOCGOUTFILL
		strcpy(ifr.ifr_name, ifname);
		if (ioctl(skfd, SIOCGOUTFILL, &ifr) < 0)
			ife->outfill = 0;
		else
			ife->outfill = (unsigned int) ifr.ifr_data;
#endif
#ifdef SIOCGKEEPALIVE
		strcpy(ifr.ifr_name, ifname);
		if (ioctl(skfd, SIOCGKEEPALIVE, &ifr) < 0)
			ife->keepalive = 0;
		else
			ife->keepalive = (unsigned int) ifr.ifr_data;
#endif
	}
#endif

#ifdef SIOCGIFMAP
	strcpy(ifr.ifr_name, ifname);
	if (ioctl(skfd, SIOCGIFMAP, &ifr) == 0)
		ife->map = ifr.ifr_map;
	else
#endif
		memset(&ife->map, 0, sizeof(struct ifmap));

#ifdef HAVE_TXQUEUELEN
	strcpy(ifr.ifr_name, ifname);
	if (ioctl(skfd, SIOCGIFTXQLEN, &ifr) < 0)
		ife->tx_queue_len = -1;	/* unknown value */
	else
		ife->tx_queue_len = ifr.ifr_qlen;
#else
	ife->tx_queue_len = -1;	/* unknown value */
#endif

#if HAVE_AFINET
	/* IPv4 address? */
	fd = get_socket_for_af(AF_INET);
	if (fd >= 0) {
		strcpy(ifr.ifr_name, ifname);
		ifr.ifr_addr.sa_family = AF_INET;
		if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
			ife->has_ip = 1;
			ife->addr = ifr.ifr_addr;
			strcpy(ifr.ifr_name, ifname);
			if (ioctl(fd, SIOCGIFDSTADDR, &ifr) < 0)
				memset(&ife->dstaddr, 0, sizeof(struct sockaddr));
			else
				ife->dstaddr = ifr.ifr_dstaddr;

			strcpy(ifr.ifr_name, ifname);
			if (ioctl(fd, SIOCGIFBRDADDR, &ifr) < 0)
				memset(&ife->broadaddr, 0, sizeof(struct sockaddr));
			else
				ife->broadaddr = ifr.ifr_broadaddr;

			strcpy(ifr.ifr_name, ifname);
			if (ioctl(fd, SIOCGIFNETMASK, &ifr) < 0)
				memset(&ife->netmask, 0, sizeof(struct sockaddr));
			else
				ife->netmask = ifr.ifr_netmask;
		} else
			memset(&ife->addr, 0, sizeof(struct sockaddr));
	}
#endif

	return 0;
}


static int do_if_fetch(struct interface *ife)
{
	if (if_fetch(ife) < 0) {
		char *errmsg;

		if (errno == ENODEV) {
			/* Give better error message for this case. */
			errmsg = _("Device not found");
		} else {
			errmsg = strerror(errno);
		}
		bb_error_msg(_("%s: error fetching interface information: %s"),
				ife->name, errmsg);
		return -1;
	}
	return 0;
}

/* This structure defines hardware protocols and their handlers. */
struct hwtype {
	const char * const name;
	const char *title;
	int type;
	int alen;
	char *(*print) (unsigned char *);
	int (*input) (char *, struct sockaddr *);
	int (*activate) (int fd);
	int suppress_null_addr;
};

static const struct hwtype unspec_hwtype = {
	"unspec", "UNSPEC", -1, 0,
	UNSPEC_print, NULL, NULL
};

static const struct hwtype loop_hwtype = {
	"loop", "Local Loopback", ARPHRD_LOOPBACK, 0,
	NULL, NULL, NULL
};

#if HAVE_HWETHER
#include <net/if_arp.h>

#if (__GLIBC__ >=2 && __GLIBC_MINOR >= 1) || defined(_NEWLIB_VERSION)
#include <net/ethernet.h>
#else
#include <linux/if_ether.h>
#endif

/* Display an Ethernet address in readable format. */
static char *pr_ether(unsigned char *ptr)
{
	static char buff[64];

	snprintf(buff, sizeof(buff), "%02X:%02X:%02X:%02X:%02X:%02X",
			 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
			 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
		);
	return (buff);
}

#ifdef KEEP_UNUSED
/* Input an Ethernet address and convert to binary. */
static int in_ether(char *bufp, struct sockaddr *sap)
{
	unsigned char *ptr;
	char c, *orig;
	int i;
	unsigned val;

	sap->sa_family = ether_hwtype.type;
	ptr = sap->sa_data;

	i = 0;
	orig = bufp;
	while ((*bufp != '\0') && (i < ETH_ALEN)) {
		val = 0;
		c = *bufp++;
		if (isdigit(c))
			val = c - '0';
		else if (c >= 'a' && c <= 'f')
			val = c - 'a' + 10;
		else if (c >= 'A' && c <= 'F')
			val = c - 'A' + 10;
		else {
#ifdef DEBUG
			bb_error_msg(_("in_ether(%s): invalid ether address!\n"), orig);
#endif
			errno = EINVAL;
			return (-1);
		}
		val <<= 4;
		c = *bufp;
		if (isdigit(c))
			val |= c - '0';
		else if (c >= 'a' && c <= 'f')
			val |= c - 'a' + 10;
		else if (c >= 'A' && c <= 'F')
			val |= c - 'A' + 10;
		else if (c == ':' || c == 0)
			val >>= 4;
		else {
#ifdef DEBUG
			bb_error_msg(_("in_ether(%s): invalid ether address!"), orig);
#endif
			errno = EINVAL;
			return (-1);
		}
		if (c != 0)
			bufp++;
		*ptr++ = (unsigned char) (val & 0377);
		i++;

		/* We might get a semicolon here - not required. */
		if (*bufp == ':') {
#ifdef DEBUG
			if (i == ETH_ALEN) {
				bb_error_msg(_("in_ether(%s): trailing : ignored!"), orig);
			}
#endif
			bufp++;
		}
	}

#ifdef DEBUG
	/* That's it.  Any trailing junk? */
	if ((i == ETH_ALEN) && (*bufp != '\0')) {
		bb_error_msg(_("in_ether(%s): trailing junk!"), orig);
		errno = EINVAL;
		return (-1);
	}
	bb_error_msg("in_ether(%s): %s", orig, pr_ether(sap->sa_data));
#endif

	return (0);
}
#endif							/* KEEP_UNUSED */


static const struct hwtype ether_hwtype = {
	"ether", "Ethernet", ARPHRD_ETHER, ETH_ALEN,
	pr_ether, NULL /* UNUSED in_ether */ , NULL
};


#endif							/* HAVE_HWETHER */


#if HAVE_HWPPP

#include <net/if_arp.h>

#ifdef KEEP_UNUSED
/* Start the PPP encapsulation on the file descriptor. */
static int do_ppp(int fd)
{
	bb_error_msg(_("You cannot start PPP with this program."));
	return -1;
}
#endif							/* KEEP_UNUSED */

static const struct hwtype ppp_hwtype = {
	"ppp", "Point-Point Protocol", ARPHRD_PPP, 0,
	NULL, NULL, NULL /* UNUSED do_ppp */ , 0
};


#endif							/* HAVE_PPP */

static const struct hwtype * const hwtypes[] = {

	&loop_hwtype,

#if HAVE_HWSLIP
	&slip_hwtype,
	&cslip_hwtype,
	&slip6_hwtype,
	&cslip6_hwtype,
	&adaptive_hwtype,
#endif
#if HAVE_HWSTRIP
	&strip_hwtype,
#endif
#if HAVE_HWETHER
	&ether_hwtype,
#endif
#if HAVE_HWTUNNEL
	&tunnel_hwtype,
#endif
#if HAVE_HWPPP
	&ppp_hwtype,
#endif
	&unspec_hwtype,
	NULL
};

#ifdef KEEP_UNUSED
static short sVhwinit = 0;

static void hwinit()
{
	loop_hwtype.title = _("Local Loopback");
	unspec_hwtype.title = _("UNSPEC");
#if HAVE_HWSLIP
	slip_hwtype.title = _("Serial Line IP");
	cslip_hwtype.title = _("VJ Serial Line IP");
	slip6_hwtype.title = _("6-bit Serial Line IP");
	cslip6_hwtype.title = _("VJ 6-bit Serial Line IP");
	adaptive_hwtype.title = _("Adaptive Serial Line IP");
#endif
#if HAVE_HWETHER
	ether_hwtype.title = _("Ethernet");
#endif
#if HAVE_HWTUNNEL
	tunnel_hwtype.title = _("IPIP Tunnel");
#endif
#if HAVE_HWPPP
	ppp_hwtype.title = _("Point-to-Point Protocol");
#endif
	sVhwinit = 1;
}
#endif							/* KEEP_UNUSED */

#ifdef IFF_PORTSEL
#if 0
static const char * const if_port_text[][4] = {
	/* Keep in step with <linux/netdevice.h> */
	{"unknown", NULL, NULL, NULL},
	{"10base2", "bnc", "coax", NULL},
	{"10baseT", "utp", "tpe", NULL},
	{"AUI", "thick", "db15", NULL},
	{"100baseT", NULL, NULL, NULL},
	{"100baseTX", NULL, NULL, NULL},
	{"100baseFX", NULL, NULL, NULL},
	{NULL, NULL, NULL, NULL},
};
#else
static const char * const if_port_text[] = {
	/* Keep in step with <linux/netdevice.h> */
	"unknown",
	"10base2",
	"10baseT",
	"AUI",
	"100baseT",
	"100baseTX",
	"100baseFX",
	NULL
};
#endif
#endif

/* Check our hardware type table for this type. */
static const struct hwtype *get_hwntype(int type)
{
	const struct hwtype * const *hwp;

#ifdef KEEP_UNUSED
	if (!sVhwinit)
		hwinit();
#endif							/* KEEP_UNUSED */

	hwp = hwtypes;
	while (*hwp != NULL) {
		if ((*hwp)->type == type)
			return (*hwp);
		hwp++;
	}
	return (NULL);
}

/* return 1 if address is all zeros */
static int hw_null_address(const struct hwtype *hw, void *ap)
{
	unsigned int i;
	unsigned char *address = (unsigned char *) ap;

	for (i = 0; i < hw->alen; i++)
		if (address[i])
			return 0;
	return 1;
}

static const char TRext[] = "\0\0\0Ki\0Mi\0Gi\0Ti";

static void print_bytes_scaled(unsigned long long ull, const char *end)
{
	unsigned long long int_part;
	const char *ext;
	unsigned int frac_part;
	int i;

	frac_part = 0;
	ext = TRext;
	int_part = ull;
	i = 4;
	do {
#if 0
		/* This does correct rounding and is a little larger.  But it
		 * uses KiB as the smallest displayed unit. */
		if ((int_part < (1024*1024 - 51)) || !--i) {
			i = 0;
			int_part += 51;		/* 1024*.05 = 51.2 */
			frac_part = ((((unsigned int) int_part) & (1024-1)) * 10) / 1024;
		}
		int_part /= 1024;
		ext += 3;	/* KiB, MiB, GiB, TiB */
#else
		if (int_part >= 1024) {
			frac_part = ((((unsigned int) int_part) & (1024-1)) * 10) / 1024;
			int_part /= 1024;
			ext += 3;	/* KiB, MiB, GiB, TiB */
		}
		--i;
#endif
	} while (i);

	printf("X bytes:%llu (%llu.%u %sB)%s", ull, int_part, frac_part, ext, end);
}

static const char * const ife_print_flags_strs[] = {
	"UP ",
	"BROADCAST ",
	"DEBUG ",
	"LOOPBACK ",
	"POINTOPOINT ",
	"NOTRAILERS ",
	"RUNNING ",
	"NOARP ",
	"PROMISC ",
	"ALLMULTI ",
	"SLAVE ",
	"MASTER ",
	"MULTICAST ",
#ifdef HAVE_DYNAMIC
	"DYNAMIC "
#endif
};

static const unsigned short ife_print_flags_mask[] = {
	IFF_UP,
	IFF_BROADCAST,
	IFF_DEBUG,
	IFF_LOOPBACK,
	IFF_POINTOPOINT,
	IFF_NOTRAILERS,
	IFF_RUNNING,
	IFF_NOARP,
	IFF_PROMISC,
	IFF_ALLMULTI,
	IFF_SLAVE,
	IFF_MASTER,
	IFF_MULTICAST,
#ifdef HAVE_DYNAMIC
	IFF_DYNAMIC
#endif
	0
};

static void ife_print(struct interface *ptr)
{
	struct aftype *ap;
	const struct hwtype *hw;
	int hf;
	int can_compress = 0;

#if HAVE_AFINET6
	FILE *f;
	char addr6[40], devname[20];
	struct sockaddr_in6 sap;
	int plen, scope, dad_status, if_idx;
	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);

	printf(_("%-9.9s Link encap:%s  "), ptr->name, _(hw->title));
	/* 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(_("HWaddr %s  "), hw->print((unsigned char *)ptr->hwaddr));
#ifdef IFF_PORTSEL
	if (ptr->flags & IFF_PORTSEL) {
		printf(_("Media:%s"), if_port_text[ptr->map.port] /* [0] */);
		if (ptr->flags & IFF_AUTOMEDIA)
			printf(_("(auto)"));
	}
#endif
	printf("\n");

#if HAVE_AFINET
	if (ptr->has_ip) {
		printf(_("          %s addr:%s "), ap->name,
			   ap->sprint(&ptr->addr, 1));
		if (ptr->flags & IFF_POINTOPOINT) {
			printf(_(" P-t-P:%s "), ap->sprint(&ptr->dstaddr, 1));
		}
		if (ptr->flags & IFF_BROADCAST) {
			printf(_(" Bcast:%s "), ap->sprint(&ptr->broadaddr, 1));
		}
		printf(_(" Mask:%s\n"), ap->sprint(&ptr->netmask, 1));
	}
#endif

#if HAVE_AFINET6

#define IPV6_ADDR_ANY           0x0000U

#define IPV6_ADDR_UNICAST       0x0001U
#define IPV6_ADDR_MULTICAST     0x0002U
#define IPV6_ADDR_ANYCAST       0x0004U

#define IPV6_ADDR_LOOPBACK      0x0010U
#define IPV6_ADDR_LINKLOCAL     0x0020U
#define IPV6_ADDR_SITELOCAL     0x0040U

#define IPV6_ADDR_COMPATv4      0x0080U

#define IPV6_ADDR_SCOPE_MASK    0x00f0U

#define IPV6_ADDR_MAPPED        0x1000U
#define IPV6_ADDR_RESERVED      0x2000U	/* reserved address space */

	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]);
				inet_pton(AF_INET6, addr6,
						  (struct sockaddr *) &sap.sin6_addr);
				sap.sin6_family = AF_INET6;
				printf(_("          inet6 addr: %s/%d"),
					   inet6_aftype.sprint((struct sockaddr *) &sap, 1),
					   plen);
				printf(_(" Scope:"));
				switch (scope & IPV6_ADDR_SCOPE_MASK) {
				case 0:
					printf(_("Global"));
					break;
				case IPV6_ADDR_LINKLOCAL:
					printf(_("Link"));
					break;
				case IPV6_ADDR_SITELOCAL:
					printf(_("Site"));
					break;
				case IPV6_ADDR_COMPATv4:
					printf(_("Compat"));
					break;
				case IPV6_ADDR_LOOPBACK:
					printf(_("Host"));
					break;
				default:
					printf(_("Unknown"));
				}
				printf("\n");
			}
		}
		fclose(f);
	}
#endif

	printf("          ");
	/* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */

	if (ptr->flags == 0) {
		printf(_("[NO FLAGS] "));
	} else {
		int i = 0;
		do {
			if (ptr->flags & ife_print_flags_mask[i]) {
				printf(_(ife_print_flags_strs[i]));
			}
		} while (ife_print_flags_mask[++i]);
	}

	/* DONT FORGET TO ADD THE FLAGS IN ife_print_short */
	printf(_(" MTU:%d  Metric:%d"), 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 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.
		 */
		printf("          ");

		printf("RX packets:%llu errors:%lu dropped:%lu overruns:%lu frame:%lu\n",
			   ptr->stats.rx_packets, ptr->stats.rx_errors,
			   ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
			   ptr->stats.rx_frame_errors);
		if (can_compress)
			printf("             compressed:%lu\n",
				   ptr->stats.rx_compressed);
		printf("          ");
		printf("TX packets:%llu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n",
			   ptr->stats.tx_packets, ptr->stats.tx_errors,
			   ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
			   ptr->stats.tx_carrier_errors);
		printf("          collisions:%lu ", ptr->stats.collisions);
		if (can_compress)
			printf("compressed:%lu ", ptr->stats.tx_compressed);
		if (ptr->tx_queue_len != -1)
			printf("txqueuelen:%d ", ptr->tx_queue_len);
		printf("\n          R");
		print_bytes_scaled(ptr->stats.rx_bytes, "  T");
		print_bytes_scaled(ptr->stats.tx_bytes, "\n");

	}

	if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
		 ptr->map.base_addr)) {
		printf("          ");
		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 address:0x%lx "),
				   (unsigned long) ptr->map.base_addr);
		if (ptr->map.mem_start) {
			printf(_("Memory:%lx-%lx "), ptr->map.mem_start,
				   ptr->map.mem_end);
		}
		if (ptr->map.dma)
			printf(_("DMA chan:%x "), ptr->map.dma);
		printf("\n");
	}
	printf("\n");
}


static int do_if_print(struct interface *ife, void *cookie)
{
	int *opt_a = (int *) cookie;
	int res;

	res = do_if_fetch(ife);
	if (res >= 0) {
		if ((ife->flags & IFF_UP) || *opt_a)
			ife_print(ife);
	}
	return res;
}

static struct interface *lookup_interface(char *name)
{
	struct interface *ife = NULL;

	if (if_readlist_proc(name) < 0)
		return NULL;
	ife = add_interface(name);
	return ife;
}

/* for ipv4 add/del modes */
static int if_print(char *ifname)
{
	int res;

	if (!ifname) {
		res = for_all_interfaces(do_if_print, &interface_opt_a);
	} else {
		struct interface *ife;

		ife = lookup_interface(ifname);
		res = do_if_fetch(ife);
		if (res >= 0)
			ife_print(ife);
	}
	return res;
}

int display_interfaces(char *ifname)
{
	int status;

	/* Create a channel to the NET kernel. */
	if ((skfd = sockets_open(0)) < 0) {
		bb_perror_msg_and_die("socket");
	}

	/* Do we have to show the current setup? */
	status = if_print(ifname);
#ifdef CONFIG_FEATURE_CLEAN_UP
	sockets_close();
#endif
	exit(status < 0);
}
