Skip to content

Commit

Permalink
import freebsd44.
Browse files Browse the repository at this point in the history
  • Loading branch information
keiichi committed Sep 26, 2001
1 parent 0213f9b commit 6af741f
Show file tree
Hide file tree
Showing 24 changed files with 748 additions and 663 deletions.
4 changes: 2 additions & 2 deletions freebsd4/usr.bin/netstat/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# $FreeBSD: src/usr.bin/netstat/Makefile,v 1.14.2.2 2001/03/22 13:48:42 des Exp $
# $FreeBSD: src/usr.bin/netstat/Makefile,v 1.14.2.3 2001/08/10 09:07:08 ru Exp $
# @(#)Makefile 8.1 (Berkeley) 6/12/93

PROG= netstat
SRCS= if.c inet.c inet6.c main.c mbuf.c mroute.c ipx.c route.c \
unix.c atalk.c netgraph.c mroute6.c ipsec.c # iso.c ns.c tp_astring.c
CFLAGS+=-Wall
CFLAGS+=-DIPSEC
CFLAGS+=-DINET6

#CFLAGS+=-g
#.PATH: ${.CURDIR}/../../sys/netiso
BINGRP= kmem
BINMODE=2555
DPADD= ${LIBKVM} ${LIBIPX} ${LIBNETGRAPH} ${LIBUTIL}
LDADD= -lkvm -lipx -lnetgraph -lutil
CFLAGS+=-DINET6 -DIPSEC

.include <bsd.prog.mk>
36 changes: 22 additions & 14 deletions freebsd4/usr.bin/netstat/atalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
static char sccsid[] = "@(#)atalk.c 1.1 (Whistle) 6/6/96";
*/
static const char rcsid[] =
"$FreeBSD: src/usr.bin/netstat/atalk.c,v 1.13 1999/10/21 07:08:55 julian Exp $";
"$FreeBSD: src/usr.bin/netstat/atalk.c,v 1.13.2.1 2001/08/10 09:07:08 ru Exp $";
#endif /* not lint */

#include <sys/param.h>
Expand All @@ -50,8 +50,9 @@ static const char rcsid[] =
#include <netatalk/at.h>
#include <netatalk/ddp_var.h>

#include <nlist.h>
#include <errno.h>
#include <nlist.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include "netstat.h"
Expand Down Expand Up @@ -102,18 +103,30 @@ static char mybuf[50];
return mybuf;
}

char *
static char *
at_pr_port(struct sockaddr_at *sat)
{
static char mybuf[50];
struct servent *serv;

switch(sat->sat_port) {
case ATADDR_ANYPORT:
return("*");
case 0xff:
return "????";
default:
sprintf(mybuf,"%d",(unsigned int)sat->sat_port);
if (nflag) {
(void)snprintf(mybuf, sizeof(mybuf), "%d",
(unsigned int)sat->sat_port);
} else {
serv = getservbyport(sat->sat_port, "ddp");
if (serv == NULL)
(void)snprintf(mybuf, sizeof(mybuf), "%d",
(unsigned int) sat->sat_port);
else
(void) snprintf(mybuf, sizeof(mybuf), "%s",
serv->s_name);
}
}
return mybuf;
}
Expand Down Expand Up @@ -142,8 +155,7 @@ static char mybuf[50];
/* 4 for port */
/* 8 for numeric only */
char *
atalk_print(sa,what)
register struct sockaddr *sa;
atalk_print(struct sockaddr *sa, int what)
{
struct sockaddr_at *sat = (struct sockaddr_at *)sa;
static char mybuf[50];
Expand Down Expand Up @@ -200,9 +212,7 @@ atalk_print2(struct sockaddr *sa, struct sockaddr *mask, int what)
}

void
atalkprotopr(off, name)
u_long off;
char *name;
atalkprotopr(u_long off __unused, char *name, int af __unused)
{
struct ddpcb *this, *next;

Expand Down Expand Up @@ -244,16 +254,14 @@ atalkprotopr(off, name)
}
}

#define ANY(x,y,z) \
((x) ? printf("\t%lu %s%s%s\n",x,y,plural(x),z) : 0)
#define ANY(x,y,z) if (x || sflag <= 1) \
printf("\t%lu %s%s%s\n",x,y,plural(x),z)

/*
* Dump DDP statistics structure.
*/
void
ddp_stats(off, name)
u_long off;
char *name;
ddp_stats(u_long off __unused, char *name, int af __unused)
{
struct ddpstat ddpstat;

Expand Down
36 changes: 14 additions & 22 deletions freebsd4/usr.bin/netstat/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
static char sccsid[] = "@(#)if.c 8.3 (Berkeley) 4/28/95";
*/
static const char rcsid[] =
"$FreeBSD: src/usr.bin/netstat/if.c,v 1.32.2.6 2001/03/28 21:07:55 des Exp $";
"$FreeBSD: src/usr.bin/netstat/if.c,v 1.32.2.8 2001/08/10 09:07:08 ru Exp $";
#endif /* not lint */

#include <sys/types.h>
Expand Down Expand Up @@ -76,17 +76,18 @@ static const char rcsid[] =
#define YES 1
#define NO 0

static void sidewaysintpr __P((u_int, u_long));
static void catchalarm __P((int));
static void sidewaysintpr (u_int, u_long);
static void catchalarm (int);

#ifdef INET6
char *netname6 __P((struct sockaddr_in6 *, struct in6_addr *));
char *netname6 (struct sockaddr_in6 *, struct in6_addr *);
static char ntop_buf[INET6_ADDRSTRLEN]; /* for inet_ntop() */
static int bdg_done;
#endif

/* print bridge statistics */
void
bdg_stats(u_long dummy, char *name) /* print bridge statistics */
bdg_stats(u_long dummy __unused, char *name, int af __unused)
{
int i;
size_t slen ;
Expand Down Expand Up @@ -131,12 +132,8 @@ bdg_stats(u_long dummy, char *name) /* print bridge statistics */
/*
* Display a formatted value, or a '-' in the same space.
*/
void
show_stat(fmt, width, value, showvalue)
char *fmt;
int width;
u_long value;
short showvalue;
static void
show_stat(const char *fmt, int width, u_long value, short showvalue)
{
char newfmt[32];

Expand All @@ -156,10 +153,7 @@ show_stat(fmt, width, value, showvalue)
* Print a description of the network interfaces.
*/
void
intpr(interval, ifnetaddr, pfunc)
int interval;
u_long ifnetaddr;
void (*pfunc)(char *);
intpr(int interval, u_long ifnetaddr, void (*pfunc)(char *))
{
struct ifnet ifnet;
struct ifnethead ifnethead;
Expand Down Expand Up @@ -208,7 +202,7 @@ intpr(interval, ifnetaddr, pfunc)
if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet))
return;

if ((!sflag || iflag) && !pflag) {
if (!pfunc) {
printf("%-5.5s %-5.5s %-13.13s %-15.15s %8.8s %5.5s",
"Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs");
if (bflag)
Expand Down Expand Up @@ -472,9 +466,10 @@ intpr(interval, ifnetaddr, pfunc)
ntop_buf,
sizeof(ntop_buf)),
ifma.ifma_refcount);
break;
#endif /* INET6 */
case AF_LINK:
switch (ifnet.if_type) {
switch (msa.dl.sdl_type) {
case IFT_ETHER:
case IFT_FDDI:
fmt = ether_ntoa(
Expand Down Expand Up @@ -514,9 +509,7 @@ u_char signalled; /* set if alarm goes off "early" */
* XXX - should be rewritten to use ifmib(4).
*/
static void
sidewaysintpr(interval, off)
unsigned interval;
u_long off;
sidewaysintpr(unsigned interval, u_long off)
{
struct ifnet ifnet;
u_long firstifnet;
Expand Down Expand Up @@ -679,8 +672,7 @@ sidewaysintpr(interval, off)
* Sets a flag to not wait for the alarm.
*/
static void
catchalarm(signo)
int signo;
catchalarm(int signo __unused)
{
signalled = YES;
}
50 changes: 17 additions & 33 deletions freebsd4/usr.bin/netstat/inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
*/
static const char rcsid[] =
"$FreeBSD: src/usr.bin/netstat/inet.c,v 1.37.2.2 2001/03/22 13:48:42 des Exp $";
"$FreeBSD: src/usr.bin/netstat/inet.c,v 1.37.2.4 2001/08/10 09:07:09 ru Exp $";
#endif /* not lint */

#include <sys/param.h>
Expand Down Expand Up @@ -80,10 +80,10 @@ static const char rcsid[] =
#include <unistd.h>
#include "netstat.h"

char *inetname __P((struct in_addr *));
void inetprint __P((struct in_addr *, int, char *, int));
char *inetname (struct in_addr *);
void inetprint (struct in_addr *, int, char *, int);
#ifdef INET6
extern void inet6print __P((struct in6_addr *, int, char *, int));
extern void inet6print (struct in6_addr *, int, char *, int);
static int udp_done, tcp_done;
#endif /* INET6 */

Expand All @@ -94,10 +94,8 @@ static int udp_done, tcp_done;
* -a (all) flag is specified.
*/
void
protopr(proto, name, af)
u_long proto; /* for sysctl version we pass proto # */
char *name;
int af;
protopr(u_long proto, /* for sysctl version we pass proto # */
char *name, int af)
{
int istcp;
static int first = 1;
Expand Down Expand Up @@ -167,7 +165,7 @@ protopr(proto, name, af)
}

/* Ignore sockets for protocols other than the desired one. */
if (so->xso_protocol != proto)
if (so->xso_protocol != (int)proto)
continue;

/* Ignore PCBs which were freed during copyout. */
Expand Down Expand Up @@ -348,9 +346,7 @@ protopr(proto, name, af)
* Dump TCP statistics structure.
*/
void
tcp_stats(off, name)
u_long off;
char *name;
tcp_stats(u_long off __unused, char *name, int af __unused)
{
struct tcpstat tcpstat;
size_t len = sizeof tcpstat;
Expand Down Expand Up @@ -448,9 +444,7 @@ tcp_stats(off, name)
* Dump UDP statistics structure.
*/
void
udp_stats(off, name)
u_long off;
char *name;
udp_stats(u_long off __unused, char *name, int af __unused)
{
struct udpstat udpstat;
size_t len = sizeof udpstat;
Expand Down Expand Up @@ -501,9 +495,7 @@ udp_stats(off, name)
* Dump IP statistics structure.
*/
void
ip_stats(off, name)
u_long off;
char *name;
ip_stats(u_long off __unused, char *name, int af __unused)
{
struct ipstat ipstat;
size_t len = sizeof ipstat;
Expand Down Expand Up @@ -552,6 +544,7 @@ ip_stats(off, name)
p(ips_ofragments, "\t%lu fragment%s created\n");
p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
p(ips_nogif, "\t%lu tunneling packet%s that can't find gif\n");
p(ips_badaddr, "\t%lu datagram%s with bad address in header\n");
#undef p
#undef p1a
}
Expand Down Expand Up @@ -582,9 +575,7 @@ static char *icmpnames[] = {
* Dump ICMP statistics.
*/
void
icmp_stats(off, name)
u_long off;
char *name;
icmp_stats(u_long off __unused, char *name, int af __unused)
{
struct icmpstat icmpstat;
int i, first;
Expand Down Expand Up @@ -650,9 +641,7 @@ icmp_stats(off, name)
* Dump IGMP statistics structure.
*/
void
igmp_stats(off, name)
u_long off;
char *name;
igmp_stats(u_long off __unused, char *name, int af __unused)
{
struct igmpstat igmpstat;
size_t len = sizeof igmpstat;
Expand Down Expand Up @@ -685,11 +674,7 @@ igmp_stats(off, name)
* Pretty print an Internet address (net address + port).
*/
void
inetprint(in, port, proto,numeric)
register struct in_addr *in;
int port;
char *proto;
int numeric;
inetprint(struct in_addr *in, int port, char *proto, int numeric_port)
{
struct servent *sp = 0;
char line[80], *cp;
Expand All @@ -698,9 +683,9 @@ inetprint(in, port, proto,numeric)
if (Wflag)
sprintf(line, "%s.", inetname(in));
else
sprintf(line, "%.*s.", (Aflag && !numeric) ? 12 : 16, inetname(in));
sprintf(line, "%.*s.", (Aflag && !numeric_port) ? 12 : 16, inetname(in));
cp = index(line, '\0');
if (!numeric && port)
if (!numeric_port && port)
sp = getservbyport((int)port, proto);
if (sp || port == 0)
sprintf(cp, "%.15s ", sp ? sp->s_name : "*");
Expand All @@ -719,8 +704,7 @@ inetprint(in, port, proto,numeric)
* numeric value, otherwise try for symbolic name.
*/
char *
inetname(inp)
struct in_addr *inp;
inetname(struct in_addr *inp)
{
register char *cp;
static char line[MAXHOSTNAMELEN];
Expand Down
Loading

0 comments on commit 6af741f

Please sign in to comment.