/*
- * stolen from net-tools-1.59 and stripped down for busybox by
- * Erik Andersen <andersee@debian.org>
+ * 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
*
* that either displays or sets the characteristics of
* one or more of the system's networking interfaces.
*
- * Version: $Id: interface.c,v 1.11 2002/11/26 09:02:04 bug1 Exp $
+ * 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
*
* {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
+ * 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
#undef HAVE_AFIPX
#undef HAVE_AFECONET
#undef HAVE_AFASH
-#ifdef CONFIG_FEATURE_IPV6
-# define HAVE_AFINET6 1
-#else
-# undef HAVE_AFINET6
-#endif
-
-/*
- *
+/*
+ *
* Device Hardware types.
- *
+ *
*/
#define HAVE_HWETHER 1
#define HAVE_HWPPP 1
#include <fcntl.h>
#include <ctype.h>
#include <sys/ioctl.h>
+#include <sys/types.h>
#include <net/if.h>
#include <net/if_arp.h>
#include "libbb.h"
+#ifdef CONFIG_FEATURE_IPV6
+# define HAVE_AFINET6 1
+#else
+# undef HAVE_AFINET6
+#endif
+
#define _(x) x
#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))
-static int procnetdev_vsn = 1;
-
-/* Ugh. But libc5 doesn't provide POSIX types. */
-#include <asm/types.h>
-
-
#ifdef HAVE_HWSLIP
-#include <linux/if_slip.h>
+#include <net/if_slip.h>
#endif
#if HAVE_AFINET6
struct in6_ifreq {
struct in6_addr ifr6_addr;
- __u32 ifr6_prefixlen;
+ uint32_t ifr6_prefixlen;
unsigned int ifr6_ifindex;
};
if (strcmp(tmp1, paft->alias))
continue;
if (strlen(paft->name) + strlen(afname) + 1 >= sizeof(afname)) {
- fprintf(stderr, _("Too much address family arguments.\n"));
+ bb_error_msg(_("Too many address family arguments."));
return (0);
}
if (paft->flag)
break;
}
if (!paft->alias) {
- fprintf(stderr, _("Unknown address family `%s'.\n"), tmp1);
+ bb_error_msg(_("Unknown address family `%s'."), tmp1);
return (1);
}
tmp1 = tmp2;
afp++;
}
if (strchr(name, ','))
- fprintf(stderr,
- _("Please don't supply more than one address family.\n"));
+ bb_error_msg(_("Please don't supply more than one address family."));
return (NULL);
}
#endif /* KEEP_UNUSED */
if (af->fd >= 0)
sfd = af->fd;
}
- if (sfd < 0)
- fprintf(stderr, _("No usable address families found.\n"));
+ 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 **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 *astr, const char *b)
+static int nstrcmp(const char *a, const char *b)
{
- const char *a = astr;
+ const char *a_ptr = a;
+ const char *b_ptr = b;
while (*a == *b) {
- if (*a == '\0')
+ if (*a == '\0') {
return 0;
+ }
+ if (!isdigit(*a) && isdigit(*(a+1))) {
+ a_ptr = a+1;
+ b_ptr = b+1;
+ }
a++;
b++;
}
- if (isdigit(*a)) {
- if (!isdigit(*b))
- return -1;
- while (a > astr) {
- a--;
- if (!isdigit(*a)) {
- a++;
- break;
- }
- if (!isdigit(*b))
- return -1;
- b--;
- }
- return atoi(a) > atoi(b) ? 1 : -1;
+
+ if (isdigit(*a) && isdigit(*b)) {
+ return atoi(a_ptr) > atoi(b_ptr) ? 1 : -1;
}
return *a - *b;
}
(as of 2.1.128) */
skfd2 = get_socket_for_af(AF_INET);
if (skfd2 < 0) {
- fprintf(stderr, _("warning: no inet socket available: %s\n"),
- strerror(errno));
+ 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)
static char *get_name(char *name, char *p)
{
- while (isspace(*p))
- p++;
- while (*p) {
- if (isspace(*p))
- break;
- if (*p == ':') { /* could be an alias */
- char *dot = p, *dotname = name;
-
- *name++ = *p++;
- while (isdigit(*p))
- *name++ = *p++;
- if (*p != ':') { /* it wasn't, backup */
- p = dot;
- name = dotname;
- }
- if (*p == '\0')
- return NULL;
- p++;
- break;
+ /* 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;
}
- *name++ = *p++;
+ 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';
}
- *name++ = '\0';
- return p;
+ return p + 1;
}
-static int get_dev_fields(char *bp, struct interface *ife)
+/* 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 *ss_fmt[] = { */
+/* "%Ln%Lu%lu%lu%lu%lu%ln%ln%Ln%Lu%lu%lu%lu%lu%lu", */
+/* "%Lu%Lu%lu%lu%lu%lu%ln%ln%Lu%Lu%lu%lu%lu%lu%lu", */
+/* "%Lu%Lu%lu%lu%lu%lu%lu%lu%Lu%Lu%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 *ss_fmt[] = {
+ "%n%Lu%u%u%u%u%n%n%n%Lu%u%u%u%u%u",
+ "%Lu%Lu%u%u%u%u%n%n%Lu%Lu%u%u%u%u%u",
+ "%Lu%Lu%u%u%u%u%u%u%Lu%Lu%u%u%u%u%u%u"
+};
+#else
+static const char *ss_fmt[] = {
+ "%n%Lu%lu%lu%lu%lu%n%n%n%Lu%lu%lu%lu%lu%lu",
+ "%Lu%Lu%lu%lu%lu%lu%n%n%Lu%Lu%lu%lu%lu%lu%lu",
+ "%Lu%Lu%lu%lu%lu%lu%lu%lu%Lu%Lu%lu%lu%lu%lu%lu%lu"
+};
+
+#endif
+
+static void get_dev_fields(char *bp, struct interface *ife, int procnetdev_vsn)
{
- switch (procnetdev_vsn) {
- case 3:
- sscanf(bp,
- "%Lu %Lu %lu %lu %lu %lu %lu %lu %Lu %Lu %lu %lu %lu %lu %lu %lu",
- &ife->stats.rx_bytes,
- &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,
- &ife->stats.rx_multicast,
- &ife->stats.tx_bytes,
- &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);
- break;
- case 2:
- sscanf(bp, "%Lu %Lu %lu %lu %lu %lu %Lu %Lu %lu %lu %lu %lu %lu",
- &ife->stats.rx_bytes,
- &ife->stats.rx_packets,
- &ife->stats.rx_errors,
- &ife->stats.rx_dropped,
- &ife->stats.rx_fifo_errors,
- &ife->stats.rx_frame_errors,
- &ife->stats.tx_bytes,
- &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.rx_multicast = 0;
- break;
- case 1:
- sscanf(bp, "%Lu %lu %lu %lu %lu %Lu %lu %lu %lu %lu %lu",
- &ife->stats.rx_packets,
- &ife->stats.rx_errors,
- &ife->stats.rx_dropped,
- &ife->stats.rx_fifo_errors,
- &ife->stats.rx_frame_errors,
- &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.rx_bytes = 0;
- ife->stats.tx_bytes = 0;
+ 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;
- break;
+ ife->stats.rx_compressed = 0;
+ ife->stats.tx_compressed = 0;
}
- return 0;
}
static inline int procnetdev_version(char *buf)
{
if (strstr(buf, "compressed"))
- return 3;
- if (strstr(buf, "bytes"))
return 2;
- return 1;
+ if (strstr(buf, "bytes"))
+ return 1;
+ return 0;
}
static int if_readlist_proc(char *target)
FILE *fh;
char buf[512];
struct interface *ife;
- int err;
+ int err, procnetdev_vsn;
if (proc_read)
return 0;
fh = fopen(_PATH_PROCNET_DEV, "r");
if (!fh) {
- fprintf(stderr, _("Warning: cannot open %s (%s). Limited output.\n"),
- _PATH_PROCNET_DEV, strerror(errno));
+ 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);
-#if 0 /* pretty, but can't cope with missing fields */
- fmt = proc_gen_fmt(_PATH_PROCNET_DEV, 1, fh, "face", "", /* parsed separately */
- "bytes", "%lu",
- "packets", "%lu",
- "errs", "%lu",
- "drop", "%lu",
- "fifo", "%lu",
- "frame", "%lu",
- "compressed", "%lu",
- "multicast", "%lu",
- "bytes", "%lu",
- "packets", "%lu",
- "errs", "%lu",
- "drop", "%lu",
- "fifo", "%lu",
- "colls", "%lu",
- "carrier", "%lu", "compressed", "%lu", NULL);
- if (!fmt)
- return -1;
-#else
procnetdev_vsn = procnetdev_version(buf);
-#endif
err = 0;
while (fgets(buf, sizeof buf, fh)) {
- char *s, name[IFNAMSIZ];
+ char *s, name[128];
s = get_name(name, buf);
ife = add_interface(name);
- get_dev_fields(s, ife);
+ get_dev_fields(s, ife, procnetdev_vsn);
ife->statistics_valid = 1;
if (target && !strcmp(target, name))
break;
err = -1;
proc_read = 0;
}
-#if 0
- free(fmt);
-#endif
fclose(fh);
return err;
}
}
#endif
+#ifdef SIOCGIFMAP
strcpy(ifr.ifr_name, ifname);
- if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0)
- memset(&ife->map, 0, sizeof(struct ifmap));
+ if (ioctl(skfd, SIOCGIFMAP, &ifr) == 0)
+ ife->map = ifr.ifr_map;
else
- memcpy(&ife->map, &ifr.ifr_map, sizeof(struct ifmap));
-
- strcpy(ifr.ifr_name, ifname);
- if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0)
+#endif
memset(&ife->map, 0, sizeof(struct ifmap));
- else
- ife->map = ifr.ifr_map;
#ifdef HAVE_TXQUEUELEN
strcpy(ifr.ifr_name, ifname);
} else {
errmsg = strerror(errno);
}
- fprintf(stderr, _("%s: error fetching interface information: %s\n"),
+ bb_error_msg(_("%s: error fetching interface information: %s\n"),
ife->name, errmsg);
return -1;
}
#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)
val = c - 'A' + 10;
else {
#ifdef DEBUG
- fprintf(stderr, _("in_ether(%s): invalid ether address!\n"),
- orig);
+ bb_error_msg(_("in_ether(%s): invalid ether address!\n"), orig);
#endif
errno = EINVAL;
return (-1);
val >>= 4;
else {
#ifdef DEBUG
- fprintf(stderr, _("in_ether(%s): invalid ether address!\n"),
- orig);
+ bb_error_msg(_("in_ether(%s): invalid ether address!"), orig);
#endif
errno = EINVAL;
return (-1);
/* We might get a semicolon here - not required. */
if (*bufp == ':') {
- if (i == ETH_ALEN) {
#ifdef DEBUG
- fprintf(stderr, _("in_ether(%s): trailing : ignored!\n"),
- orig)
-#endif
- ; /* nothing */
+ 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')) {
-#ifdef DEBUG
- fprintf(stderr, _("in_ether(%s): trailing junk!\n"), orig);
+ bb_error_msg(_("in_ether(%s): trailing junk!"), orig);
errno = EINVAL;
return (-1);
-#endif
}
-#ifdef DEBUG
- fprintf(stderr, "in_ether(%s): %s\n", orig, pr_ether(sap->sa_data));
+ bb_error_msg("in_ether(%s): %s", orig, pr_ether(sap->sa_data));
#endif
return (0);
/* Start the PPP encapsulation on the file descriptor. */
static int do_ppp(int fd)
{
- fprintf(stderr, _("You cannot start PPP with this program.\n"));
+ bb_error_msg(_("You cannot start PPP with this program."));
return -1;
}
#endif /* KEEP_UNUSED */
#endif /* KEEP_UNUSED */
#ifdef IFF_PORTSEL
-static const char *if_port_text[][4] = {
+#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},
{"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. */
return 1;
}
-static const char TRext[] = "\0\0k\0M";
+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;
- unsigned long frac_part;
const char *ext;
+ unsigned int frac_part;
int i;
frac_part = 0;
ext = TRext;
int_part = ull;
- for (i = 0; i < 2; i++) {
+ 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 = ((int_part % 1024) * 10) / 1024;
+ frac_part = ((((unsigned int) int_part) & (1024-1)) * 10) / 1024;
int_part /= 1024;
- ext += 2; /* Kb, Mb */
+ ext += 3; /* KiB, MiB, GiB, TiB */
}
- }
+ --i;
+#endif
+ } while (i);
- printf("X bytes:%Lu (%Lu.%lu %siB)%s", ull, int_part, frac_part, ext, end);
+ printf("X bytes:%Lu (%Lu.%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;
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
+ /* 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(ptr->hwaddr));
#ifdef IFF_PORTSEL
if (ptr->flags & IFF_PORTSEL) {
- printf(_("Media:%s"), if_port_text[ptr->map.port][0]);
+ printf(_("Media:%s"), if_port_text[ptr->map.port] /* [0] */);
if (ptr->flags & IFF_AUTOMEDIA)
printf(_("(auto)"));
}
printf(" ");
/* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */
- if (ptr->flags == 0)
+
+ if (ptr->flags == 0) {
printf(_("[NO FLAGS] "));
- if (ptr->flags & IFF_UP)
- printf(_("UP "));
- if (ptr->flags & IFF_BROADCAST)
- printf(_("BROADCAST "));
- if (ptr->flags & IFF_DEBUG)
- printf(_("DEBUG "));
- if (ptr->flags & IFF_LOOPBACK)
- printf(_("LOOPBACK "));
- if (ptr->flags & IFF_POINTOPOINT)
- printf(_("POINTOPOINT "));
- if (ptr->flags & IFF_NOTRAILERS)
- printf(_("NOTRAILERS "));
- if (ptr->flags & IFF_RUNNING)
- printf(_("RUNNING "));
- if (ptr->flags & IFF_NOARP)
- printf(_("NOARP "));
- if (ptr->flags & IFF_PROMISC)
- printf(_("PROMISC "));
- if (ptr->flags & IFF_ALLMULTI)
- printf(_("ALLMULTI "));
- if (ptr->flags & IFF_SLAVE)
- printf(_("SLAVE "));
- if (ptr->flags & IFF_MASTER)
- printf(_("MASTER "));
- if (ptr->flags & IFF_MULTICAST)
- printf(_("MULTICAST "));
-#ifdef HAVE_DYNAMIC
- if (ptr->flags & IFF_DYNAMIC)
- printf(_("DYNAMIC "));
-#endif
+ } 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
*/
printf(" ");
- printf(_
- ("RX packets:%Lu errors:%lu dropped:%lu overruns:%lu frame:%lu\n"),
+ printf(_("RX packets:%Lu 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);
printf(_(" compressed:%lu\n"),
ptr->stats.rx_compressed);
printf(" ");
- printf(_
- ("TX packets:%Lu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n"),
+ printf(_("TX packets:%Lu 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(" ");
if (ptr->map.irq)
printf(_("Interrupt:%d "), ptr->map.irq);
- if (ptr->map.base_addr >= 0x100) /* Only print devices using it for
+ 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);
/* Create a channel to the NET kernel. */
if ((skfd = sockets_open(0)) < 0) {
- perror_msg_and_die("socket");
+ bb_perror_msg_and_die("socket");
}
/* Do we have to show the current setup? */
status = if_print(ifname);
- close(skfd);
+#ifdef CONFIG_FEATURE_CLEAN_UP
+ sockets_close();
+#endif
exit(status < 0);
}