Update to 980910 from ftp.rhyolite.com

This commit is contained in:
christos 1998-10-25 14:56:06 +00:00
parent 99c0436391
commit 94b2d42842
15 changed files with 316 additions and 230 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.16 1998/06/02 18:02:55 thorpej Exp $ */
/* $NetBSD: defs.h,v 1.17 1998/10/25 14:56:06 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -51,7 +51,7 @@
* tell the kernel hop counts
* do not advertise if ipforwarding=0
*
* The vestigual support for other protocols has been removed. There
* The vestigial support for other protocols has been removed. There
* is no likelihood that IETF RIPv1 or RIPv2 will ever be used with
* other protocols. The result is far smaller, faster, cleaner, and
* perhaps understandable.
@ -73,6 +73,7 @@
#include <stdarg.h>
#include <syslog.h>
#include <time.h>
#include <sys/cdefs.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
@ -93,6 +94,7 @@
#define RIPVERSION RIPv2
#include <protocols/routed.h>
/* Type of an IP address.
* Some systems do not like to pass structures, so do not use in_addr.
* Some systems think a long has 64 bits, which would be a gross waste.
@ -100,7 +102,7 @@
* It should be defined somewhere netinet/in.h, but it is not.
*/
#ifdef sgi
#define naddr __uint32_t
#define naddr u_int32_t
#elif defined (__NetBSD__)
#define naddr u_int32_t
#define _HAVE_SA_LEN
@ -114,7 +116,7 @@
/* Turn on if IP_DROP_MEMBERSHIP and IP_ADD_MEMBERSHIP do not look at
* the dstaddr of point-to-point interfaces.
*/
#if defined(__NetBSD__)
#ifdef __NetBSD__
#define MCAST_PPP_BUG
#endif
@ -295,7 +297,7 @@ struct interface {
} int_data;
# define MAX_AUTH_KEYS 5
struct auth { /* authentication info */
u_char type;
u_int16_t type;
u_char key[RIP_AUTH_PW_LEN];
u_char keyid;
time_t start, end;
@ -363,7 +365,7 @@ struct ag_info {
u_int ag_seqno;
u_short ag_tag;
u_short ag_state;
#define AGS_SUPPRESS 0x001 /* combine with coaser mask */
#define AGS_SUPPRESS 0x001 /* combine with coarser mask */
#define AGS_AGGREGATE 0x002 /* synthesize combined routes */
#define AGS_REDUN0 0x004 /* redundant, finer routes output */
#define AGS_REDUN1 0x008
@ -375,7 +377,7 @@ struct ag_info {
#define AGS_FINE_GATE 0x080 /* ignore differing ag_gate when this
* has the finer netmask */
#define AGS_CORS_GATE 0x100 /* ignore differing gate when this
* has the coarser netmaks */
* has the coarser netmask */
#define AGS_SPLIT_HZ 0x200 /* suppress for split horizon */
/* some bits are set if they are set on either route */
@ -394,7 +396,7 @@ extern struct parm {
char parm_d_metric;
u_int parm_int_state;
int parm_rdisc_pref; /* signed IRDP preference */
int parm_rdisc_int; /* IRDP advertising internval */
int parm_rdisc_int; /* IRDP advertising interval */
struct auth parm_auth[MAX_AUTH_KEYS];
} *parms;
@ -455,7 +457,7 @@ extern int supplier_set; /* -s or -q requested */
extern int lookforinterfaces; /* 1=probe for new up interfaces */
extern int ridhosts; /* 1=reduce host routes */
extern int mhome; /* 1=want multi-homed host route */
extern int advertise_mhome; /* 1=must continue adverising it */
extern int advertise_mhome; /* 1=must continue advertising it */
extern int auth_ok; /* 1=ignore auth if we do not care */
extern struct timeval clk; /* system clock's idea of time */
@ -469,7 +471,7 @@ extern struct timeval next_bcast; /* next general broadcast */
extern struct timeval age_timer; /* next check of old routes */
extern struct timeval no_flash; /* inhibit flash update until then */
extern struct timeval rdisc_timer; /* next advert. or solicitation */
extern int rdisc_ok; /* using solicted route */
extern int rdisc_ok; /* using solicited route */
extern struct timeval ifinit_timer; /* time to check interfaces */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if.c,v 1.15 1998/08/26 17:50:33 christos Exp $ */
/* $NetBSD: if.c,v 1.16 1998/10/25 14:56:07 christos Exp $ */
/*
* Copyright (c) 1983, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -37,7 +37,7 @@
static char sccsid[] = "@(#)if.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: if.c,v 1.15 1998/08/26 17:50:33 christos Exp $");
__RCSID("$NetBSD: if.c,v 1.16 1998/10/25 14:56:07 christos Exp $");
#endif
#include "defs.h"
@ -338,7 +338,7 @@ ripv1_mask_net(naddr addr, /* in network byte order */
for (r1p = r1nets; r1p != 0; r1p = r1p->r1net_next) {
if (on_net(addr, r1p->r1net_net, r1p->r1net_match)
&& r1p->r1net_mask > mask)
r1p->r1net_mask = mask;
mask = r1p->r1net_mask;
}
/* Otherwise, make the classic A/B/C guess.
@ -701,7 +701,7 @@ ifinit(void)
? CHECK_ACT_INTERVAL
: CHECK_QUIET_INTERVAL);
/* mark all interfaces so we can get rid of thost that disappear */
/* mark all interfaces so we can get rid of those that disappear */
for (ifp = ifnet; 0 != ifp; ifp = ifp->int_next)
ifp->int_state &= ~(IS_CHECKED | IS_DUP);
@ -776,7 +776,7 @@ ifinit(void)
* will be an alias.
* Do not output RIP or Router-Discovery packets via aliases.
*/
memmove(&ifs, &ifs0, sizeof(ifs));
memcpy(&ifs, &ifs0, sizeof(ifs));
ifs0.int_state |= (IS_ALIAS | IS_NO_RIP_OUT | IS_NO_RDISC);
if (INFO_IFA(&info) == 0) {
@ -1011,7 +1011,7 @@ ifinit(void)
}
ifp->int_data = ifs.int_data;
/* Withhold judgement when the short error
/* Withhold judgment when the short error
* counters wrap or the interface is reset.
*/
if (ierr < 0 || in < 0 || oerr < 0 || out < 0) {
@ -1111,7 +1111,7 @@ ifinit(void)
/* It is new and ok. Add it to the list of interfaces
*/
ifp = (struct interface *)rtmalloc(sizeof(*ifp), "ifinit ifp");
memmove(ifp, &ifs, sizeof(*ifp));
memcpy(ifp, &ifs, sizeof(*ifp));
get_parms(ifp);
if_link(ifp);
trace_if("Add", ifp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: input.c,v 1.23 1998/10/24 18:30:23 christos Exp $ */
/* $NetBSD: input.c,v 1.24 1998/10/25 14:56:07 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -37,7 +37,7 @@
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: input.c,v 1.23 1998/10/24 18:30:23 christos Exp $");
__RCSID("$NetBSD: input.c,v 1.24 1998/10/25 14:56:07 christos Exp $");
#endif
#include "defs.h"
@ -185,7 +185,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
*
* RIPv2 authentication is lame. Why authenticate queries?
* Why should a RIPv2 implementation with authentication disabled
* not be able to listen to RIPv2 packets with authenication, while
* not be able to listen to RIPv2 packets with authentication, while
* RIPv1 systems will listen? Crazy!
*/
if (!auth_ok
@ -235,7 +235,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
}
}
/* According to RFC 1723, we should ignore unathenticated
/* According to RFC 1723, we should ignore unauthenticated
* queries. That is too silly to bother with. Sheesh!
* Are forwarding tables supposed to be secret, when
* a bad guy can infer them with test traffic? When RIP
@ -620,7 +620,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
*/
gate = FROM_NADDR;
if (n->n_nhop != 0) {
if (rip->rip_vers == RIPv2) {
if (rip->rip_vers == RIPv1) {
n->n_nhop = 0;
} else {
/* Use it only if it is valid. */
@ -924,7 +924,7 @@ ck_passwd(struct interface *aifp,
struct auth *ap;
MD5_CTX md5_ctx;
u_char hash[RIP_AUTH_PW_LEN];
int i;
int i, len;
if ((void *)NA >= lim || NA->a_family != RIP_AF_AUTH) {
@ -942,7 +942,7 @@ ck_passwd(struct interface *aifp,
continue;
if (NA->a_type == RIP_AUTH_PW) {
if (!memcmp(ap->key, NA->au.au_pw, RIP_AUTH_PW_LEN))
if (!memcmp(NA->au.au_pw, ap->key, RIP_AUTH_PW_LEN))
return 1;
} else {
@ -951,28 +951,52 @@ ck_passwd(struct interface *aifp,
if (NA->au.a_md5.md5_keyid != ap->keyid)
continue;
na2 = (struct netauth *)((char *)(NA+1)
+ NA->au.a_md5.md5_pkt_len);
if (NA->au.a_md5.md5_pkt_len % sizeof(*NA) != 0
|| lim < (void *)(na2+1)) {
len = ntohs(NA->au.a_md5.md5_pkt_len);
if ((len-sizeof(*rip)) % sizeof(*NA) != 0
|| len != (char *)lim-(char*)rip-sizeof(*NA)) {
msglim(use_authp, from,
"bad MD5 RIP-II pkt length %d from %s",
NA->au.a_md5.md5_pkt_len,
"wrong MD5 RIPv2 packet length of %d"
" instead of %d from %s",
len, (int)((char *)lim-(char *)rip
-sizeof(*NA)),
naddr_ntoa(from));
return 0;
}
na2 = (struct netauth *)((char *)rip+len);
/* Given a good hash value, these are not security
* problems so be generous and accept the routes,
* after complaining.
*/
if (TRACEPACKETS) {
if (NA->au.a_md5.md5_auth_len
!= RIP_AUTH_MD5_LEN)
msglim(use_authp, from,
"unknown MD5 RIPv2 auth len %#x"
" instead of %#x from %s",
NA->au.a_md5.md5_auth_len,
RIP_AUTH_MD5_LEN,
naddr_ntoa(from));
if (na2->a_family != RIP_AF_AUTH)
msglim(use_authp, from,
"unknown MD5 RIPv2 family %#x"
" instead of %#x from %s",
na2->a_family, RIP_AF_AUTH,
naddr_ntoa(from));
if (na2->a_type != ntohs(1))
msglim(use_authp, from,
"MD5 RIPv2 hash has %#x"
" instead of %#x from %s",
na2->a_type, ntohs(1),
naddr_ntoa(from));
}
MD5Init(&md5_ctx);
MD5Update(&md5_ctx, (u_char *)NA,
(char *)na2->au.au_pw - (char *)NA);
MD5Update(&md5_ctx,
(u_char *)ap->key, sizeof(ap->key));
MD5Update(&md5_ctx, (u_char *)rip, len);
MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_LEN);
MD5Final(hash, &md5_ctx);
if (na2->a_family != RIP_AF_AUTH
|| na2->a_type != 1
|| NA->au.a_md5.md5_auth_len != RIP_AUTH_PW_LEN
|| memcmp(hash, na2->au.au_pw, sizeof(hash)))
return 0;
return 1;
if (!memcmp(hash, na2->au.au_pw, sizeof(hash)))
return 1;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.19 1998/07/06 06:50:28 mrg Exp $ */
/* $NetBSD: main.c,v 1.20 1998/10/25 14:56:07 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -40,7 +40,7 @@ char copyright[] =
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: main.c,v 1.19 1998/07/06 06:50:28 mrg Exp $");
__RCSID("$NetBSD: main.c,v 1.20 1998/10/25 14:56:07 christos Exp $");
#endif
#include "defs.h"
@ -73,7 +73,7 @@ int default_gateway; /* 1=advertise default */
int background = 1;
int ridhosts; /* 1=reduce host routes */
int mhome; /* 1=want multi-homed host route */
int advertise_mhome; /* 1=must continue adverising it */
int advertise_mhome; /* 1=must continue advertising it */
int auth_ok = 1; /* 1=ignore auth if we do not care */
struct timeval epoch; /* when started */
@ -223,7 +223,7 @@ main(int argc,
case 'v':
/* display version */
verbose++;
msglog("version 2.10");
msglog("version 2.15");
break;
default:
@ -422,7 +422,7 @@ usage:
/* It is desirable to send routing updates
* regularly. So schedule the next update
* 30 seconds after the previous one was
* secheduled, instead of 30 seconds after
* scheduled, instead of 30 seconds after
* the previous update was finished.
* Even if we just started after discovering
* a 2nd interface or were otherwise delayed,
@ -809,7 +809,7 @@ timevaladd(struct timeval *t1,
{
t1->tv_sec += t2->tv_sec;
if ((t1->tv_usec += t2->tv_usec) > 1000000) {
if ((t1->tv_usec += t2->tv_usec) >= 1000000) {
t1->tv_sec++;
t1->tv_usec -= 1000000;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: output.c,v 1.15 1998/06/02 18:02:55 thorpej Exp $ */
/* $NetBSD: output.c,v 1.16 1998/10/25 14:56:08 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -37,7 +37,7 @@
static char sccsid[] = "@(#)output.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: output.c,v 1.15 1998/06/02 18:02:55 thorpej Exp $");
__RCSID("$NetBSD: output.c,v 1.16 1998/10/25 14:56:08 christos Exp $");
#endif
#include "defs.h"
@ -153,7 +153,7 @@ output(enum output_type type,
msg = "Send mcast";
if (rip_sock_mcast != ifp) {
#ifdef MCAST_PPP_BUG
/* Do not specifiy the primary interface
/* Do not specify the primary interface
* explicitly if we have the multicast
* point-to-point kernel bug, since the
* kernel will do the wrong thing if the
@ -213,7 +213,7 @@ output(enum output_type type,
/* Find the first key for a packet to send.
* Try for a key that is eligable and has not expired, but settle for
* Try for a key that is eligible and has not expired, but settle for
* the last key if they have all expired.
* If no key is ready yet, give up.
*/
@ -263,23 +263,24 @@ clr_ws_buf(struct ws_buf *wb,
wb->n = wb->base;
memset(wb->n, 0, NETS_LEN*sizeof(*wb->n));
/* install authentication if appropriate
/* (start to) install authentication if appropriate
*/
if (ap == 0)
return;
na = (struct netauth*)wb->n;
if (ap->type == RIP_AUTH_PW) {
na->a_family = RIP_AF_AUTH;
na->a_type = RIP_AUTH_PW;
memmove(na->au.au_pw, ap->key, sizeof(na->au.au_pw));
memcpy(na->au.au_pw, ap->key, sizeof(na->au.au_pw));
wb->n++;
} else if (ap->type == RIP_AUTH_MD5) {
na->a_family = RIP_AF_AUTH;
na->a_type = RIP_AUTH_MD5;
na->au.a_md5.md5_keyid = ap->keyid;
na->au.a_md5.md5_auth_len = RIP_AUTH_PW_LEN;
na->au.a_md5.md5_seqno = clk.tv_sec;
na->au.a_md5.md5_auth_len = RIP_AUTH_MD5_LEN;
na->au.a_md5.md5_seqno = htonl(clk.tv_sec);
wb->n++;
wb->lim--; /* make room for trailer */
}
@ -292,17 +293,18 @@ end_md5_auth(struct ws_buf *wb,
{
struct netauth *na, *na2;
MD5_CTX md5_ctx;
int len;
na = (struct netauth*)wb->base;
na2 = (struct netauth*)wb->n;
len = (char *)na2-(char *)wb->buf;
na2->a_family = RIP_AF_AUTH;
na2->a_type = 1;
memmove(na2->au.au_pw, ap->key, sizeof(na2->au.au_pw));
na->au.a_md5.md5_pkt_len = (char *)na2-(char *)(na+1);
na2->a_type = htons(1);
na->au.a_md5.md5_pkt_len = htons(len);
MD5Init(&md5_ctx);
MD5Update(&md5_ctx, (u_char *)na,
(char *)(na2+1) - (char *)na);
MD5Update(&md5_ctx, (u_char *)wb->buf, len);
MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_LEN);
MD5Final(na2->au.au_pw, &md5_ctx);
wb->n++;
}
@ -314,7 +316,7 @@ static void
supply_write(struct ws_buf *wb)
{
/* Output multicast only if legal.
* If we would multcast and it would be illegal, then discard the
* If we would multicast and it would be illegal, then discard the
* packet.
*/
switch (wb->type) {
@ -446,7 +448,8 @@ supply_out(struct ag_info *ag)
*/
/* ARGSUSED */
static int
walk_supply(struct radix_node *rn, struct walkarg *argp)
walk_supply(struct radix_node *rn,
struct walkarg *argp)
{
#define RT ((struct rt_entry *)rn)
u_short ags;
@ -588,7 +591,7 @@ walk_supply(struct radix_node *rn, struct walkarg *argp)
* should knows them as well as we do.
*
* Notice spare routes with the same metric that we are about to
* advertise, to split the horizon on redunant, inactive paths.
* advertise, to split the horizon on redundant, inactive paths.
*/
if (ws.ifp != 0
&& !(ws.state & WS_ST_QUERY)

View File

@ -1,4 +1,4 @@
/* $NetBSD: parms.c,v 1.11 1998/06/02 18:02:55 thorpej Exp $ */
/* $NetBSD: parms.c,v 1.12 1998/10/25 14:56:08 christos Exp $ */
/*
* Copyright (c) 1983, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -37,7 +37,7 @@
static char sccsid[] = "@(#)if.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: parms.c,v 1.11 1998/06/02 18:02:55 thorpej Exp $");
__RCSID("$NetBSD: parms.c,v 1.12 1998/10/25 14:56:08 christos Exp $");
#endif
#include "defs.h"
@ -77,7 +77,7 @@ get_parms(struct interface *ifp)
if (parmp->parm_auth[0].type == RIP_AUTH_NONE
|| num_passwds >= MAX_AUTH_KEYS)
break;
memmove(&ifp->int_auth[num_passwds++],
memcpy(&ifp->int_auth[num_passwds++],
&parmp->parm_auth[i],
sizeof(ifp->int_auth[0]));
}
@ -371,8 +371,7 @@ parse_quote(char **linep, /* look here */
char *buf, /* copy token to here */
int lim) /* at most this many bytes */
{
char c = '\0';
char *pc, *p;
char c = '\0', *pc, *p;
pc = *linep;
@ -384,7 +383,7 @@ parse_quote(char **linep, /* look here */
if (c == '\0')
break;
if (c == '\\' && pc != '\0') {
if (c == '\\' && *pc != '\0') {
if ((c = *pc++) == 'n') {
c = '\n';
} else if (c == 'r') {
@ -435,7 +434,9 @@ parse_ts(time_t *tp,
u_int bufsize)
{
struct tm tm;
#if defined(sgi) || defined(__NetBSD__)
char *ptr;
#endif
if (0 > parse_quote(valp, "| ,\n\r", delimp,
buf,bufsize)
@ -446,12 +447,25 @@ parse_ts(time_t *tp,
}
strcat(buf,"\n");
memset(&tm, 0, sizeof(tm));
#if defined(sgi) || defined(__NetBSD__)
ptr = strptime(buf, "%y/%m/%d@%H:%M\n", &tm);
if (ptr == NULL || *ptr != '\0') {
sprintf(buf,"bad timestamp %.25s", val0);
return buf;
}
#else
if (5 != sscanf(buf, "%u/%u/%u@%u:%u\n",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min)
|| tm.tm_mon < 1 || tm.tm_mon > 12
|| tm.tm_mday < 1 || tm.tm_mday > 31) {
sprintf(buf,"bad timestamp %.25s", val0);
return buf;
}
tm.tm_mon--;
if (tm.tm_year <= 37) /* assume small years are in the */
tm.tm_year += 100; /* 3rd millenium */
#endif
if ((*tp = mktime(&tm)) == -1) {
sprintf(buf,"bad timestamp %.25s", val0);
@ -469,7 +483,7 @@ static char * /* 0 or error message */
get_passwd(char *tgt,
char *val,
struct parm *parmp,
u_char type,
u_int16_t type,
int safe) /* 1=from secure file */
{
static char buf[80];
@ -569,11 +583,10 @@ parse_parms(char *line,
struct r1net *r1netp;
struct tgate *tg;
naddr addr, mask;
char delim, *val0, *tgt, *val, *p;
char delim, *val0 = 0, *tgt, *val, *p;
char buf[BUFSIZ], buf2[BUFSIZ];
int i;
val0 = NULL; /* XXX gcc -Wuninitialized */
/* "subnet=x.y.z.u/mask[,metric]" must be alone on the line */
if (!strncasecmp(line, "subnet=", sizeof("subnet=")-1)
@ -602,7 +615,10 @@ parse_parms(char *line,
return 0;
}
/* "ripv1_mask=x.y.z.u/mask,mask" must be alone on the line */
/* "ripv1_mask=x.y.z.u/mask1,mask2" must be alone on the line.
* This requires that x.y.z.u/mask1 be considered a subnet of
* x.y.z.u/mask2, as if x.y.z.u/mask2 were a class-full network.
*/
if (!strncasecmp(line, "ripv1_mask=", sizeof("ripv1_mask=")-1)
&& *(val = &line[sizeof("ripv1_mask=")-1]) != '\0') {
if (0 > parse_quote(&val, ",", &delim, buf, sizeof(buf))
@ -616,7 +632,7 @@ parse_parms(char *line,
r1netp->r1net_mask = HOST_MASK << (32-i);
if (!getnet(buf, &r1netp->r1net_net, &r1netp->r1net_match)
|| r1netp->r1net_net == RIP_DEFAULT
|| r1netp->r1net_mask < r1netp->r1net_match) {
|| r1netp->r1net_mask > r1netp->r1net_match) {
free(r1netp);
return bad_str(line);
}
@ -778,7 +794,7 @@ parse_parms(char *line,
tg = (struct tgate *)rtmalloc(sizeof(*tg),
"parse_parms"
"trust_gateway");
bzero(tg, sizeof(*tg));
memset(tg, 0, sizeof(*tg));
tg->tgate_addr = addr;
i = 0;
/* The default is to trust all routes. */
@ -882,7 +898,7 @@ check_parms(struct parm *new)
* they affect the result in the order the operator specified.
*/
parmp = (struct parm*)rtmalloc(sizeof(*parmp), "check_parms");
memmove(parmp, new, sizeof(*parmp));
memcpy(parmp, new, sizeof(*parmp));
*parmpp = parmp;
return 0;
@ -994,7 +1010,7 @@ gethost(char *name,
hp = gethostbyname(name);
if (hp) {
memmove(addrp, hp->h_addr, sizeof(*addrp));
memcpy(addrp, hp->h_addr, sizeof(*addrp));
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pathnames.h,v 1.8 1996/09/24 16:24:18 christos Exp $ */
/* $NetBSD: pathnames.h,v 1.9 1998/10/25 14:56:08 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -34,7 +34,7 @@
*
* @(#)pathnames.h 8.1 (Berkeley) 6/5/93
*
* $NetBSD: pathnames.h,v 1.8 1996/09/24 16:24:18 christos Exp $
* $NetBSD: pathnames.h,v 1.9 1998/10/25 14:56:08 christos Exp $
*/
#include <paths.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: radix.c,v 1.6 1997/09/16 07:29:56 lukem Exp $ */
/* $NetBSD: radix.c,v 1.7 1998/10/25 14:56:08 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -42,7 +42,7 @@
static char sccsid[] = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: radix.c,v 1.6 1997/09/16 07:29:56 lukem Exp $");
__RCSID("$NetBSD: radix.c,v 1.7 1998/10/25 14:56:08 christos Exp $");
#endif
#include "defs.h"
@ -63,7 +63,7 @@ static char *rn_zeros, *rn_ones;
#define Bcmp(a, b, l) (l == 0 ? 0 \
: memcmp((caddr_t)(a), (caddr_t)(b), (size_t)l))
static int rn_satsifies_leaf(char *, struct radix_node *, int);
static int rn_satisfies_leaf(char *, struct radix_node *, int);
/*
* The data structure for the keys is a radix tree with one way
@ -179,7 +179,7 @@ rn_lookup(void *v_arg, void *m_arg, struct radix_node_head *head)
}
static int
rn_satsifies_leaf(char *trial,
rn_satisfies_leaf(char *trial,
struct radix_node *leaf,
int skip)
{
@ -272,7 +272,7 @@ on2:
*/
if ((saved_t = t)->rn_mask == 0)
t = t->rn_dupedkey;
for (; t; t = t->rn_dupedkey)
for (; t; t = t->rn_dupedkey) {
/*
* Even if we don't match exactly as a host,
* we may match if the leaf we wound up at is
@ -281,8 +281,10 @@ on2:
if (t->rn_flags & RNF_NORMAL) {
if (rn_b <= t->rn_b)
return t;
} else if (rn_satsifies_leaf(v, t, matched_off))
} else if (rn_satisfies_leaf(v, t, matched_off)) {
return t;
}
}
t = saved_t;
/* start searching up the tree */
do {
@ -304,7 +306,7 @@ on2:
x = rn_search_m(v, t, m->rm_mask);
while (x && x->rn_mask != m->rm_mask)
x = x->rn_dupedkey;
if (x && rn_satsifies_leaf(v, x, off))
if (x && rn_satisfies_leaf(v, x, off))
return x;
}
} while ((m = m->rm_mklist));
@ -443,9 +445,9 @@ rn_addmask(void *n_arg, int search, int skip)
x = 0;
if (x || search)
return (x);
R_Malloc(x, struct radix_node *, max_keylen + 2 * sizeof (*x));
if ((saved_x = x) == 0)
return (0);
x = (struct radix_node *)rtmalloc(max_keylen + 2*sizeof(*x),
"rn_addmask");
saved_x = x;
Bzero(x, max_keylen + 2 * sizeof (*x));
netmask = cp = (caddr_t)(x + 2);
Bcopy(addmask_key, cp, mlen);
@ -851,9 +853,7 @@ rn_inithead(void **head, int off)
struct radix_node *t, *tt, *ttt;
if (*head)
return (1);
R_Malloc(rnh, struct radix_node_head *, sizeof (*rnh));
if (rnh == 0)
return (0);
rnh = (struct radix_node_head *)rtmalloc(sizeof(*rnh), "rn_inithead");
Bzero(rnh, sizeof (*rnh));
*head = rnh;
t = rn_newpair(rn_zeros, off, rnh->rnh_nodes);
@ -882,9 +882,7 @@ rn_init(void)
printf("rn_init: radix functions require max_keylen be set\n");
return;
}
R_Malloc(rn_zeros, char *, 3 * max_keylen);
if (rn_zeros == NULL)
panic("rn_init");
rn_zeros = (char *)rtmalloc(3 * max_keylen, "rn_init");
Bzero(rn_zeros, 3 * max_keylen);
rn_ones = cp = rn_zeros + max_keylen;
addmask_key = cplim = rn_ones + max_keylen;

View File

@ -1,4 +1,4 @@
/* $NetBSD: radix.h,v 1.4 1997/09/15 10:38:18 lukem Exp $ */
/* $NetBSD: radix.h,v 1.5 1998/10/25 14:56:08 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -104,7 +104,7 @@ extern struct radix_mask {
m = rn_mkfreelist; \
rn_mkfreelist = (m)->rm_mklist; \
} else \
R_Malloc(m, struct radix_mask *, sizeof (*(m))); }\
m = (struct radix_mask *)rtmalloc(sizeof(*(m)), "MKGet"); }\
#define MKFree(m) { (m)->rm_mklist = rn_mkfreelist; rn_mkfreelist = (m);}
@ -139,7 +139,6 @@ struct radix_node_head {
#define Bcmp(a, b, n) memcmp(((void *)(a)), ((void *)(b)), (n))
#define Bcopy(a, b, n) memmove(((void *)(b)), ((void *)(a)), (size_t)(n))
#define Bzero(p, n) memset((void *)(p), 0, (size_t)(n));
#define R_Malloc(p, t, n) (p = (t) malloc((size_t)(n)))
#define Free(p) free((void *)p);
void rn_init __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: rdisc.c,v 1.7 1998/06/02 18:02:56 thorpej Exp $ */
/* $NetBSD: rdisc.c,v 1.8 1998/10/25 14:56:08 christos Exp $ */
/*
* Copyright (c) 1995
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -37,7 +37,7 @@
static char sccsid[] = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: rdisc.c,v 1.7 1998/06/02 18:02:56 thorpej Exp $");
__RCSID("$NetBSD: rdisc.c,v 1.8 1998/10/25 14:56:08 christos Exp $");
#endif
#include "defs.h"
@ -83,7 +83,7 @@ int rdisc_sock = -1; /* router-discovery raw socket */
struct interface *rdisc_sock_mcast; /* current multicast interface */
struct timeval rdisc_timer;
int rdisc_ok; /* using solicted route */
int rdisc_ok; /* using solicited route */
#define MAX_ADS 16 /* at least one per interface */
@ -264,7 +264,7 @@ set_supplier(void)
if (supplier_set)
return;
trace_act("start suppying routes");
trace_act("start supplying routes");
/* Forget discovered routes.
*/
@ -306,7 +306,7 @@ rdisc_age(naddr bad_gate)
struct dr *drp;
/* If only adverising, then do only that. */
/* If only advertising, then do only that. */
if (supplier) {
/* If switching from client to server, get rid of old
* default routes.
@ -319,7 +319,7 @@ rdisc_age(naddr bad_gate)
/* If we are being told about a bad router,
* then age the discovered default route, and if there is
* no alternative, solicite a replacement.
* no alternative, solicit a replacement.
*/
if (bad_gate != 0) {
/* Look for the bad discovered default route.
@ -457,15 +457,13 @@ rdisc_sort(void)
struct rt_entry *rt;
struct rt_spare new;
struct interface *ifp;
u_int new_st;
n_long new_pref;
u_int new_st = 0;
n_long new_pref = 0;
/* Find the best discovered route.
*/
new_drp = 0;
new_st = 0;
new_pref = 0;
for (drp = drs; drp < &drs[MAX_ADS]; drp++) {
if (drp->dr_ts == 0)
continue;
@ -543,7 +541,7 @@ rdisc_sort(void)
new_drp->dr_ifp->int_name);
}
bzero(&new, sizeof(new));
memset(&new, 0, sizeof(new));
new.rts_ifp = new_drp->dr_ifp;
new.rts_gate = new_drp->dr_gate;
new.rts_router = new_drp->dr_gate;
@ -637,7 +635,7 @@ parse_ad(naddr from,
new_drp = drp;
} else if (new_drp->dr_ts != 0) {
/* look for the least valueable entry to reuse
/* look for the least valuable entry to reuse
*/
if ((!(new_drp->dr_ifp->int_state & IS_SICK)
&& (drp->dr_ifp->int_state & IS_SICK))
@ -741,7 +739,7 @@ send_rdisc(union ad_u *p,
if (rdisc_sock_mcast != ifp) {
/* select the right interface. */
#ifdef MCAST_PPP_BUG
/* Do not specifiy the primary interface explicitly
/* Do not specify the primary interface explicitly
* if we have the multicast point-to-point kernel
* bug, since the kernel will do the wrong thing
* if the local address of a point-to-point link

View File

@ -1,4 +1,4 @@
.\" $NetBSD: routed.8,v 1.21 1998/10/21 13:58:32 lukem Exp $
.\" $NetBSD: routed.8,v 1.22 1998/10/25 14:56:08 christos Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -12,7 +12,7 @@
.\" 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:
.\" must display the following acknowledgment:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
@ -165,7 +165,7 @@ of ICMP Redirect messages are deleted after a while to minimize
.Em black-holes .
When a TCP connection suffers a timeout,
the kernel tells
.Nm "" ,
.Nm Ns ,
which deletes all redirected routes
through the gateway involved, advances the age of all RIP routes through
the gateway to allow an alternate to be chosen, and advances of the
@ -217,6 +217,16 @@ in the
.Pa /etc/gateways
file.
.Pp
While using Router Discovery (which happens by default when
the system has a single network interface and a Router Discover Advertisement
is received), there is a single default route and a variable number of
redirected host routes in the kernel table.
On a host with more than one network interface,
this default route will be via only one of the interfaces.
Thus, multi-homed hosts running with \f3\-q\f1 might need
.Cm no_rdisc
described below.
.Pp
See the
.Cm pm_rdisc
facility described below to support "legacy" systems
@ -229,11 +239,10 @@ or PPP, with the IFF_POINTOPOINT flag) is used by
.Nm
to infer the netmask used by the remote system when RIPv1 is used.
.Pp
Options supported by
.Nm "" :
.Bl -tag -width Ds
The following options are available:
.Bl -tag -width indent
.It Fl s
this option forces
force
.Nm
to supply routing information.
This is the default if multiple network interfaces are present on which
@ -245,10 +254,10 @@ is the opposite of the
option.
This is the default when only one interface is present.
.It Fl d
Do not run in the background.
do not run in the background.
This option is meant for interactive use.
.It Fl g
This flag is used on internetwork routers to offer a route
used on internetwork routers to offer a route
to the "default" destination.
It is equivalent to
.Fl F
@ -257,7 +266,8 @@ and is present mostly for historical reasons.
A better choice is
.Fl P Cm pm_rdisc
on the command line or
.Cm pm_rdisc in the
.Cm pm_rdisc
in the
.Pa /etc/gateways
file.
since a larger metric
@ -270,13 +280,13 @@ Notice that because a metric of 1 is used, this feature is
dangerous. It is more commonly accidentally used to create chaos with routing
loop than to solve problems.
.It Fl h
This causes host or point-to-point routes to not be advertised,
cause host or point-to-point routes to not be advertised,
provided there is a network route going the same direction.
That is a limited kind of aggregation.
This option is useful on gateways to ethernets that have other gateway
This option is useful on gateways to Ethernets that have other gateway
machines connected with point-to-point links such as SLIP.
.It Fl m
This causes the machine to advertise a host or point-to-point route to
cause the machine to advertise a host or point-to-point route to
its primary interface.
It is useful on multi-homed machines such as NFS servers.
This option should not be used except when the cost of
@ -297,7 +307,7 @@ However, it makes no sense and breaks using RIP as a discovery protocol
to ignore all RIPv2 packets that carry authentication when this machine
does not care about authentication.
.It Fl t
increases the debugging level, which causes more information to be logged
increase the debugging level, which causes more information to be logged
on the tracefile specified with
.Fl T
or standard out.
@ -313,10 +323,10 @@ command.
increases the debugging level to at least 1 and
causes debugging information to be appended to the trace file.
Note that because of security concerns, it is wisest to not run
.Nm routed
.Nm
routinely with tracing directed to a file.
.It Fl v
displays and logs the version of daemon.
display and logs the version of daemon.
.It Fl F Ar net[/mask][,metric]
minimize routes in transmissions via interfaces with addresses that match
.Em net/mask ,
@ -406,9 +416,9 @@ routing table nor are they included in routing updates.
The function of external entries is to indicate
that another routing process
will install such a route if necessary,
and that alternative routes to that destination should not be installed
and that other routes to that destination should not be installed
by
.Nm "" .
.Nm Ns .
Such entries are only required when both routers may learn of routes
to the same destination.
.Pp
@ -455,9 +465,9 @@ or
or
.Xr named 8 ,
must have been started before
.Nm "" Ns .)
.Nm Ns .)
.Pp
.Ar mask
.Ar Mask
is an optional number between 1 and 32 indicating the netmask associated
with
.Ar Nname .
@ -468,7 +478,7 @@ be forwarded.
.Pp
.Ar Value
is the hop count to the destination host or network.
.Ar " host hname "
.Ar " Host hname "
is equivalent to
.Ar " net nname/32 ".
.Pp
@ -522,7 +532,7 @@ is
a subnet should be
.Cm mask2 .
For example \f2ripv1_mask=192.0.2.16/28,27\f1 marks 192.0.2.16/28
as a subnet of 192.0.2.0/28 instead of 192.0.2.0/24.
as a subnet of 192.0.2.0/27 instead of 192.0.2.0/24.
.It Cm passwd Ns \&= Ns Ar XXX[|KeyID[start|stop]]
specifies a RIPv2 cleartext password that will be included on
all RIPv2 responses sent, and checked on all RIPv2 responses received.
@ -549,7 +559,7 @@ To protect the secrets, the passwd settings are valid only in the
.Em /etc/gateways
file and only when that file is readable only by UID 0.
.It Cm md5_passwd Ns \&= Ns Ar XXX|KeyID[start|stop]
specifes a RIPv2 MD5 password.
specifies a RIPv2 MD5 password.
Except that a
.Cm KeyID
is required, this keyword is similar to
@ -566,6 +576,7 @@ disables all RIP processing on the specified interface.
If no interfaces are allowed to process RIP packets,
.Nm
acts purely as a router discovery daemon.
.Pp
Note that turning off RIP without explicitly turning on router
discovery advertisements with
.Cm rdisc_adv
@ -597,11 +608,11 @@ specifies that Router Discovery solicitations should be sent,
even on point-to-point links,
which by default only listen to Router Discovery messages.
.It Cm no_rdisc_adv
disables the transmission of Router Discovery Advertisements
disables the transmission of Router Discovery Advertisements.
.It Cm rdisc_adv
specifies that Router Discovery Advertisements should be sent,
even on point-to-point links,
which by default only listen to Router Discovery messages
which by default only listen to Router Discovery messages.
.It Cm bcast_rdisc
specifies that Router Discovery packets should be broadcast instead of
multicast.
@ -618,7 +629,7 @@ are transmitted to N seconds and their lifetime to 3*N.
.It Cm fake_default Ns \&= Ns Ar metric
has an identical effect to
.Fl F Ar net[/mask][=metric]
with the network and mask coming from the sepcified interface.
with the network and mask coming from the specified interface.
.It Cm pm_rdisc
is similar to
.Cm fake_default .
@ -648,9 +659,9 @@ Otherwise, ICMP Redirect messages are overridden.
for distant gateways
.El
.Sh SEE ALSO
.Xr gated 8 ,
.Xr udp 4 ,
.Xr icmp 4 ,
.Xr udp 4 ,
.Xr gated 8 ,
.Xr htable 8 ,
.Xr rtquery 8 .
.Rs
@ -659,8 +670,8 @@ for distant gateways
.%Q Xerox System Integration Standard
.Re
.Sh BUGS
It does not always detect unidirectional failures in network interfaces
(e.g. when the output side fails).
It does not always detect unidirectional failures in network interfaces,
for example, when the output side fails.
.Sh HISTORY
The
.Nm

View File

@ -1,4 +1,4 @@
.\" $NetBSD: rtquery.8,v 1.11 1998/08/18 18:03:28 msaitoh Exp $
.\" $NetBSD: rtquery.8,v 1.12 1998/10/25 14:56:09 christos Exp $
.\"
.Dd June 1, 1996
.Dt RTQUERY 8
@ -65,35 +65,31 @@ and so answers completely.
is also used to turn tracing on or off in
.Xr routed 8 .
.Pp
Options supported by
.Nm "" :
.Bl -tag -width Ds
The following options are available:
.Bl -tag -width indent
.It Fl n
Normally network and host numbers are displayed both symbolically
and numerically.
The
.Fl n
option displays only the numeric network and host numbers.
displays only the numeric network and host numbers instead of both
numeric and and symbolic.
.It Fl p
Uses the
uses the
.Em poll
command to request full routing information from
.Xr gated 8 .
This is an undocumented extension RIP protocol supported only by
.Xr gated 8 .
.It Fl 1
query using RIP version 1 instead of RIP version 2.
queries using RIP version 1 instead of RIP version 2.
.It Fl w Ar timeout
changes the delay for an answer from each host.
By default, each host is given 15 seconds to respond.
.It Fl r Ar addr
ask about the route to destination
asks about the route to destination
.Em addr .
.It Fl a Ar passwd=XXX
.It Fl a Ar md5_passwd=XXX|KeyID
cause the query to be sent with the indicated cleartext or MD5 password.
causes the query to be sent with the indicated cleartext or MD5 password.
.It Fl t Ar op
change tracing, where
changes tracing, where
.Em op
is one of the following.
Requests from processes not running with UID 0 or on distant networks
@ -103,7 +99,7 @@ is likely to ignore these debugging requests.
.El
.Bl -tag -width Ds -offset indent-two
.It Em on=tracefile
turn tracing on into the specified file.
turns tracing on into the specified file.
That file must usually have been specified when the daemon was
started or be the same as a fixed name, often
.Pa /etc/routed.trace .

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtquery.c,v 1.8 1998/06/02 18:02:56 thorpej Exp $ */
/* $NetBSD: rtquery.c,v 1.9 1998/10/25 14:56:09 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -41,10 +41,11 @@ char copyright[] =
static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: rtquery.c,v 1.8 1998/06/02 18:02:56 thorpej Exp $");
__RCSID("$NetBSD: rtquery.c,v 1.9 1998/10/25 14:56:09 christos Exp $");
#endif
#include <sys/param.h>
#include <sys/cdefs.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/time.h>
@ -119,6 +120,7 @@ static void query_loop(char *argv[], int) __attribute((__noreturn__));
static int getnet(char *, struct netinfo *);
static u_int std_mask(u_int);
static int parse_quote(char **, char *, char *, char *, int);
static void usage(void);
int
@ -154,13 +156,13 @@ main(int argc,
wtime = (int)strtoul(optarg, &p, 0);
if (*p != '\0'
|| wtime <= 0)
goto usage;
usage();
break;
case 'r':
not_trace = 1;
if (rflag)
goto usage;
usage();
rflag = getnet(optarg, &OMSG.rip_nets[0]);
if (!rflag) {
struct hostent *hp = gethostbyname(optarg);
@ -170,7 +172,7 @@ main(int argc,
herror(0);
exit(1);
}
memmove(&OMSG.rip_nets[0].n_dst, hp->h_addr,
memcpy(&OMSG.rip_nets[0].n_dst, hp->h_addr,
sizeof(OMSG.rip_nets[0].n_dst));
OMSG.rip_nets[0].n_family = RIP_AF_INET;
OMSG.rip_nets[0].n_mask = -1;
@ -198,28 +200,28 @@ main(int argc,
OMSG.rip_cmd = RIPCMD_TRACEON;
if (!value
|| strlen(value) > MAXPATHLEN)
goto usage;
usage();
break;
case TRACE_MORE:
if (value)
goto usage;
usage();
OMSG.rip_cmd = RIPCMD_TRACEON;
value = "";
break;
case TRACE_OFF:
if (value)
goto usage;
usage();
OMSG.rip_cmd = RIPCMD_TRACEOFF;
value = "";
break;
case TRACE_DUMP:
if (value)
goto usage;
usage();
OMSG.rip_cmd = RIPCMD_TRACEON;
value = "dump/../table";
break;
default:
goto usage;
usage();
}
strcpy((char*)OMSG.rip_tracefile, value);
omsg_len += strlen(value) - sizeof(OMSG.ripun);
@ -230,40 +232,34 @@ main(int argc,
not_trace = 1;
p = strchr(optarg,'=');
if (!p)
goto usage;
usage();
*p++ = '\0';
if (!strcasecmp("passwd",optarg))
auth_type = RIP_AUTH_PW;
else if (!strcasecmp("md5_passwd",optarg))
auth_type = RIP_AUTH_MD5;
else
goto usage;
usage();
if (0 > parse_quote(&p,"|",&delim,
passwd,sizeof(passwd)))
goto usage;
usage();
if (auth_type == RIP_AUTH_MD5
&& delim == '|') {
keyid = strtoul(p+1,&p,0);
if (keyid > 255 || *p != '\0')
goto usage;
usage();
} else if (delim != '\0') {
goto usage;
usage();
}
break;
default:
goto usage;
usage();
}
argv += optind;
argc -= optind;
if (not_trace && trace) {
usage: fprintf(stderr, "%s: [-np1] [-r tgt_rt] [-w wtime]"
" [-a type=passwd] host1 [host2 ...]\n"
"or\t-t {on=filename|more|off|dump}"
" host1 [host2 ...]\n",
pgmname);
exit(1);
}
if (not_trace && trace)
usage();
if (argc == 0) {
argc = 1;
argv = default_argv;
@ -291,6 +287,19 @@ usage: fprintf(stderr, "%s: [-np1] [-r tgt_rt] [-w wtime]"
else
query_loop(argv, argc);
/* NOTREACHED */
return 0;
}
static void
usage(void)
{
fprintf(stderr,
"usage: rtquery [-np1] [-r tgt_rt] [-w wtime]"
" [-a type=passwd] host1 [host2 ...]\n"
"\trtquery -t {on=filename|more|off|dump}"
" host1 [host2 ...]\n");
exit(1);
}
@ -364,7 +373,7 @@ query_loop(char *argv[], int argc)
OMSG.rip_nets[1] = OMSG.rip_nets[0];
NA0.a_family = RIP_AF_AUTH;
NA0.a_type = RIP_AUTH_PW;
memmove(NA0.au.au_pw, passwd, RIP_AUTH_PW_LEN);
memcpy(NA0.au.au_pw, passwd, RIP_AUTH_PW_LEN);
omsg_len += sizeof(OMSG.rip_nets[0]);
} else if (auth_type == RIP_AUTH_MD5) {
@ -372,15 +381,17 @@ query_loop(char *argv[], int argc)
NA0.a_family = RIP_AF_AUTH;
NA0.a_type = RIP_AUTH_MD5;
NA0.au.a_md5.md5_keyid = (int8_t)keyid;
NA0.au.a_md5.md5_auth_len = RIP_AUTH_PW_LEN;
NA0.au.a_md5.md5_auth_len = RIP_AUTH_MD5_LEN;
NA0.au.a_md5.md5_seqno = 0;
NA0.au.a_md5.md5_pkt_len = sizeof(OMSG.rip_nets[1]);
cc = (char *)&NA2-(char *)&OMSG;
NA0.au.a_md5.md5_pkt_len = htons(cc);
NA2.a_family = RIP_AF_AUTH;
NA2.a_type = 1;
memmove(NA2.au.au_pw, passwd, sizeof(NA2.au.au_pw));
NA2.a_type = htons(1);
MD5Init(&md5_ctx);
MD5Update(&md5_ctx, (u_char *)&NA0,
(char *)(&NA2+1) - (char *)&NA0);
MD5Update(&md5_ctx,
(u_char *)&OMSG, cc);
MD5Update(&md5_ctx,
(u_char *)passwd, RIP_AUTH_MD5_LEN);
MD5Final(NA2.au.au_pw, &md5_ctx);
omsg_len += 2*sizeof(OMSG.rip_nets[0]);
}
@ -425,6 +436,11 @@ query_loop(char *argv[], int argc)
}
if (sp == 0) {
sp = malloc(sizeof(*sp));
if (sp == 0) {
fprintf(stderr,
"rtquery: malloc failed\n");
exit(1);
}
sp->addr = from.sin_addr;
sp->next = seen;
seen = sp;
@ -493,7 +509,7 @@ out(char *host)
herror(host);
return -1;
}
memmove(&router.sin_addr, hp->h_addr, sizeof(router.sin_addr));
memcpy(&router.sin_addr, hp->h_addr, sizeof(router.sin_addr));
}
router.sin_port = htons(RIP_PORT);
@ -572,6 +588,9 @@ rip_input(struct sockaddr_in *from,
struct in_addr in;
char *name;
char net_buf[80];
u_char hash[RIP_AUTH_MD5_LEN];
MD5_CTX md5_ctx;
u_char md5_authed = 0;
u_int mask, dmask;
char *sp;
int i;
@ -686,15 +705,18 @@ rip_input(struct sockaddr_in *from,
if (na->a_type == RIP_AUTH_MD5
&& n == IMSG.rip_nets) {
(void)printf(" MD5 Authentication"
(void)printf(" MD5 Auth"
" len=%d KeyID=%d"
" seqno=%d"
" auth_len=%d"
" seqno=%#x"
" rsvd=%#x,%#x\n",
na->au.a_md5.md5_pkt_len,
ntohs(na->au.a_md5.md5_pkt_len),
na->au.a_md5.md5_keyid,
na->au.a_md5.md5_seqno,
na->au.a_md5.md5_auth_len,
ntohl(na->au.a_md5.md5_seqno),
na->au.a_md5.rsvd[0],
na->au.a_md5.rsvd[1]);
md5_authed = 1;
continue;
}
(void)printf(" Authentication type %d: ",
@ -702,6 +724,19 @@ rip_input(struct sockaddr_in *from,
for (i = 0; i < sizeof(na->au.au_pw); i++)
(void)printf("%02x ", na->au.au_pw[i]);
putc('\n', stdout);
if (md5_authed && n+1 > lim
&& na->a_type == ntohs(1)) {
MD5Init(&md5_ctx);
MD5Update(&md5_ctx, (u_char *)&IMSG,
(char *)na-(char *)&IMSG);
MD5Update(&md5_ctx, (u_char *)passwd,
RIP_AUTH_MD5_LEN);
MD5Final(hash, &md5_ctx);
(void)printf(" %s hash\n",
memcmp(hash, na->au.au_pw,
sizeof(hash))
? "WRONG" : "correct");
}
continue;
} else {
@ -829,7 +864,7 @@ parse_quote(char **linep,
if (c == '\0')
break;
if (c == '\\' && pc != '\0') {
if (c == '\\' && *pc != '\0') {
if ((c = *pc++) == 'n') {
c = '\n';
} else if (c == 'r') {

View File

@ -1,4 +1,4 @@
/* $NetBSD: table.c,v 1.7 1998/06/02 18:02:56 thorpej Exp $ */
/* $NetBSD: table.c,v 1.8 1998/10/25 14:56:09 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -37,7 +37,7 @@
static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: table.c,v 1.7 1998/06/02 18:02:56 thorpej Exp $");
__RCSID("$NetBSD: table.c,v 1.8 1998/10/25 14:56:09 christos Exp $");
#endif
#include "defs.h"
@ -192,11 +192,11 @@ ag_del(struct ag_info *ag)
}
/* Flush routes waiting for aggretation.
/* Flush routes waiting for aggregation.
* This must not suppress a route unless it is known that among all
* routes with coarser masks that match it, the one with the longest
* mask is appropriate. This is ensured by scanning the routes
* in lexical order, and with the most restritive mask first
* in lexical order, and with the most restrictive mask first
* among routes to the same destination.
*/
void
@ -335,8 +335,8 @@ ag_check(naddr dst,
* A route to an address less than the current destination
* will not be affected by the current route or any route
* seen hereafter. That means it is safe to suppress it.
* This check keeps poor routes (eg. with large hop counts)
* from preventing suppresion of finer routes.
* This check keeps poor routes (e.g. with large hop counts)
* from preventing suppression of finer routes.
*/
if (ag_cors != 0
&& ag->ag_dst_h < dst
@ -833,7 +833,7 @@ kern_check_static(struct khash *k,
if (k->k_metric == 0)
return;
bzero(&new, sizeof(new));
memset(&new, 0, sizeof(new));
new.rts_ifp = ifp;
new.rts_gate = k->k_gate;
new.rts_router = (ifp != 0) ? ifp->int_addr : loopaddr;
@ -1385,7 +1385,8 @@ kern_out(struct ag_info *ag)
/* ARGSUSED */
static int
walk_kern(struct radix_node *rn, struct walkarg *argp)
walk_kern(struct radix_node *rn,
struct walkarg *argp)
{
#define RT ((struct rt_entry *)rn)
char metric, pref;
@ -1952,7 +1953,8 @@ rtbad_sub(struct rt_entry *rt)
*/
/* ARGSUSED */
int
walk_bad(struct radix_node *rn, struct walkarg *argp)
walk_bad(struct radix_node *rn,
struct walkarg *argp)
{
#define RT ((struct rt_entry *)rn)
struct rt_spare *rts;
@ -1994,7 +1996,8 @@ walk_bad(struct radix_node *rn, struct walkarg *argp)
*/
/* ARGSUSED */
static int
walk_age(struct radix_node *rn, struct walkarg *argp)
walk_age(struct radix_node *rn,
struct walkarg *argp)
{
#define RT ((struct rt_entry *)rn)
struct interface *ifp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trace.c,v 1.21 1998/06/02 18:02:56 thorpej Exp $ */
/* $NetBSD: trace.c,v 1.22 1998/10/25 14:56:09 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -13,7 +13,7 @@
* 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:
* must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
@ -37,7 +37,7 @@
static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
#include <sys/cdefs.h>
__RCSID("$NetBSD: trace.c,v 1.21 1998/06/02 18:02:56 thorpej Exp $");
__RCSID("$NetBSD: trace.c,v 1.22 1998/10/25 14:56:09 christos Exp $");
#endif
#define RIPCMDS
@ -154,7 +154,7 @@ ts(time_t secs) {
#ifdef sgi
(void)cftime(s, "%T", &secs);
#else
memmove(s, ctime(&secs)+11, 8);
memcpy(s, ctime(&secs)+11, 8);
s[8] = '\0';
#endif
return s;
@ -874,7 +874,7 @@ trace_rip(char *dir1, char *dir2,
int size) /* total size of message */
{
struct netinfo *n, *lim;
# define NA (msg->rip_auths)
# define NA ((struct netauth*)n)
int i, seen_route;
if (!TRACEPACKETS || ftrace == 0)
@ -944,20 +944,21 @@ trace_rip(char *dir1, char *dir2,
if (NA->a_type == RIP_AUTH_MD5
&& n == msg->rip_nets) {
(void)fprintf(ftrace,
"\tMD5 Authentication"
" len=%d KeyID=%u"
" seqno=%u"
"\tMD5 Auth"
" pkt_len=%d KeyID=%u"
" auth_len=%d"
" seqno=%#x"
" rsvd=%#x,%#x\n",
NA->au.a_md5.md5_pkt_len,
NA->au.a_md5.md5_keyid,
NA->au.a_md5.md5_seqno,
NA->au.a_md5.rsvd[0],
NA->au.a_md5.rsvd[1]);
ntohs(NA->au.a_md5.md5_pkt_len),
NA->au.a_md5.md5_keyid,
NA->au.a_md5.md5_auth_len,
ntohl(NA->au.a_md5.md5_seqno),
ntohs(NA->au.a_md5.rsvd[0]),
ntohs(NA->au.a_md5.rsvd[1]));
continue;
}
(void)fprintf(ftrace,
"\tAuthentication"
" type %d: ",
"\tAuthentication type %d: ",
ntohs(NA->a_type));
for (i = 0;
i < sizeof(NA->au.au_pw);