Commit c32a1ce0 authored by Phil Blundell's avatar Phil Blundell

Update manual pages to better match reality.

Pull code from ifconfig into interface.c; implement ifconfig -s
and netstat -i -e.
parent 3b602edc
......@@ -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.36 2000/05/21 13:46:39 pb Exp $
* Version: $Id: ifconfig.c,v 1.37 2000/05/21 19:35:34 pb Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* and others. Copyright 1993 MicroWalt Corporation
......@@ -65,40 +65,8 @@ struct in6_ifreq {
#endif
#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 */
#endif /* HAVE_AFINET6 */
#ifdef IFF_PORTSEL
static const char *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},
};
#endif
#if HAVE_AFIPX
#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
#include <netipx/ipx.h>
......@@ -132,246 +100,12 @@ static int set_ifstate(char *parent,
int flag);
void ife_print(struct interface *ptr)
{
struct aftype *ap;
struct hwtype *hw;
int hf;
int can_compress = 0;
#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);
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(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
/* 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(_(" inet6 addr: %s/%d"),
inet6_aftype.sprint((struct sockaddr *) &sap, 1), plen);
printf(_(" Scope:"));
switch (scope) {
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
#if HAVE_AFIPX
if (ipxtype == NULL)
ipxtype = get_afntype(AF_IPX);
if (ipxtype != NULL) {
if (ptr->has_ipx_bb)
printf(_(" IPX/Ethernet II addr:%s\n"),
ipxtype->sprint(&ptr->ipxaddr_bb, 1));
if (ptr->has_ipx_sn)
printf(_(" IPX/Ethernet SNAP addr:%s\n"),
ipxtype->sprint(&ptr->ipxaddr_sn, 1));
if (ptr->has_ipx_e2)
printf(_(" IPX/Ethernet 802.2 addr:%s\n"),
ipxtype->sprint(&ptr->ipxaddr_e2, 1));
if (ptr->has_ipx_e3)
printf(_(" IPX/Ethernet 802.3 addr:%s\n"),
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(_(" EtherTalk Phase 2 addr:%s\n"), 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(_(" econet addr:%s\n"), ectype->sprint(&ptr->ecaddr, 1));
}
#endif
printf(" ");
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
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:%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);
if (can_compress)
printf(_(" compressed:%lu\n"), ptr->stats.rx_compressed);
printf(" ");
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(_(" 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");
}
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%x "), 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 if_print(char *ifname)
{
int res;
int res;
if (ife_short)
printf(_("Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n"));
if (!ifname) {
res = for_all_interfaces(do_if_print, &opt_a);
......@@ -386,7 +120,6 @@ static int if_print(char *ifname)
return res;
}
/* Set a certain interface flag. */
static int set_flag(char *ifname, short flag)
{
......@@ -407,7 +140,6 @@ static int set_flag(char *ifname, short flag)
return (0);
}
/* Clear a certain interface flag. */
static int clr_flag(char *ifname, short flag)
{
......@@ -428,10 +160,9 @@ static int clr_flag(char *ifname, short flag)
return (0);
}
static void usage(void)
{
fprintf(stderr, _("Usage:\n ifconfig [-a] [-i] [-v] <interface> [[<AF>] <address>]\n"));
fprintf(stderr, _("Usage:\n ifconfig [-a] [-i] [-v] [-s] <interface> [[<AF>] <address>]\n"));
#if HAVE_AFINET
fprintf(stderr, _(" [add <address>[/<prefixlen>]]\n"));
fprintf(stderr, _(" [del <address>[/<prefixlen>]]\n"));
......@@ -522,17 +253,26 @@ int main(int argc, char **argv)
if (!strcmp(*argv, "-a"))
opt_a = 1;
if (!strcmp(*argv, "-v"))
opt_v = 1;
else if (!strcmp(*argv, "-s"))
ife_short = 1;
if (!strcmp(*argv, "-V") || !strcmp(*argv, "-version") ||
else if (!strcmp(*argv, "-v"))
opt_v = 1;
else if (!strcmp(*argv, "-V") || !strcmp(*argv, "-version") ||
!strcmp(*argv, "--version"))
version();
if (!strcmp(*argv, "-?") || !strcmp(*argv, "-h") ||
else if (!strcmp(*argv, "-?") || !strcmp(*argv, "-h") ||
!strcmp(*argv, "-help") || !strcmp(*argv, "--help"))
usage();
else {
fprintf(stderr, "ifconfig: unknown option %s\n", argv[0]);
fprintf(stderr, "(Use --help for usage information.\n)");
exit(1);
}
argv++;
argc--;
}
......
......@@ -74,6 +74,10 @@ extern int do_if_print(struct interface *ife, void *cookie);
extern void ife_print(struct interface *ptr);
extern int ife_short;
extern const char *if_port_text[][4];
/* Defines for poor glibc2.0 users, the feature check is done at runtime */
#if !defined(SIOCSIFTXQLEN)
#define SIOCSIFTXQLEN 0x8943
......
......@@ -4,7 +4,7 @@
10/1998 partly rewriten by Andi Kleen to support an interface list.
I don't claim that the list operations are efficient @).
$Id: interface.c,v 1.8 2000/02/20 17:50:08 philip Exp $
$Id: interface.c,v 1.9 2000/05/21 19:35:34 pb Exp $
*/
#include "config.h"
......@@ -48,8 +48,42 @@
#include "util.h"
#include "intl.h"
#ifdef IFF_PORTSEL
const char *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},
};
#endif
#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 */
int procnetdev_vsn = 1;
int ife_short;
static struct interface *int_list;
void add_interface(struct interface *n)
......@@ -525,3 +559,288 @@ int do_if_print(struct interface *ife, void *cookie)
}
return res;
}
void ife_print_short(struct interface *ptr)
{
printf("%-5.5s ", ptr->name);
printf("%5d %3d ", ptr->mtu, ptr->metric);
/* If needed, display the interface statistics. */
if (ptr->statistics_valid) {
printf("%8lu %6lu %6lu %6lu ",
ptr->stats.rx_packets, ptr->stats.rx_errors,
ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors);
printf("%8lu %6lu %6lu %6lu ",
ptr->stats.tx_packets, ptr->stats.tx_errors,
ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors);
} else {
printf("%-56s", _(" - no statistics available -"));
}
if (ptr->flags == 0)
printf(_("[NO FLAGS]"));
if (ptr->flags & IFF_ALLMULTI)
printf("A");
if (ptr->flags & IFF_BROADCAST)
printf("B");
if (ptr->flags & IFF_DEBUG)
printf("D");
if (ptr->flags & IFF_LOOPBACK)
printf("L");
if (ptr->flags & IFF_PROMISC)
printf("M");
if (ptr->flags & IFF_NOTRAILERS)
printf("N");
if (ptr->flags & IFF_NOARP)
printf("O");
if (ptr->flags & IFF_POINTOPOINT)
printf("P");
if (ptr->flags & IFF_RUNNING)
printf("R");
if (ptr->flags & IFF_UP)
printf("U");
printf("\n");
}
void ife_print_long(struct interface *ptr)
{
struct aftype *ap;
struct hwtype *hw;
int hf;
int can_compress = 0;
#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);
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(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
/* 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(_(" inet6 addr: %s/%d"),
inet6_aftype.sprint((struct sockaddr *) &sap, 1), plen);
printf(_(" Scope:"));
switch (scope) {
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
#if HAVE_AFIPX
if (ipxtype == NULL)
ipxtype = get_afntype(AF_IPX);
if (ipxtype != NULL) {
if (ptr->has_ipx_bb)
printf(_(" IPX/Ethernet II addr:%s\n"),
ipxtype->sprint(&ptr->ipxaddr_bb, 1));
if (ptr->has_ipx_sn)
printf(_(" IPX/Ethernet SNAP addr:%s\n"),
ipxtype->sprint(&ptr->ipxaddr_sn, 1));
if (ptr->has_ipx_e2)
printf(_(" IPX/Ethernet 802.2 addr:%s\n"),
ipxtype->sprint(&ptr->ipxaddr_e2, 1));
if (ptr->has_ipx_e3)
printf(_(" IPX/Ethernet 802.3 addr:%s\n"),
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(_(" EtherTalk Phase 2 addr:%s\n"), 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(_(" econet addr:%s\n"), ectype->sprint(&ptr->ecaddr, 1));
}
#endif
printf(" ");
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
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:%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);
if (can_compress)
printf(_(" compressed:%lu\n"), ptr->stats.rx_compressed);
printf(" ");
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(_(" 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");
}
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%x "), 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");
}
void ife_print(struct interface *i)
{
if (ife_short)
ife_print_short(i);
else
ife_print_long(i);
}
......@@ -11,7 +11,7 @@
.TH NETSTAT 8 "29 February 2000" "net-tools" "Linux Programmer's Manual"
.SH NAME
netstat \- Print network connections, routing tables, interface statistics, masquerade connections, netlink messages, and multicast memberships
netstat \- Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
.SH SYNOPSIS
......@@ -29,9 +29,7 @@ netstat \- Print network connections, routing tables, interface statistics, masq
.RB [ \-\-program | \-p ]
.RB [ \-\-verbose | \-v ]
.RB [ \-\-continuous | \-c]
.PP
.P
.B netstat
.RB { \-\-route | \-r }
.RI [ address_family_options ]
......@@ -39,9 +37,7 @@ netstat \- Print network connections, routing tables, interface statistics, masq
.RB [ \-\-verbose | \-v ]
.RB [ \-\-numeric | \-n ]
.RB [ \-\-continuous | \-c]
.PP
.P
.B netstat
.RB { \-\-interfaces | \-i }
.RI [ iface ]
......@@ -51,49 +47,30 @@ netstat \- Print network connections, routing tables, interface statistics, masq
.RB [ \-\-program | \-p ]
.RB [ \-\-numeric | \-n ]
.RB [ \-\-continuous | \-c]
.PP
.P
.B netstat
.RB [ \-\-groups | \-g ]
.RB { \-\-groups | \-g }
.RB [ \-\-numeric | \-n ]
.RB [ \-\-continuous | \-c]
.PP
.P
.B netstat
.RB { \-\-masquerade | \-M }
.RB [ \-\-extend | \-e ]
.RB [ \-\-numeric | \-n ]
.RB [ \-\-continuous | \-c]
.PP
.P
.B netstat
.RB { \-\-statistics | -s }
.RB [ \-\-tcp | \-t ]
.RB [ \-\-udp | \-u ]
.RB [ \-\-raw | \-w ]
.PP
.B netstat
.RB { \-\-netlink | \-L }
.RB [ \-\-numeric | \-n ]
.RB [ \-\-continuous | \-c]
.PP
.P
.B netstat
.RB { \-\-version | \-V }
.PP
.P
.B netstat
.RB { \-\-help | \-h }
.PP
.P
.IR address_family_options :
.PP
.RB [ \-\-protocol= { inet , unix , ipx , ax25 , netrom , ddp }[, ...] ]
......@@ -104,114 +81,35 @@ netstat \- Print network connections, routing tables, interface statistics, masq
.RB [ \-\-netrom ]
.RB [ \-\-ddp ]
.PP
.SH DESCRIPTION
.B Netstat
prints information about the Linux networking subsystem.
.SS "(no option)"
By default,
prints information about the Linux networking subsystem. The type of
information printed is controlled by the first argument, as follows:
.SS (none)
By default,
.B
netstat
prints the status of network connections by listing the open
sockets. If you don't specify any address families, then the active
sockets of all configured address families will be printed. With
.BR \-\-extend " (" \-e )
you get some additional information (userid). Use it twice to add
more information (inode number). With the
.BR \-\-verbose " (" \-v )
option, you can make netstat complain about known address families which are
not supported by the kernel. The
.BR \-\-timers " (" \-o )
option prints some additional information on networking timers. Enabling the
.BR \-\-program " (" \-p )
will show you the process PID and name of the program that has the socket
open.
.BR \-\-listening " (" \-L )
makes
.B
netstat
show only the sockets which are only listening, which are omitted by default.
With
.BR \-\-all " (" \-a ),
you get both the listening and the non-listening sockets. The address
family
.B inet
includes raw, udp and tcp protocol sockets.
displays a list of open sockets. If you don't specify any
address families, then the active sockets of all configured address
families will be printed.
.SS "\-\-route , \-r"
With the
.BR \-\-route " (" \-r )
option, you get the kernel routing tables in the same format as
.B "route -e"
use.
.B "netstat --route --extend"
uses the output format of
.BR route .
Please see
.BR route (8)
for details.
Display the kernel routing tables.
.SS "\-\-groups , \-g"
With the
.BR \-\-groups " (" \-g )
option, IGMP multicast group membership information for IPv4 and IPv6 is
printed.
Display multicast group membership information for IPv4 and IPv6.
.SS "\-\-interface=\fIiface \fR, \fB\-i"
If you use the
.BR \-\-interfaces " (" -\i )
option, a table of all (or the specified
.IR iface )
networking interfaces will be printed. The output uses the
.B "ifconfig -e"
format, and is described in
.BR ifconfig (8).
.B "netstat --interface --extend"
will print a table or a single interface entry just like
.B ifconfig
does. With the
.BR \-\-all " (" \-a )
option, you can include interfaces which are not configured (i.e. don't have
the
.BR U = UP
flag set).
Display a table of all network interfaces, or the specified
.IR iface ) .
.SS "\-\-masquerade , \-M"
This generates a list of masqueraded sessions. With the
.BR \-\-extend " (" \-e )
option, you can include some more information about sequence numbering and
deltas, caused by data rewrites on FTP sessions (PORT
command). Masquerade support is used to hide hosts with unofficial network
addresses from the outside world, as described in
.BR ipfw "(4), " ipfwadm "(8), and " ipfw (8).
Display a list of masqueraded connections.
.SS "\-\-statistics , \-s"
.B netstat
prints summary statistics for each protocol.
.SS "\-\-netlink , \-N"
Recent kernels have a kernel/user communication support called netlink. You
can get messages about creation or deletion of interfaces or routes from
.I /dev/route
(36,0).
.PP
Display summary statistics for each protocol.
.SH OPTIONS
.SS "\-\-verbose , \-v"
Tell the user what is going on by being verbose. Especially print some
useful information about unconfigured address families.
.SS "\-\-numeric , \-n"
shows numerical addresses instead of trying to determine symbolic host, port
Show numerical addresses instead of trying to determine symbolic host, port
or user names.
.SS "\-\-protocol=\fIfamily \fR, \fB\-A"
Specifies the address families (perhaps better described as low level
protocols) for which connections are to be shown.
......@@ -233,38 +131,50 @@ This has the same effect as using the
and
.B \-\-ddp
options.
.SS "\-c, \-\-continous"
.P
The address family
.B inet
includes raw, udp and tcp protocol sockets.
.SS "\-c, \-\-continuous"
This will cause
.B netstat
to print the selected information every second continously.
.PP
to print the selected information every second continuously.
.SS "\-e, \-\-extend"
Display additional information. Use this option twice for maximum detail.
.SS "\-o, \-\-timers"
Include information related to networking timers.
.SS "\-p, \-\-program"
Show the PID and name of the program to which each socket belongs.
.SS "\-L, \-\-listening"
Show only listening sockets. (These are omitted by default.)
.SS "\-a, \-\-all"
Show both listening and non-listening sockets. With the
.B --interfaces
option, show interfaces that are not marked
.SS "\-F"
Print routing information from the FIB. (This is the default.)
.SS "\-C"
Print routing information from the route cache.
.IR UP .
.P
.SH OUTPUT
.PP
.P
.SS Active Internet connections \fR(TCP, UDP, raw)\fR
.SS "Proto"
The protocol (tcp, udp, raw) used by the socket.
.SS "Recv-Q"
The count of bytes not copied by the user program connected to this socket.
.SS "Send-Q"
The count of bytes not acknowledged by the remote host.
.SS "Local Address"
Address and port number of the local end of the socket. Unless the
.BR \-\-numeric " (" \-n )
option is specified, the socket address is resolved to its canonical
host name (FQDN), and the port number is translated into the
corresponding service name.
.SS "Foreign Address"
Address and port number of the remote end of the socket.
Analogous to "Local Address."
.SS "State"
The state of the socket. Since there are no states in raw mode and usually no
states used in UDP, this column may be left blank. Normally this can be one
......@@ -325,10 +235,8 @@ sent.
.I
UNKNOWN
The state of the socket is unknown.
.SS "User"
The username or the user id (UID) of the owner of the socket.
.SS "PID/Program name"
Slash-separated pair of the process id (PID) and process name of the
process that owns the socket.
......@@ -337,21 +245,14 @@ causes this column to be included. You will also need
.I superuser
privileges to see this information on sockets you don't own. This
identification information is not yet available for IPX sockets.
.SS "Timer"
(this needs to be written)
.PP
.P
.SS Active UNIX domain Sockets
.SS "Proto"
The protocol (usually unix) used by the socket.
.SS "RefCnt"
The reference count (i.e. attached processes via this socket).
.SS "Flags"
The flags displayed is SO_ACCEPTON (displayed as
.BR ACC ),
......@@ -363,7 +264,6 @@ SO_ACCECPTON
is used on unconnected sockets if their corresponding
processes are waiting for a connect request. The other flags are not
of normal interest.
.SS "Type"
There are several types of socket access:
.TP
......@@ -394,7 +294,6 @@ Raw interface access socket.
.I
UNKNOWN
Who ever knows what the future will bring us - just fill in here :-)
.PP
.SS "State"
This field will contain one of the following Keywords:
......@@ -424,35 +323,26 @@ The socket is not connected to another one.
.TP
.I UNKNOWN
This state should never happen.
.SS "PID/Program name"
Process ID (PID) and process name of the process that has the socket open.
More info available in
.B "Active Internet connections"
section written above.
.SS "Path"
This is the path name as which the corresponding processes attached
to the socket.
.PP
.P
.SS Active IPX sockets
(this needs to be done by somebody who knows it)
.PP
.P
.SS Active NET/ROM sockets
(this needs to be done by somebody who knows it)
.PP
.P
.SS Active AX.25 sockets
(this needs to be done by somebody who knows it)
.PP
.SH NOTES
Starting with Linux Release 2.2
Starting with Linux release 2.2
.B netstat -i
does not show interface statistics for alias interfaces. To get per
alias interface counters you need to setup explicit rules using the
......@@ -474,7 +364,6 @@ status information via the following files.
.I /proc/net/raw
-- raw socket information
.I /proc/net/tcp
-- TCP socket information
......@@ -517,29 +406,21 @@ status information via the following files.
.I /proc/net/ip_masquerade
-- masqueraded connections
.I /proc/net/snmp
-- statistics
.fi
.PP
.P
.SH SEE ALSO
.BR route (8),
.BR ifconfig (8),
.BR ipfw (4),
.BR ipfw (8),
.BR ipfwadm (8),
.BR ipchains (8),
.BR iptables (8),
.BR proc (5)
.PP
.P
.SH BUGS
Occasionally strange information may appear if a socket changes
as it is viewed. This is unlikely to occur.
.br
The
.B netstat -i
options is described as it should work after some code cleanup of the BETA
release of the net-tools package.
.PP
.P
.SH AUTHORS
The netstat user interface was written by Fred Baumgarten
<dc6iq@insu1.etec.uni-karlsruhe.de> the man page basically
......
......@@ -210,13 +210,13 @@ This command adds the net "192.57.66.x" to be gatewayed through the former
route to the SLIP interface.
.TP
.B route add 224.0.0.0 netmask 240.0.0.0 dev eth0
.B route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
This is an obscure one documented so people know how to do it. This sets
all of the class D (multicast) IP routes to go via "eth0". This is the
correct normal configuration line with a multicasting kernel.
.TP
.B route add 10.0.0.0 netmask 255.0.0.0 reject
.B route add -net 10.0.0.0 netmask 255.0.0.0 reject
This installs a rejecting route for the private network "10.x.x.x."
.LP
......
......@@ -6,7 +6,7 @@
* NET-3 Networking Distribution for the LINUX operating
* system.
*
* Version: $Id: netstat.c,v 1.36 2000/05/20 13:38:10 pb Exp $
* Version: $Id: netstat.c,v 1.37 2000/05/21 19:35:34 pb Exp $
*
* Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
......@@ -121,7 +121,7 @@ typedef enum {
#define FEATURE_NETSTAT
#include "lib/net-features.h"
char *Release = RELEASE, *Version = "netstat 1.38 (1999-04-20)", *Signature = "Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang and others";
char *Release = RELEASE, *Version = "netstat 1.39 (2000-05-21)", *Signature = "Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang and others";
#define E_READ -1
......@@ -724,12 +724,12 @@ static void tcp_do_one(int lnr, const char *line)
sscanf(local_addr, "%08X%08X%08X%08X",
&in6.s6_addr32[0], &in6.s6_addr32[1],
&in6.s6_addr32[2], &in6.s6_addr32[3]);
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
inet6_aftype.input(1, addr6, (struct sockaddr *) &localaddr);
sscanf(rem_addr, "%08X%08X%08X%08X",
&in6.s6_addr32[0], &in6.s6_addr32[1],
&in6.s6_addr32[2], &in6.s6_addr32[3]);
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
&in6.s6_addr32[2], &in6.s6_addr32[3]);
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
inet6_aftype.input(1, addr6, (struct sockaddr *) &remaddr);
localaddr.sin6_family = AF_INET6;
remaddr.sin6_family = AF_INET6;
......@@ -848,13 +848,13 @@ static void udp_do_one(int lnr, const char *line)
#if HAVE_AFINET6
sscanf(local_addr, "%08X%08X%08X%08X",
&in6.s6_addr32[0], &in6.s6_addr32[1],
&in6.s6_addr32[2], &in6.s6_addr32[3]);
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
&in6.s6_addr32[2], &in6.s6_addr32[3]);
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
inet6_aftype.input(1, addr6, (struct sockaddr *) &localaddr);
sscanf(rem_addr, "%08X%08X%08X%08X",
&in6.s6_addr32[0], &in6.s6_addr32[1],
&in6.s6_addr32[2], &in6.s6_addr32[3]);
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
&in6.s6_addr32[2], &in6.s6_addr32[3]);
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
inet6_aftype.input(1, addr6, (struct sockaddr *) &remaddr);
localaddr.sin6_family = AF_INET6;
remaddr.sin6_family = AF_INET6;
......@@ -1424,46 +1424,6 @@ static int ipx_info(void)
}
#endif
void ife_print(struct interface *ptr)
{
printf("%-5.5s ", ptr->name);
printf("%5d %3d ", ptr->mtu, ptr->metric);
/* If needed, display the interface statistics. */
if (ptr->statistics_valid) {
printf("%8lu %6lu %6lu %6lu ",
ptr->stats.rx_packets, ptr->stats.rx_errors,
ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors);
printf("%8lu %6lu %6lu %6lu ",
ptr->stats.tx_packets, ptr->stats.tx_errors,
ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors);
} else {
printf("%-56s", _(" - no statistics available -"));
}
if (ptr->flags == 0)
printf(_("[NO FLAGS]"));
if (ptr->flags & IFF_ALLMULTI)
printf("A");
if (ptr->flags & IFF_BROADCAST)
printf("B");
if (ptr->flags & IFF_DEBUG)
printf("D");
if (ptr->flags & IFF_LOOPBACK)
printf("L");
if (ptr->flags & IFF_PROMISC)
printf("M");
if (ptr->flags & IFF_NOTRAILERS)
printf("N");
if (ptr->flags & IFF_NOARP)
printf("O");
if (ptr->flags & IFF_POINTOPOINT)
printf("P");
if (ptr->flags & IFF_RUNNING)
printf("R");
if (ptr->flags & IFF_UP)
printf("U");
printf("\n");
}
static int iface_info(void)
{
if (skfd < 0) {
......@@ -1473,7 +1433,10 @@ static int iface_info(void)
}
printf(_("Kernel Interface table\n"));
}
printf(_("Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n"));
if (!flag_exp) {
ife_short = 1;
printf(_("Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n"));
}
if (for_all_interfaces(do_if_print, &flag_all) < 0) {
perror(_("missing interface information"));
......@@ -1541,7 +1504,6 @@ int main
{"interfaces", 0, 0, 'i'},
{"help", 0, 0, 'h'},
{"route", 0, 0, 'r'},
{"netlink", 2, 0, 'L'},
#if HAVE_FW_MASQUERADE
{"masquerade", 0, 0, 'M'},
#endif
......@@ -1824,18 +1786,21 @@ int main
#else
if (flag_arg) {
i = 1;
if(!flag_arg || flag_x25) {
#if HAVE_AFX25
/* FIXME */
i = x25_info();
if(i) { return(i); }
#endif
}
if (flag_arg)
{ i=1; ENOSUPP("netstat","AF X25"); }
ENOSUPP("netstat", "AF AX25");
}
#endif
}
if(!flag_arg || flag_x25) {
#if HAVE_AFX25
/* FIXME */
i = x25_info();
if (i)
return(i);
#else
if (flag_arg) {
i = 1;
ENOSUPP("netstat", "AF X25");
}
#endif
}
if (!flag_arg || flag_netrom) {
......
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