- Add netatalk bits

- Add prototypes
- Fix printf formats
This commit is contained in:
christos 1997-04-03 02:35:46 +00:00
parent 8e9ba6bac6
commit d9349e61e1
9 changed files with 230 additions and 115 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.15 1997/02/22 03:49:31 thorpej Exp $ # $NetBSD: Makefile,v 1.16 1997/04/03 02:35:46 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/5/93 # @(#)Makefile 8.1 (Berkeley) 6/5/93
PROG= route PROG= route
@ -16,4 +16,5 @@ SRCS= route.c show.c keywords.c ccitt_addr.c
route.o .depend lint tags: keywords.h route.o .depend lint tags: keywords.h
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: ccitt_addr.c,v 1.8 1995/04/23 10:33:41 cgd Exp $ */ /* $NetBSD: ccitt_addr.c,v 1.9 1997/04/03 02:35:47 christos Exp $ */
/* /*
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
@ -52,12 +52,17 @@
* Copyright (c) 1984 * Copyright (c) 1984
*/ */
#include <string.h>
#include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netccitt/x25.h> #include <netccitt/x25.h>
static char *copychar (); #include "extern.h"
static char *copychar __P((char *, char *));
int
ccitt_addr (addr, xp) ccitt_addr (addr, xp)
char *addr; char *addr;
register struct sockaddr_x25 *xp; register struct sockaddr_x25 *xp;

46
sbin/route/extern.h Normal file
View File

@ -0,0 +1,46 @@
/* $NetBSD: extern.h,v 1.1 1997/04/03 02:35:48 christos Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christos Zoulas.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
struct sockaddr;
struct sockaddr_x25;
struct sockaddr_ns;
/* show.c */
void show __P((int, char **));
/* ccitt_addr.c */
int ccitt_addr __P((char *, struct sockaddr_x25 *));
/* route.c */
extern int nflag;
char *routename __P((struct sockaddr *));
char *netname __P((struct sockaddr *));
char *ns_print __P((struct sockaddr_ns *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: keywords.c,v 1.1 1996/11/15 18:01:38 gwr Exp $ */ /* $NetBSD: keywords.c,v 1.2 1997/04/03 02:35:48 christos Exp $ */
/* WARNING! This file was generated by keywords.sh */ /* WARNING! This file was generated by keywords.sh */
@ -7,6 +7,7 @@
struct keytab keywords[] = { struct keytab keywords[] = {
{"add", K_ADD}, {"add", K_ADD},
{"atalk", K_ATALK},
{"blackhole", K_BLACKHOLE}, {"blackhole", K_BLACKHOLE},
{"change", K_CHANGE}, {"change", K_CHANGE},
{"cloning", K_CLONING}, {"cloning", K_CLONING},

View File

@ -1,4 +1,4 @@
/* $NetBSD: keywords.h,v 1.3 1996/12/16 19:53:02 cgd Exp $ */ /* $NetBSD: keywords.h,v 1.4 1997/04/03 02:35:49 christos Exp $ */
/* WARNING! This file was generated by keywords.sh */ /* WARNING! This file was generated by keywords.sh */
@ -9,46 +9,47 @@ extern struct keytab {
#define K_ADD 1 #define K_ADD 1
#define K_BLACKHOLE 2 #define K_ATALK 2
#define K_CHANGE 3 #define K_BLACKHOLE 3
#define K_CLONING 4 #define K_CHANGE 4
#define K_DELETE 5 #define K_CLONING 5
#define K_DST 6 #define K_DELETE 6
#define K_EXPIRE 7 #define K_DST 7
#define K_FLUSH 8 #define K_EXPIRE 8
#define K_GATEWAY 9 #define K_FLUSH 9
#define K_GENMASK 10 #define K_GATEWAY 10
#define K_GET 11 #define K_GENMASK 11
#define K_HOST 12 #define K_GET 12
#define K_HOPCOUNT 13 #define K_HOST 13
#define K_IFACE 14 #define K_HOPCOUNT 14
#define K_INTERFACE 15 #define K_IFACE 15
#define K_IFA 16 #define K_INTERFACE 16
#define K_IFP 17 #define K_IFA 17
#define K_INET 18 #define K_IFP 18
#define K_ISO 19 #define K_INET 19
#define K_LINK 20 #define K_ISO 20
#define K_LLINFO 21 #define K_LINK 21
#define K_LOCK 22 #define K_LLINFO 22
#define K_LOCKREST 23 #define K_LOCK 23
#define K_MASK 24 #define K_LOCKREST 24
#define K_MONITOR 25 #define K_MASK 25
#define K_MTU 26 #define K_MONITOR 26
#define K_NET 27 #define K_MTU 27
#define K_NETMASK 28 #define K_NET 28
#define K_NOSTATIC 29 #define K_NETMASK 29
#define K_OSI 30 #define K_NOSTATIC 30
#define K_PROTO1 31 #define K_OSI 31
#define K_PROTO2 32 #define K_PROTO1 32
#define K_RECVPIPE 33 #define K_PROTO2 33
#define K_REJECT 34 #define K_RECVPIPE 34
#define K_RTT 35 #define K_REJECT 35
#define K_RTTVAR 36 #define K_RTT 36
#define K_SA 37 #define K_RTTVAR 37
#define K_SENDPIPE 38 #define K_SA 38
#define K_SHOW 39 #define K_SENDPIPE 39
#define K_SSTHRESH 40 #define K_SHOW 40
#define K_STATIC 41 #define K_SSTHRESH 41
#define K_X25 42 #define K_STATIC 42
#define K_XNS 43 #define K_X25 43
#define K_XRESOLVE 44 #define K_XNS 44
#define K_XRESOLVE 45

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $NetBSD: keywords.sh,v 1.3 1996/12/16 19:53:03 cgd Exp $ # $NetBSD: keywords.sh,v 1.4 1997/04/03 02:35:49 christos Exp $
# @(#)keywords 8.2 (Berkeley) 3/19/94 # @(#)keywords 8.2 (Berkeley) 3/19/94
# #
# WARNING! If you change this file, re-run it! # WARNING! If you change this file, re-run it!
@ -9,6 +9,7 @@ awk=${AWK:-awk}
cat << _EOF_ > _keywords.t1 cat << _EOF_ > _keywords.t1
add add
atalk
blackhole blackhole
change change
cloning cloning

View File

@ -1,4 +1,4 @@
.\" $NetBSD: route.8,v 1.8 1997/02/22 21:22:24 carrel Exp $ .\" $NetBSD: route.8,v 1.9 1997/04/03 02:35:50 christos Exp $
.\" .\"
.\" Copyright (c) 1983, 1991, 1993 .\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -122,6 +122,7 @@ will ``flush'' the routing tables of all gateway entries.
When the address family may is specified by any of the When the address family may is specified by any of the
.Fl osi , .Fl osi ,
.Fl xns , .Fl xns ,
.Fl atalk ,
or or
.Fl inet .Fl inet
modifiers, only routes having destinations with addresses in the modifiers, only routes having destinations with addresses in the
@ -185,11 +186,14 @@ indicating the interface to be used for transmission.
The optional modifiers The optional modifiers
.Fl xns , .Fl xns ,
.Fl osi , .Fl osi ,
.Fl atalk ,
and and
.Fl link .Fl link
specify that all subsequent addresses are in the specify that all subsequent addresses are in the
.Tn XNS .Tn XNS ,
.Tn OSI .Tn OSI ,
or
.Tn AppleTalk
address families, address families,
or are specified as link-level addresses, or are specified as link-level addresses,
and the names must be numeric specifications rather than and the names must be numeric specifications rather than

View File

@ -1,4 +1,4 @@
/* $NetBSD: route.c,v 1.18 1997/02/22 21:22:26 carrel Exp $ */ /* $NetBSD: route.c,v 1.19 1997/04/03 02:35:51 christos Exp $ */
/* /*
* Copyright (c) 1983, 1989, 1991, 1993 * Copyright (c) 1983, 1989, 1991, 1993
@ -43,7 +43,7 @@ static char copyright[] =
#if 0 #if 0
static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94"; static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94";
#else #else
static char rcsid[] = "$NetBSD: route.c,v 1.18 1997/02/22 21:22:26 carrel Exp $"; static char rcsid[] = "$NetBSD: route.c,v 1.19 1997/04/03 02:35:51 christos Exp $";
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -58,6 +58,7 @@ static char rcsid[] = "$NetBSD: route.c,v 1.18 1997/02/22 21:22:26 carrel Exp $"
#include <net/route.h> #include <net/route.h>
#include <net/if_dl.h> #include <net/if_dl.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netatalk/at.h>
#include <netns/ns.h> #include <netns/ns.h>
#include <netiso/iso.h> #include <netiso/iso.h>
#include <netccitt/x25.h> #include <netccitt/x25.h>
@ -73,35 +74,55 @@ static char rcsid[] = "$NetBSD: route.c,v 1.18 1997/02/22 21:22:26 carrel Exp $"
#include <paths.h> #include <paths.h>
#include "keywords.h" #include "keywords.h"
#include "extern.h"
typedef union sockunion *sup;
int main __P((int, char **));
static __dead void usage __P((char *));
static void quit __P((char *));
static char *any_ntoa __P((const struct sockaddr *));
static void set_metric __P((char *, int));
static void newroute __P((int, char **));
static void inet_makenetandmask __P((u_long, struct sockaddr_in *));
static int getaddr __P((int, char *, struct hostent **));
#ifndef SMALL
static void flushroutes __P((int, char *[]));
static int x25_makemask __P((void));
static void interfaces __P((void));
static void monitor __P((void));
static void print_getmsg __P((struct rt_msghdr *, int));
#endif
static int rtmsg __P((int, int ));
static void mask_addr __P((void));
static void print_rtmsg __P((struct rt_msghdr *, int));
static void pmsg_common __P((struct rt_msghdr *));
static void pmsg_addrs __P((char *, int));
static void bprintf __P((FILE *, int, u_char *));
static int keyword __P((char *));
static void sodump __P((sup, char *));
static void sockaddr __P((char *, struct sockaddr *));
struct ortentry route; struct ortentry route;
union sockunion { union sockunion {
struct sockaddr sa; struct sockaddr sa;
struct sockaddr_in sin; struct sockaddr_in sin;
struct sockaddr_at sat;
struct sockaddr_ns sns; struct sockaddr_ns sns;
struct sockaddr_iso siso; struct sockaddr_iso siso;
struct sockaddr_dl sdl; struct sockaddr_dl sdl;
struct sockaddr_x25 sx25; struct sockaddr_x25 sx25;
} so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp; } so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp;
typedef union sockunion *sup;
int pid, rtm_addrs; int pid, rtm_addrs;
int s; int s;
int forcehost, forcenet, doflush, nflag, af, qflag, tflag, keyword(); int forcehost, forcenet, doflush, nflag, af, qflag, tflag;
int iflag, verbose, aflen = sizeof (struct sockaddr_in); int iflag, verbose, aflen = sizeof (struct sockaddr_in);
int locking, lockrest, debugonly; int locking, lockrest, debugonly;
struct rt_metrics rt_metrics; struct rt_metrics rt_metrics;
u_long rtm_inits; u_long rtm_inits;
struct in_addr inet_makeaddr();
char *routename(), *netname();
void flushroutes(), newroute(), monitor(), sockaddr(), sodump();
void print_getmsg(), print_rtmsg(), pmsg_common(), pmsg_addrs();
void bprintf(), mask_addr();
int getaddr(), rtmsg(), x25_makemask();
extern char *inet_ntoa(), *iso_ntoa(), *link_ntoa();
extern void show();
__dead void static __dead void
usage(cp) usage(cp)
char *cp; char *cp;
{ {
@ -113,7 +134,7 @@ usage(cp)
/* NOTREACHED */ /* NOTREACHED */
} }
void static void
quit(s) quit(s)
char *s; char *s;
{ {
@ -214,7 +235,7 @@ main(argc, argv)
* Purge all entries in the routing tables not * Purge all entries in the routing tables not
* associated with network interfaces. * associated with network interfaces.
*/ */
void static void
flushroutes(argc, argv) flushroutes(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
@ -232,6 +253,9 @@ flushroutes(argc, argv)
case K_INET: case K_INET:
af = AF_INET; af = AF_INET;
break; break;
case K_ATALK:
af = AF_APPLETALK;
break;
case K_XNS: case K_XNS:
af = AF_NS; af = AF_NS;
break; break;
@ -311,7 +335,7 @@ bad: usage(*argv);
static char hexlist[] = "0123456789abcdef"; static char hexlist[] = "0123456789abcdef";
char * static char *
any_ntoa(sa) any_ntoa(sa)
const struct sockaddr *sa; const struct sockaddr *sa;
{ {
@ -343,7 +367,6 @@ routename(sa)
struct hostent *hp; struct hostent *hp;
static char domain[MAXHOSTNAMELEN + 1]; static char domain[MAXHOSTNAMELEN + 1];
static int first = 1; static int first = 1;
char *ns_print();
struct in_addr in; struct in_addr in;
if (first) { if (first) {
@ -392,6 +415,12 @@ routename(sa)
(void) sprintf(line, "iso %s", (void) sprintf(line, "iso %s",
iso_ntoa(&((struct sockaddr_iso *)sa)->siso_addr)); iso_ntoa(&((struct sockaddr_iso *)sa)->siso_addr));
break; break;
case AF_APPLETALK:
(void) snprintf(line, sizeof(line), "atalk %d.%d",
((struct sockaddr_at *)sa)->sat_addr.s_net,
((struct sockaddr_at *)sa)->sat_addr.s_node);
break;
#endif /* SMALL */ #endif /* SMALL */
default: default:
@ -417,7 +446,6 @@ netname(sa)
u_long net, mask; u_long net, mask;
register u_long i; register u_long i;
int subnetshift; int subnetshift;
char *ns_print();
struct in_addr in; struct in_addr in;
switch (sa->sa_family) { switch (sa->sa_family) {
@ -487,6 +515,12 @@ netname(sa)
(void) sprintf(line, "iso %s", (void) sprintf(line, "iso %s",
iso_ntoa(&((struct sockaddr_iso *)sa)->siso_addr)); iso_ntoa(&((struct sockaddr_iso *)sa)->siso_addr));
break; break;
case AF_APPLETALK:
(void) snprintf(line, sizeof(line), "atalk %d.%d",
((struct sockaddr_at *)sa)->sat_addr.s_net,
((struct sockaddr_at *)sa)->sat_addr.s_node);
break;
#endif /* SMALL */ #endif /* SMALL */
default: default:
@ -497,7 +531,7 @@ netname(sa)
return (line); return (line);
} }
void static void
set_metric(value, key) set_metric(value, key)
char *value; char *value;
int key; int key;
@ -524,7 +558,7 @@ set_metric(value, key)
*valp = atoi(value); *valp = atoi(value);
} }
void static void
newroute(argc, argv) newroute(argc, argv)
int argc; int argc;
register char **argv; register char **argv;
@ -546,6 +580,11 @@ newroute(argc, argv)
aflen = sizeof(union sockunion); aflen = sizeof(union sockunion);
break; break;
case K_ATALK:
af = AF_APPLETALK;
aflen = sizeof(struct sockaddr_at);
break;
case K_INET: case K_INET:
af = AF_INET; af = AF_INET;
aflen = sizeof(struct sockaddr_in); aflen = sizeof(struct sockaddr_in);
@ -741,7 +780,7 @@ newroute(argc, argv)
} }
} }
void static void
inet_makenetandmask(net, sin) inet_makenetandmask(net, sin)
u_long net; u_long net;
register struct sockaddr_in *sin; register struct sockaddr_in *sin;
@ -787,18 +826,17 @@ inet_makenetandmask(net, sin)
* Interpret an argument as a network address of some kind, * Interpret an argument as a network address of some kind,
* returning 1 if a host address, 0 if a network address. * returning 1 if a host address, 0 if a network address.
*/ */
int static int
getaddr(which, s, hpp) getaddr(which, s, hpp)
int which; int which;
char *s; char *s;
struct hostent **hpp; struct hostent **hpp;
{ {
register sup su; register sup su;
struct ns_addr ns_addr();
struct iso_addr *iso_addr();
struct hostent *hp; struct hostent *hp;
struct netent *np; struct netent *np;
u_long val; u_long val;
char *t;
if (af == 0) { if (af == 0) {
af = AF_INET; af = AF_INET;
@ -829,6 +867,7 @@ getaddr(which, s, hpp)
su->sa.sa_family = af; su->sa.sa_family = af;
break; break;
default: default:
su = NULL;
usage("Internal Error"); usage("Internal Error");
/*NOTREACHED*/ /*NOTREACHED*/
} }
@ -880,6 +919,24 @@ getaddr(which, s, hpp)
sockaddr(s, &su->sa); sockaddr(s, &su->sa);
return (1); return (1);
case AF_APPLETALK:
t = strchr (s, '.');
if (!t) {
badataddr:
(void)fprintf (stderr, "bad address: %s\n", s);
exit (1);
}
val = atoi (s);
if (val > 65535)
goto badataddr;
su->sat.sat_addr.s_net = val;
val = atoi (t);
if (val > 256)
goto badataddr;
su->sat.sat_addr.s_node = val;
rtm_addrs |= RTA_NETMASK;
return(forcehost || su->sat.sat_addr.s_node != 0);
case AF_LINK: case AF_LINK:
link_addr(s, &su->sdl); link_addr(s, &su->sdl);
return (1); return (1);
@ -979,11 +1036,12 @@ ns_print(sns)
else else
*cport = 0; *cport = 0;
(void) sprintf(mybuf,"%XH.%s%s", ntohl(net.long_e), host, cport); (void) sprintf(mybuf,"%XH.%s%s", (u_int32_t) ntohl(net.long_e),
host, cport);
return (mybuf); return (mybuf);
} }
void static void
interfaces() interfaces()
{ {
size_t needed; size_t needed;
@ -1010,7 +1068,7 @@ interfaces()
} }
} }
void static void
monitor() monitor()
{ {
int n; int n;
@ -1036,7 +1094,7 @@ struct {
char m_space[512]; char m_space[512];
} m_rtmsg; } m_rtmsg;
int static int
rtmsg(cmd, flags) rtmsg(cmd, flags)
int cmd, flags; int cmd, flags;
{ {
@ -1113,7 +1171,7 @@ rtmsg(cmd, flags)
return (0); return (0);
} }
void static void
mask_addr() mask_addr()
{ {
int olen = so_mask.sa.sa_len; int olen = so_mask.sa.sa_len;
@ -1130,6 +1188,7 @@ mask_addr()
case AF_NS: case AF_NS:
case AF_INET: case AF_INET:
case AF_CCITT: case AF_CCITT:
case AF_APPLETALK:
case 0: case 0:
return; return;
case AF_ISO: case AF_ISO:
@ -1179,7 +1238,7 @@ char ifnetflags[] =
char addrnames[] = char addrnames[] =
"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD"; "\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD";
void static void
print_rtmsg(rtm, msglen) print_rtmsg(rtm, msglen)
register struct rt_msghdr *rtm; register struct rt_msghdr *rtm;
int msglen; int msglen;
@ -1218,7 +1277,7 @@ print_rtmsg(rtm, msglen)
} }
#ifndef SMALL #ifndef SMALL
void static void
print_getmsg(rtm, msglen) print_getmsg(rtm, msglen)
register struct rt_msghdr *rtm; register struct rt_msghdr *rtm;
int msglen; int msglen;
@ -1229,7 +1288,8 @@ print_getmsg(rtm, msglen)
register char *cp; register char *cp;
register int i; register int i;
(void) printf(" route to: %s\n", routename(&so_dst)); (void) printf(" route to: %s\n",
routename((struct sockaddr *) &so_dst));
if (rtm->rtm_version != RTM_VERSION) { if (rtm->rtm_version != RTM_VERSION) {
(void)fprintf(stderr, (void)fprintf(stderr,
"routing message version %d not understood\n", "routing message version %d not understood\n",
@ -1293,16 +1353,16 @@ print_getmsg(rtm, msglen)
(void) printf("\n%s\n", "\ (void) printf("\n%s\n", "\
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire"); recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire");
printf("%8d%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE));
printf("%8d%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); printf("%8ld%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE));
printf("%8d%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH));
printf("%8d%c ", msec(rtm->rtm_rmx.rmx_rtt), lock(RTT)); printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rtt), lock(RTT));
printf("%8d%c ", msec(rtm->rtm_rmx.rmx_rttvar), lock(RTTVAR)); printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rttvar), lock(RTTVAR));
printf("%8d%c ", rtm->rtm_rmx.rmx_hopcount, lock(HOPCOUNT)); printf("%8ld%c ", rtm->rtm_rmx.rmx_hopcount, lock(HOPCOUNT));
printf("%8d%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU)); printf("%8ld%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU));
if (rtm->rtm_rmx.rmx_expire) if (rtm->rtm_rmx.rmx_expire)
rtm->rtm_rmx.rmx_expire -= time(0); rtm->rtm_rmx.rmx_expire -= time(0);
printf("%8d%c\n", rtm->rtm_rmx.rmx_expire, lock(EXPIRE)); printf("%8ld%c\n", rtm->rtm_rmx.rmx_expire, lock(EXPIRE));
#undef lock #undef lock
#undef msec #undef msec
#define RTA_IGN (RTA_DST|RTA_GATEWAY|RTA_NETMASK|RTA_IFP|RTA_IFA|RTA_BRD) #define RTA_IGN (RTA_DST|RTA_GATEWAY|RTA_NETMASK|RTA_IFP|RTA_IFA|RTA_BRD)
@ -1328,7 +1388,7 @@ pmsg_common(rtm)
pmsg_addrs(((char *)(rtm + 1)), rtm->rtm_addrs); pmsg_addrs(((char *)(rtm + 1)), rtm->rtm_addrs);
} }
void static void
pmsg_addrs(cp, addrs) pmsg_addrs(cp, addrs)
char *cp; char *cp;
int addrs; int addrs;
@ -1351,7 +1411,7 @@ pmsg_addrs(cp, addrs)
(void) fflush(stdout); (void) fflush(stdout);
} }
void static void
bprintf(fp, b, s) bprintf(fp, b, s)
register FILE *fp; register FILE *fp;
register int b; register int b;
@ -1362,7 +1422,7 @@ bprintf(fp, b, s)
if (b == 0) if (b == 0)
return; return;
while (i = *s++) { while ((i = *s++) != 0) {
if (b & (1 << (i-1))) { if (b & (1 << (i-1))) {
if (gotsome == 0) if (gotsome == 0)
i = '<'; i = '<';
@ -1380,7 +1440,7 @@ bprintf(fp, b, s)
(void) putc('>', fp); (void) putc('>', fp);
} }
int static int
keyword(cp) keyword(cp)
char *cp; char *cp;
{ {
@ -1391,7 +1451,7 @@ keyword(cp)
return kt->kt_i; return kt->kt_i;
} }
void static void
sodump(su, which) sodump(su, which)
register sup su; register sup su;
char *which; char *which;
@ -1401,6 +1461,10 @@ sodump(su, which)
(void) printf("%s: inet %s; ", (void) printf("%s: inet %s; ",
which, inet_ntoa(su->sin.sin_addr)); which, inet_ntoa(su->sin.sin_addr));
break; break;
case AF_APPLETALK:
(void) printf("%s: atalk %d.%d; ",
which, su->sat.sat_addr.s_net, su->sat.sat_addr.s_node);
break;
case AF_LINK: case AF_LINK:
(void) printf("%s: link %s; ", (void) printf("%s: link %s; ",
which, link_ntoa(&su->sdl)); which, link_ntoa(&su->sdl));
@ -1416,7 +1480,7 @@ sodump(su, which)
break; break;
#endif /* SMALL */ #endif /* SMALL */
default: default:
(void) printf("af %d: %s; ", (void) printf("af %p: %s; ",
which, any_ntoa(&su->sa)); which, any_ntoa(&su->sa));
} }
(void) fflush(stdout); (void) fflush(stdout);
@ -1431,7 +1495,7 @@ sodump(su, which)
#define END (4*1) #define END (4*1)
#define DELIM (4*2) #define DELIM (4*2)
void static void
sockaddr(addr, sa) sockaddr(addr, sa)
register char *addr; register char *addr;
register struct sockaddr *sa; register struct sockaddr *sa;
@ -1439,9 +1503,9 @@ sockaddr(addr, sa)
register char *cp = (char *)sa; register char *cp = (char *)sa;
int size = sa->sa_len; int size = sa->sa_len;
char *cplim = cp + size; char *cplim = cp + size;
register int byte = 0, state = VIRGIN, new; register int byte = 0, state = VIRGIN, new = 0;
memset(cp, 0, size); (void) memset(cp, 0, size);
cp++; cp++;
do { do {
if ((*addr >= '0') && (*addr <= '9')) { if ((*addr >= '0') && (*addr <= '9')) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* $NetBSD: show.c,v 1.2 1997/04/03 02:35:52 christos Exp $ */
/* /*
* Copyright (c) 1983, 1988, 1993 * Copyright (c) 1983, 1988, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94"; static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else #else
static char *rcsid = "$NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $"; static char *rcsid = "$NetBSD: show.c,v 1.2 1997/04/03 02:35:52 christos Exp $";
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -61,12 +61,7 @@ static char *rcsid = "$NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $";
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
/* XXX: things from route.c */ #include "extern.h"
extern char * routename __P((struct sockaddr *));
extern char * netname __P((struct sockaddr *));
extern char * ns_print __P((struct sockaddr_ns *));
extern int nflag;
/* /*
* Definitions for showing gateway flags. * Definitions for showing gateway flags.
@ -93,13 +88,11 @@ static const struct bits bits[] = {
{ 0 } { 0 }
}; };
static void p_rtentry __P((struct rt_msghdr *));
static void p_sockaddr __P((struct sockaddr *, int, int));
static void p_flags __P((int, char *));
static void pr_rthdr __P((void)); static void pr_rthdr __P((void));
static void p_rtentry __P((struct rt_msghdr *));
static void pr_family __P((int)); static void pr_family __P((int));
static void p_sockaddr __P((struct sockaddr *, int, int ));
static void p_flags __P((int, char *));
/* /*
* Print routing tables. * Print routing tables.
@ -113,7 +106,6 @@ show(argc, argv)
int mib[6]; int mib[6];
char *buf, *next, *lim; char *buf, *next, *lim;
register struct rt_msghdr *rtm; register struct rt_msghdr *rtm;
int i;
mib[0] = CTL_NET; mib[0] = CTL_NET;
mib[1] = PF_ROUTE; mib[1] = PF_ROUTE;