+/* vi: set sw=4 ts=4: */
/*
* stolen from net-tools-1.59 and stripped down for busybox by
* Erik Andersen <andersen@codepoet.org>
}
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
+ .name = "inet",
+ .title = "DARPA Internet",
+ .af = AF_INET,
+ .alen = 4,
+ .sprint = INET_sprint,
+ .fd = -1
};
#if HAVE_AFINET6
}
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
+ .name = "inet6",
+ .title = "IPv6",
+ .af = AF_INET6,
+ .alen = sizeof(struct in6_addr),
+ .sprint = INET6_sprint,
+ .fd = -1
};
#endif /* HAVE_AFINET6 */
sfd = af->fd;
}
if (sfd < 0) {
- bb_error_msg("No usable address families found.");
+ bb_error_msg("no usable address families found");
}
return sfd;
}
}
if (isdigit(*a) && isdigit(*b)) {
- return atoi(a_ptr) > atoi(b_ptr) ? 1 : -1;
+ return xatoul(a_ptr) > xatoul(b_ptr) ? 1 : -1;
}
return *a - *b;
}
static char *get_name(char *name, char *p)
{
- /* Extract <name>[:<alias>] from nul-terminated p where p matches
- <name>[:<alias>]: after leading whitespace.
+ /* Extract <name> from nul-terminated p where p matches
+ <name>: after leading whitespace.
If match is not made, set name empty and return unchanged p */
- int namestart=0, nameend=0, aliasend;
+ int namestart=0, nameend=0;
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';
name[0]='\0';
}
} else {
- /* first ':' not found - return empty */
+ /* trailing ':' not found - return empty */
name[0]='\0';
}
return p + 1;
fh = fopen(_PATH_PROCNET_DEV, "r");
if (!fh) {
- bb_perror_msg("Warning: cannot open %s. Limited output.", _PATH_PROCNET_DEV);
+ bb_perror_msg("warning: cannot open %s, limiting output", _PATH_PROCNET_DEV);
return if_readconf();
}
fgets(buf, sizeof buf, fh); /* eat line */
};
static const struct hwtype unspec_hwtype = {
- "unspec", "UNSPEC", -1, 0,
- UNSPEC_print, NULL, NULL
+ .name = "unspec",
+ .title = "UNSPEC",
+ .type = -1,
+ .print = UNSPEC_print
};
static const struct hwtype loop_hwtype = {
- "loop", "Local Loopback", ARPHRD_LOOPBACK, 0,
- NULL, NULL, NULL
+ .name = "loop",
+ .title = "Local Loopback",
+ .type = ARPHRD_LOOPBACK
};
#include <net/if_arp.h>
}
static const struct hwtype ether_hwtype = {
- "ether", "Ethernet", ARPHRD_ETHER, ETH_ALEN,
- pr_ether, NULL /* UNUSED in_ether */ , NULL
+ .name = "ether",
+ .title = "Ethernet",
+ .type = ARPHRD_ETHER,
+ .alen = ETH_ALEN,
+ .print = pr_ether
};
#include <net/if_arp.h>
static const struct hwtype ppp_hwtype = {
- "ppp", "Point-Point Protocol", ARPHRD_PPP, 0,
- NULL, NULL, NULL /* UNUSED do_ppp */ , 0
+ .name = "ppp",
+ .title = "Point-to-Point Protocol",
+ .type = ARPHRD_PPP
};
+#ifdef CONFIG_FEATURE_IPV6
+static const struct hwtype sit_hwtype = {
+ .name = "sit",
+ .title = "IPv6-in-IPv4",
+ .type = ARPHRD_SIT,
+ .print = UNSPEC_print,
+ .suppress_null_addr = 1
+} ;
+#endif
+
static const struct hwtype * const hwtypes[] = {
&loop_hwtype,
ðer_hwtype,
&ppp_hwtype,
&unspec_hwtype,
+#ifdef CONFIG_FEATURE_IPV6
+ &sit_hwtype,
+#endif
NULL
};
printf("(auto)");
}
#endif
- printf("\n");
+ puts("");
if (ptr->has_ip) {
printf(" %s addr:%s ", ap->name,
default:
printf("Unknown");
}
- printf("\n");
+ puts("");
}
}
fclose(f);
if (ptr->outfill || ptr->keepalive)
printf(" Outfill:%d Keepalive:%d", ptr->outfill, ptr->keepalive);
#endif
- printf("\n");
+ puts("");
/* If needed, display the interface statistics. */
}
if (ptr->map.dma)
printf("DMA chan:%x ", ptr->map.dma);
- printf("\n");
+ puts("");
}
- printf("\n");
+ puts("");
}