Commit cb9aeb94 authored by Bernd Eckenfels's avatar Bernd Eckenfels

- change columns of netstat -i/ifconfig -s to avoid run-into (Stefan Illner)

- prevent segfault on protocol families without host error member
- use /128 as default prefix if not specified instead of /0
parent 88d85a75
......@@ -3,7 +3,7 @@
* that either displays or sets the characteristics of
* one or more of the system's networking interfaces.
*
* Version: $Id: ifconfig.c,v 1.56 2002/07/05 17:36:02 ecki Exp $
* Version: $Id: ifconfig.c,v 1.57 2002/12/10 00:56:41 ecki Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* and others. Copyright 1993 MicroWalt Corporation
......@@ -529,7 +529,10 @@ int main(int argc, char **argv)
if (*++spp != NULL) {
safe_strncpy(host, *spp, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
if (ap->herror)
ap->herror(host);
else
fprintf(stderr, _("ifconfig: Error resolving '%s' for broadcast\n"), host);
goterr = 1;
spp++;
continue;
......@@ -551,7 +554,10 @@ int main(int argc, char **argv)
usage();
safe_strncpy(host, *spp, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
if (ap->herror)
ap->herror(host);
else
fprintf(stderr, _("ifconfig: Error resolving '%s' for dstaddr\n"), host);
goterr = 1;
spp++;
continue;
......@@ -571,7 +577,10 @@ int main(int argc, char **argv)
usage();
safe_strncpy(host, *spp, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
if (ap->herror)
ap->herror(host);
else
fprintf(stderr, _("ifconfig: Error resolving '%s' for netmask\n"), host);
goterr = 1;
spp++;
continue;
......@@ -658,7 +667,10 @@ int main(int argc, char **argv)
spp++;
safe_strncpy(host, *spp, (sizeof host));
if (ap->input(0, host, &sa)) {
if (ap->herror)
ap->herror(host);
else
fprintf(stderr, _("ifconfig: Error resolving '%s' for pointopoint\n"), host);
goterr = 1;
spp++;
continue;
......@@ -723,12 +735,15 @@ int main(int argc, char **argv)
usage();
*cp = 0;
} else {
prefix_len = 0;
prefix_len = 128;
}
safe_strncpy(host, *spp, (sizeof host));
if (inet6_aftype.input(1, host,
(struct sockaddr *) &sa6) < 0) {
if (inet6_aftype.herror)
inet6_aftype.herror(host);
else
fprintf(stderr, _("ifconfig: Error resolving '%s' for add\n"), host);
goterr = 1;
spp++;
continue;
......@@ -813,7 +828,7 @@ int main(int argc, char **argv)
usage();
*cp = 0;
} else {
prefix_len = 0;
prefix_len = 128;
}
safe_strncpy(host, *spp, (sizeof host));
if (inet6_aftype.input(1, host,
......@@ -842,6 +857,8 @@ int main(int argc, char **argv)
}
ifr6.ifr6_ifindex = ifr.ifr_ifindex;
ifr6.ifr6_prefixlen = prefix_len;
if (opt_v)
fprintf(stderr, "now deleting: ioctl(SIOCDIFADDR,{ifindex=%d,prefixlen=%ld})\n",ifr.ifr_ifindex,prefix_len);
if (ioctl(fd, SIOCDIFADDR, &ifr6) < 0) {
fprintf(stderr, "SIOCDIFADDR: %s\n",
strerror(errno));
......@@ -901,7 +918,7 @@ int main(int argc, char **argv)
usage();
*cp = 0;
} else {
prefix_len = 0;
prefix_len = 128;
}
safe_strncpy(host, *spp, (sizeof host));
if (inet6_aftype.input(1, host, (struct sockaddr *) &sa6) < 0) {
......@@ -963,9 +980,11 @@ int main(int argc, char **argv)
exit(1);
}
if (ap->input(0, host, &sa) < 0) {
if (ap->herror)
ap->herror(host);
fprintf(stderr, _("ifconfig: `--help' gives usage information.\n"));
exit(1);
else
fprintf(stderr,_("ifconfig: error resolving '%s' to set address for af=%s\n"), host, ap->name); fprintf(stderr,
_("ifconfig: `--help' gives usage information.\n")); exit(1);
}
memcpy((char *) &ifr.ifr_addr, (char *) &sa, sizeof(struct sockaddr));
{
......
......@@ -7,7 +7,7 @@
8/2000 Andi Kleen make the list operations a bit more efficient.
People are crazy enough to use thousands of aliases now.
$Id: interface.c,v 1.26 2002/12/05 22:10:32 ecki Exp $
$Id: interface.c,v 1.27 2002/12/10 00:56:41 ecki Exp $
*/
#include "config.h"
......@@ -594,13 +594,13 @@ int do_if_print(struct interface *ife, void *cookie)
void ife_print_short(struct interface *ptr)
{
printf("%-5.5s ", ptr->name);
printf("%5d %-2d", ptr->mtu, ptr->metric);
printf("%5d %-2d ", ptr->mtu, ptr->metric);
/* If needed, display the interface statistics. */
if (ptr->statistics_valid) {
printf("%9llu %6lu %6lu %-5lu",
printf("%8llu %6lu %6lu %-6lu ",
ptr->stats.rx_packets, ptr->stats.rx_errors,
ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors);
printf("%9llu %6lu %6lu %6lu ",
printf("%8llu %6lu %6lu %6lu ",
ptr->stats.tx_packets, ptr->stats.tx_errors,
ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors);
} else {
......
......@@ -6,7 +6,7 @@
* NET-3 Networking Distribution for the LINUX operating
* system.
*
* Version: $Id: netstat.c,v 1.49 2002/07/23 21:08:16 ecki Exp $
* Version: $Id: netstat.c,v 1.50 2002/12/10 00:56:41 ecki Exp $
*
* Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment