Merge in Lite-2 changes.

This commit is contained in:
peter 1996-01-14 23:33:13 +00:00
parent d6750ce6ed
commit e0dc992026
4 changed files with 106 additions and 31 deletions

View File

@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)if.c 8.2 (Berkeley) 2/21/94";
static char sccsid[] = "@(#)if.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/types.h>
@ -200,7 +200,7 @@ intpr(interval, ifnetaddr)
cp = (char *)LLADDR(sdl);
n = sdl->sdl_alen;
}
m = printf("<Link>");
m = printf("%-11.11s ", "<Link>");
goto hexprint;
default:
m = printf("(%d)", sa->sa_family);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1983, 1988, 1993
* Copyright (c) 1983, 1988, 1993, 1995
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94";
static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
#endif /* not lint */
#include <sys/param.h>
@ -217,6 +217,7 @@ tcp_stats(off, name)
p(tcps_rcvshort, "\t\t%d discarded because packet too short\n");
p(tcps_connattempt, "\t%d connection request%s\n");
p(tcps_accepts, "\t%d connection accept%s\n");
p(tcps_badsyn, "\t%d bad connection attempt%s\n");
p(tcps_connects, "\t%d connection%s established (including accepts)\n");
p2(tcps_closed, tcps_drops,
"\t%d connection%s closed (including %d drop%s)\n");

View File

@ -34,7 +34,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)mroute.c 8.1 (Berkeley) 6/6/93
* @(#)mroute.c 8.2 (Berkeley) 4/28/95
*/
/*

View File

@ -33,10 +33,10 @@
#ifndef lint
#if 0
static char sccsid[] = "From: @(#)route.c 8.3 (Berkeley) 3/9/94";
static char sccsid[] = "From: @(#)route.c 8.6 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
"$Id: route.c,v 1.7 1995/10/26 20:31:59 julian Exp $";
"$Id: route.c,v 1.8 1995/12/05 07:29:15 julian Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -114,7 +114,7 @@ static void p_tree __P((struct radix_node *));
static void p_rtnode __P(());
static void ntreestuff __P(());
static void np_rtentry __P((struct rt_msghdr *));
static void p_sockaddr __P((struct sockaddr *, int, int));
static void p_sockaddr __P((struct sockaddr *, struct sockaddr *, int, int));
static void p_flags __P((int, char *));
static void p_rtentry __P((struct rtentry *));
@ -194,7 +194,7 @@ pr_family(af)
}
/* column widths; each followed by one space */
#define WID_DST 16 /* width of destination column */
#define WID_DST 18 /* width of destination column */
#define WID_GW 18 /* width of gateway column */
/*
@ -243,7 +243,7 @@ p_tree(rn)
p_rtnode();
} else {
p_sockaddr(kgetsa((struct sockaddr *)rnode.rn_key),
0, 44);
NULL, 0, 44);
putchar('\n');
}
if (rn = rnode.rn_dupedkey)
@ -270,7 +270,7 @@ p_rtnode()
if (rnode.rn_mask) {
printf("\t mask ");
p_sockaddr(kgetsa((struct sockaddr *)rnode.rn_mask),
0, -1);
NULL, 0, -1);
} else if (rm == 0)
return;
} else {
@ -282,7 +282,15 @@ p_rtnode()
sprintf(nbuf, " %d refs, ", rmask.rm_refs);
printf(" mk = %8.8x {(%d),%s",
rm, -1 - rmask.rm_b, rmask.rm_refs ? nbuf : " ");
p_sockaddr(kgetsa((struct sockaddr *)rmask.rm_mask), 0, -1);
if (rmask.rm_flags & RNF_NORMAL) {
struct radix_node rnode_aux;
printf(" <normal>, ");
kget(rmask.rm_leaf, rnode_aux);
p_sockaddr(kgetsa((struct sockaddr *)rnode_aux.rn_mask),
NULL, 0, -1);
} else
p_sockaddr(kgetsa((struct sockaddr *)rmask.rm_mask),
NULL, 0, -1);
putchar('}');
if (rm = rmask.rm_mklist)
printf(" ->");
@ -351,21 +359,21 @@ np_rtentry(rtm)
old_af = af;
}
if (rtm->rtm_addrs == RTA_DST)
p_sockaddr(sa, 0, 36);
p_sockaddr(sa, NULL, 0, 36);
else {
p_sockaddr(sa, rtm->rtm_flags, 16);
p_sockaddr(sa, NULL, rtm->rtm_flags, 16);
if (sa->sa_len == 0)
sa->sa_len = sizeof(long);
sa = (struct sockaddr *)(sa->sa_len + (char *)sa);
p_sockaddr(sa, 0, 18);
p_sockaddr(sa, NULL, 0, 18);
}
p_flags(rtm->rtm_flags & interesting, "%-6.6s ");
putchar('\n');
}
static void
p_sockaddr(sa, flags, width)
struct sockaddr *sa;
p_sockaddr(sa, mask, flags, width)
struct sockaddr *sa, *mask;
int flags, width;
{
char workbuf[128], *cplim;
@ -376,10 +384,16 @@ p_sockaddr(sa, flags, width)
{
register struct sockaddr_in *sin = (struct sockaddr_in *)sa;
cp = (sin->sin_addr.s_addr == 0) ? "default" :
((flags & RTF_HOST) ?
routename(sin->sin_addr.s_addr) :
netname(sin->sin_addr.s_addr, 0L));
if (sin->sin_addr.s_addr == INADDR_ANY)
cp = "default";
else if (flags & RTF_HOST)
cp = routename(sin->sin_addr.s_addr);
else if (mask)
cp = netname(sin->sin_addr.s_addr,
ntohl(((struct sockaddr_in *)mask)
->sin_addr.s_addr));
else
cp = netname(sin->sin_addr.s_addr, 0L);
break;
}
@ -473,6 +487,8 @@ p_rtentry(rt)
static struct ifnet ifnet, *lastif;
static char name[16];
static char prettyname[9];
struct sockaddr *sa;
struct sockaddr addr, mask;
/*
* Don't print protocol-cloned routes unless -a.
@ -480,8 +496,16 @@ p_rtentry(rt)
if(rt->rt_parent && !aflag)
return;
p_sockaddr(kgetsa(rt_key(rt)), rt->rt_flags, WID_DST);
p_sockaddr(kgetsa(rt->rt_gateway), RTF_HOST, WID_GW);
if (!(sa = kgetsa(rt_key(rt))))
bzero(&addr, sizeof addr);
else
addr = *sa;
if (!rt_mask(rt) || !(sa = kgetsa(rt_mask(rt))))
bzero(&mask, sizeof mask);
else
mask = *sa;
p_sockaddr(&addr, &mask, rt->rt_flags, WID_DST);
p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST, WID_GW);
p_flags(rt->rt_flags, "%-6.6s ");
printf("%6d %8d ", rt->rt_refcnt, rt->rt_use);
if (rt->rt_ifp) {
@ -549,6 +573,51 @@ routename(in)
return (line);
}
static u_long
forgemask(a)
u_long a;
{
u_long m;
if (IN_CLASSA(a))
m = IN_CLASSA_NET;
else if (IN_CLASSB(a))
m = IN_CLASSB_NET;
else
m = IN_CLASSC_NET;
return (m);
}
static void
domask(dst, addr, mask)
char *dst;
u_long addr, mask;
{
register int b, i;
if (!mask || (forgemask(addr) == mask)) {
*dst = '\0';
return;
}
i = 0;
for (b = 0; b < 32; b++)
if (mask & (1 << b)) {
register int bb;
i = b;
for (bb = b+1; bb < 32; bb++)
if (!(mask & (1 << bb))) {
i = -1; /* noncontig */
break;
}
break;
}
if (i == -1)
sprintf(dst, "&0x%lx", mask);
else
sprintf(dst, "/%d", 32-i);
}
/*
* Return the name of the network whose address is given.
* The address is assumed to be that of a net or subnet, not a host.
@ -560,22 +629,26 @@ netname(in, mask)
char *cp = 0;
static char line[MAXHOSTNAMELEN + 1];
struct netent *np = 0;
u_long net;
register int i;
u_long net, omask;
register u_long i;
int subnetshift;
i = ntohl(in);
omask = mask;
if (!nflag && i) {
if (mask == 0) {
if (IN_CLASSA(i)) {
mask = IN_CLASSA_NET;
switch (mask = forgemask(i)) {
case IN_CLASSA_NET:
subnetshift = 8;
} else if (IN_CLASSB(i)) {
mask = IN_CLASSB_NET;
break;
case IN_CLASSB_NET:
subnetshift = 8;
} else {
mask = IN_CLASSC_NET;
break;
case IN_CLASSC_NET:
subnetshift = 4;
break;
default:
abort();
}
/*
* If there are more bits than the standard mask
@ -605,6 +678,7 @@ netname(in, mask)
else
sprintf(line, "%u.%u.%u.%u", C(i >> 24),
C(i >> 16), C(i >> 8), C(i));
domask(line+strlen(line), i, omask);
return (line);
}