Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Latest version of routed(8) from Vernon Schryver <vjs@calcite.rhyolit…

…e.com>
  • Loading branch information...
commit 0a6a74e3fc726b34db7e8051c1b375518d94b111 1 parent 37ad742
christos authored
View
21 sbin/routed/Makefile
@@ -1,21 +1,12 @@
-# @(#)Makefile 8.1 (Berkeley) 6/19/93
+# Make `routed` tools
+# $Revision: 1.1.1.6 $
PROG= routed
-SRCS= if.c input.c main.c md5.c output.c parms.c radix.c rdisc.c table.c \
- trace.c
+SRCS=if.c input.c main.c md5.c output.c parms.c radix.c rdisc.c table.c trace.c
MAN8= routed.0
+MLINKS= routed.8 rdisc.8
SUBDIR= rtquery
-#COPTS= -g -DDEBUG -Wall
+#COPTS= -g -DDEBUG -W -Wall -Wcast-align -Wcast-qual -Winline -Wpointer-arith -Wnested-externs -Wwrite-strings -Wunused
.include <bsd.prog.mk>
-
-.if (${MACHINE} == "vax")
-# The following can be deleted where not appropriate to use the kernel's
-# inline code expansions.
-INLINE= /sys/vax/inline/obj/inline
-C2= /usr/libexec/c2
-.c.o:
- ${CC} -S ${CFLAGS} ${.CURDIR}/${.PREFIX}.c
- @${C2} ${.PREFIX}.s | ${INLINE} | ${AS} -o ${.PREFIX}.o
- @rm -f ${.PREFIX}.s
-.endif
+.include <bsd.subdir.mk>
View
81 sbin/routed/defs.h
@@ -11,7 +11,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
@@ -32,11 +32,11 @@
*
* @(#)defs.h 8.1 (Berkeley) 6/5/93
*
- * $NetBSD: defs.h,v 1.1.1.6 1998/06/02 17:41:24 thorpej Exp $
+ * $NetBSD: defs.h,v 1.1.1.7 1999/02/23 09:56:49 christos Exp $
*/
-#ifndef __NetBSD__
-#ident "$Revision: 1.1.1.6 $"
+#ifdef sgi
+#ident "$Revision: 1.1.1.7 $"
#endif
/* Definitions for RIPv2 routing process.
@@ -55,7 +55,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.
@@ -77,6 +77,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>
@@ -88,6 +89,8 @@
#include <net/radix.h>
#else
#include "radix.h"
+#define UNUSED __attribute__((unused))
+#define PATTRIB(f,l) __attribute__((format (printf,f,l)))
#endif
#include <net/if.h>
#include <net/route.h>
@@ -105,13 +108,13 @@
* It should be defined somewhere netinet/in.h, but it is not.
*/
#ifdef sgi
-#define naddr __uint32_t
-#else
-#ifdef __NetBSD__
#define naddr u_int32_t
+#elif defined (__NetBSD__)
+#define naddr u_int32_t
+#define _HAVE_SA_LEN
+#define _HAVE_SIN_LEN
#else
#define naddr u_long
-#endif
#define _HAVE_SA_LEN
#define _HAVE_SIN_LEN
#endif
@@ -119,7 +122,9 @@
/* Turn on if IP_DROP_MEMBERSHIP and IP_ADD_MEMBERSHIP do not look at
* the dstaddr of point-to-point interfaces.
*/
-/* #define MCAST_PPP_BUG */
+#ifdef __NetBSD__
+#define MCAST_PPP_BUG
+#endif
#define DAY (24*60*60)
#define NEVER DAY /* a long time */
@@ -298,8 +303,8 @@ struct interface {
} int_data;
# define MAX_AUTH_KEYS 5
struct auth { /* authentication info */
- u_char type;
- u_char key[RIP_AUTH_PW_LEN];
+ u_int16_t type;
+ u_char key[RIP_AUTH_PW_LEN];
u_char keyid;
time_t start, end;
} int_auth[MAX_AUTH_KEYS];
@@ -366,7 +371,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
@@ -378,7 +383,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 netmasks */
#define AGS_SPLIT_HZ 0x200 /* suppress for split horizon */
/* some bits are set if they are set on either route */
@@ -397,7 +402,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;
@@ -458,7 +463,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 */
@@ -472,7 +477,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 */
@@ -485,7 +490,7 @@ extern int have_ripv1_out; /* have a RIPv1 interface */
extern int have_ripv1_in;
extern int need_flash; /* flash update needed */
extern struct timeval need_kern; /* need to update kernel table */
-extern int update_seqno; /* a route has changed */
+extern u_int update_seqno; /* a route has changed */
extern int tracelevel, new_tracelevel;
#define MAX_TRACELEVEL 4
@@ -504,7 +509,7 @@ extern struct radix_node_head *rhead;
#define dup2(x,y) BSDdup2(x,y)
#endif /* sgi */
-extern void fix_sock(int, char *);
+extern void fix_sock(int, const char *);
extern void fix_select(void);
extern void rip_off(void);
extern void rip_on(struct interface *);
@@ -518,7 +523,7 @@ extern void rip_bcast(int);
extern void supply(struct sockaddr_in *, struct interface *,
enum output_type, int, int, int);
-extern void msglog(char *, ...);
+extern void msglog(const char *, ...) PATTRIB(1,2);
struct msg_limit {
time_t reuse;
struct msg_sub {
@@ -527,9 +532,10 @@ struct msg_limit {
# define MSG_SUBJECT_N 8
} subs[MSG_SUBJECT_N];
};
-extern void msglim(struct msg_limit *, naddr, char *, ...);
+extern void msglim(struct msg_limit *, naddr,
+ const char *, ...) PATTRIB(3,4);
#define LOGERR(msg) msglog(msg ": %s", strerror(errno))
-extern void logbad(int, char *, ...);
+extern void logbad(int, const char *, ...) PATTRIB(2,3);
#define BADERR(dump,msg) logbad(dump,msg ": %s", strerror(errno))
#ifdef DEBUG
#define DBGERR(dump,msg) BADERR(dump,msg)
@@ -537,35 +543,35 @@ extern void logbad(int, char *, ...);
#define DBGERR(dump,msg) LOGERR(msg)
#endif
extern char *naddr_ntoa(naddr);
-extern char *saddr_ntoa(struct sockaddr *);
+extern const char *saddr_ntoa(struct sockaddr *);
-extern void *rtmalloc(size_t, char *);
+extern void *rtmalloc(size_t, const char *);
extern void timevaladd(struct timeval *, struct timeval *);
extern void intvl_random(struct timeval *, u_long, u_long);
extern int getnet(char *, naddr *, naddr *);
extern int gethost(char *, naddr *);
extern void gwkludge(void);
-extern char *parse_parms(char *, int);
-extern char *check_parms(struct parm *);
+extern const char *parse_parms(char *, int);
+extern const char *check_parms(struct parm *);
extern void get_parms(struct interface *);
extern void lastlog(void);
extern void trace_close(int);
-extern void set_tracefile(char *, char *, int);
-extern void tracelevel_msg(char *, int);
-extern void trace_off(char*, ...);
+extern void set_tracefile(const char *, const char *, int);
+extern void tracelevel_msg(const char *, int);
+extern void trace_off(const char*, ...) PATTRIB(1,2);
extern void set_tracelevel(void);
extern void trace_flush(void);
-extern void trace_misc(char *, ...);
-extern void trace_act(char *, ...);
-extern void trace_pkt(char *, ...);
-extern void trace_add_del(char *, struct rt_entry *);
+extern void trace_misc(const char *, ...) PATTRIB(1,2);
+extern void trace_act(const char *, ...) PATTRIB(1,2);
+extern void trace_pkt(const char *, ...) PATTRIB(1,2);
+extern void trace_add_del(const char *, struct rt_entry *);
extern void trace_change(struct rt_entry *, u_int, struct rt_spare *,
- char *);
-extern void trace_if(char *, struct interface *);
+ const char *);
+extern void trace_if(const char *, struct interface *);
extern void trace_upslot(struct rt_entry *, struct rt_spare *,
struct rt_spare *);
-extern void trace_rip(char*, char*, struct sockaddr_in *,
+extern void trace_rip(const char*, const char*, struct sockaddr_in *,
struct interface *, struct rip *, int);
extern char *addrname(naddr, naddr, int);
extern char *rtname(naddr, naddr, naddr);
@@ -606,7 +612,6 @@ extern void rtbad_sub(struct rt_entry *);
extern void rtswitch(struct rt_entry *, struct rt_spare *);
extern void rtbad(struct rt_entry *);
-
#define S_ADDR(x) (((struct sockaddr_in *)(x))->sin_addr.s_addr)
#define INFO_DST(I) ((I)->rti_info[RTAX_DST])
#define INFO_GATE(I) ((I)->rti_info[RTAX_GATEWAY])
@@ -628,7 +633,7 @@ extern int check_remote(struct interface *);
extern int addrouteforif(register struct interface *);
extern void ifinit(void);
extern int walk_bad(struct radix_node *, struct walkarg *);
-extern int if_ok(struct interface *, char *);
+extern int if_ok(struct interface *, const char *);
extern void if_sick(struct interface *);
extern void if_bad(struct interface *);
extern void if_link(struct interface *);
View
27 sbin/routed/if.c
@@ -11,7 +11,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
@@ -31,12 +31,11 @@
* SUCH DAMAGE.
*/
-#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
-static char sccsid[] = "@(#)if.c 8.1 (Berkeley) 6/5/93";
+#if !defined(sgi) && !defined(__NetBSD__)
+static char sccsid[] __attribute__((unused)) = "@(#)if.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
-static char rcsid[] = "$NetBSD: if.c,v 1.1.1.6 1998/06/02 17:41:24 thorpej Exp $";
+__RCSID("$NetBSD: if.c,v 1.1.1.7 1999/02/23 09:56:50 christos Exp $");
#endif
-#ident "$Revision: 1.1.1.6 $"
#include "defs.h"
#include "pathnames.h"
@@ -335,7 +334,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.
@@ -582,7 +581,7 @@ if_bad(struct interface *ifp)
*/
int /* 1=it was dead */
if_ok(struct interface *ifp,
- char *type)
+ const char *type)
{
struct interface *ifp1;
@@ -640,7 +639,7 @@ rt_xaddrs(struct rt_addrinfo *info,
#endif
- bzero(info, sizeof(*info));
+ memset(info, 0, sizeof(*info));
info->rti_addrs = addrs;
for (i = 0; i < RTAX_MAX && sa < lim; i++) {
if ((addrs & (1 << i)) == 0)
@@ -698,7 +697,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);
@@ -740,7 +739,7 @@ ifinit(void)
ifm = (struct if_msghdr *)ifam;
/* make prototype structure for the IP aliases
*/
- bzero(&ifs0, sizeof(ifs0));
+ memset(&ifs0, 0, sizeof(ifs0));
ifs0.int_rip_sock = -1;
ifs0.int_index = ifm->ifm_index;
ifs0.int_if_flags = ifm->ifm_flags;
@@ -773,7 +772,7 @@ ifinit(void)
* will be an alias.
* Do not output RIP or Router-Discovery packets via aliases.
*/
- bcopy(&ifs0, &ifs, sizeof(ifs));
+ memcpy(&ifs, &ifs0, sizeof(ifs));
ifs0.int_state |= (IS_ALIAS | IS_NO_RIP_OUT | IS_NO_RDISC);
if (INFO_IFA(&info) == 0) {
@@ -967,7 +966,7 @@ ifinit(void)
} else if (now.tv_sec>(ifp->int_data.ts
+ CHECK_BAD_INTERVAL)) {
trace_act("interface %s has been off"
- " %d seconds; forget it",
+ " %ld seconds; forget it",
ifp->int_name,
now.tv_sec-ifp->int_data.ts);
ifdel(ifp);
@@ -1008,7 +1007,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) {
@@ -1108,7 +1107,7 @@ ifinit(void)
/* It is new and ok. Add it to the list of interfaces
*/
ifp = (struct interface *)rtmalloc(sizeof(*ifp), "ifinit ifp");
- bcopy(&ifs, ifp, sizeof(*ifp));
+ memcpy(ifp, &ifs, sizeof(*ifp));
get_parms(ifp);
if_link(ifp);
trace_if("Add", ifp);
View
83 sbin/routed/input.c
@@ -11,7 +11,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
@@ -31,12 +31,11 @@
* SUCH DAMAGE.
*/
-#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
-static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/5/93";
+#if !defined(sgi) && !defined(__NetBSD__)
+static char sccsid[] __attribute__((unused)) = "@(#)input.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
-static char rcsid[] = "$NetBSD: input.c,v 1.1.1.6 1998/06/02 17:41:25 thorpej Exp $";
+__RCSID("$NetBSD: input.c,v 1.1.1.7 1999/02/23 09:56:50 christos Exp $");
#endif
-#ident "$Revision: 1.1.1.6 $"
#include "defs.h"
@@ -145,7 +144,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
struct rt_spare new;
struct netinfo *n, *lim;
struct interface *ifp1;
- naddr gate, mask, v1_mask, dst, ddst_h;
+ naddr gate, mask, v1_mask, dst, ddst_h = 0;
struct auth *ap;
struct tgate *tg = 0;
struct tgate_net *tn;
@@ -167,7 +166,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
} else if (rip->rip_vers > RIPv2) {
rip->rip_vers = RIPv2;
}
- if (cc > OVER_MAXPACKETSIZE) {
+ if (cc > (int)OVER_MAXPACKETSIZE) {
msglim(&bad_router, FROM_NADDR,
"packet at least %d bytes too long received from %s",
cc-MAXPACKETSIZE, naddr_ntoa(FROM_NADDR));
@@ -183,7 +182,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
@@ -233,7 +232,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
@@ -607,7 +606,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. */
@@ -633,7 +632,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
} else if ((ntohl(dst) & ~mask) != 0) {
msglim(&bad_mask, FROM_NADDR,
"router %s sent bad netmask"
- " %#x with %s",
+ " %#lx with %s",
naddr_ntoa(FROM_NADDR),
mask,
naddr_ntoa(dst));
@@ -670,7 +669,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
*/
if (aifp->int_d_metric != 0
&& dst == RIP_DEFAULT
- && n->n_metric >= aifp->int_d_metric)
+ && (int)n->n_metric >= aifp->int_d_metric)
continue;
/* We can receive aggregated RIPv2 routes that must
@@ -911,7 +910,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) {
@@ -929,7 +928,7 @@ ck_passwd(struct interface *aifp,
continue;
if (NA->a_type == RIP_AUTH_PW) {
- if (!bcmp(NA->au.au_pw, ap->key, RIP_AUTH_PW_LEN))
+ if (!memcmp(NA->au.au_pw, ap->key, RIP_AUTH_PW_LEN))
return 1;
} else {
@@ -938,28 +937,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-(int)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
- || bcmp(hash, na2->au.au_pw, sizeof(hash)))
- return 0;
- return 1;
+ if (!memcmp(hash, na2->au.au_pw, sizeof(hash)))
+ return 1;
}
}
View
70 sbin/routed/main.c
@@ -11,7 +11,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,12 +34,11 @@
char copyright[] =
"@(#) Copyright (c) 1983, 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n";
-#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
-static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/5/93";
+#if !defined(sgi) && !defined(__NetBSD__)
+static char sccsid[] __attribute__((unused)) = "@(#)main.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
-static char rcsid[] = "$NetBSD: main.c,v 1.1.1.6 1998/06/02 17:41:25 thorpej Exp $";
+__RCSID("$NetBSD: main.c,v 1.1.1.7 1999/02/23 09:56:50 christos Exp $");
#endif
-#ident "$Revision: 1.1.1.6 $"
#include "defs.h"
#include "pathnames.h"
@@ -49,12 +48,6 @@ static char rcsid[] = "$NetBSD: main.c,v 1.1.1.6 1998/06/02 17:41:25 thorpej Exp
#include <signal.h>
#include <fcntl.h>
#include <sys/file.h>
-#if defined(sgi) && !defined(PRE_KUDZU)
-#include <cap_net.h>
-#else
-#define cap_socket socket
-#define cap_bind bind
-#endif
pid_t mypid;
@@ -71,7 +64,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 */
@@ -104,6 +97,7 @@ main(int argc,
int n, mib[4], off;
size_t len;
char *p, *q;
+ const char *cp;
struct timeval wtime, t2;
time_t dt;
fd_set ibits;
@@ -134,7 +128,7 @@ main(int argc,
(void)gethostname(myname, sizeof(myname)-1);
(void)gethost(myname, &myaddr);
- while ((n = getopt(argc, argv, "sqdghmpAtvT:F:P:")) != EOF) {
+ while ((n = getopt(argc, argv, "sqdghmpAtvT:F:P:")) != -1) {
switch (n) {
case 's':
supplier = 1;
@@ -151,11 +145,11 @@ main(int argc,
break;
case 'g':
- bzero(&parm, sizeof(parm));
+ memset(&parm, 0, sizeof(parm));
parm.parm_d_metric = 1;
- p = check_parms(&parm);
- if (p != 0)
- msglog("bad -g: %s", p);
+ cp = check_parms(&parm);
+ if (cp != 0)
+ msglog("bad -g: %s", cp);
else
default_gateway = 1;
break;
@@ -198,29 +192,29 @@ main(int argc,
optarg);
break;
}
- bzero(&parm, sizeof(parm));
+ memset(&parm, 0, sizeof(parm));
parm.parm_net = p_net;
parm.parm_mask = p_mask;
parm.parm_d_metric = n;
- p = check_parms(&parm);
- if (p != 0)
- msglog("bad -F: %s", p);
+ cp = check_parms(&parm);
+ if (cp != 0)
+ msglog("bad -F: %s", cp);
break;
case 'P':
/* handle arbitrary parameters.
*/
q = strdup(optarg);
- p = parse_parms(q, 0);
- if (p != 0)
- msglog("%s in \"-P %s\"", p, optarg);
+ cp = parse_parms(q, 0);
+ if (cp != 0)
+ msglog("%s in \"-P %s\"", cp, optarg);
free(q);
break;
case 'v':
/* display version */
verbose++;
- msglog("version 2.10");
+ msglog("version 2.16");
break;
default:
@@ -298,7 +292,7 @@ main(int argc,
/* prepare socket connected to the kernel.
*/
- rt_sock = cap_socket(AF_ROUTE, SOCK_RAW, 0);
+ rt_sock = socket(AF_ROUTE, SOCK_RAW, 0);
if (rt_sock < 0)
BADERR(1,"rt_sock = socket()");
if (fcntl(rt_sock, F_SETFL, O_NONBLOCK) == -1)
@@ -364,7 +358,7 @@ main(int argc,
dt = t2.tv_sec;
if (dt > 0)
dt -= wtime.tv_sec;
- trace_act("time changed by %d sec", dt);
+ trace_act("time changed by %d sec", (int)dt);
epoch.tv_sec += dt;
}
timevalsub(&now, &clk, &epoch);
@@ -419,7 +413,7 @@ main(int argc,
/* 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,
@@ -522,7 +516,7 @@ main(int argc,
/* ARGSUSED */
void
-sigalrm(int s)
+sigalrm(int s UNUSED)
{
/* Historically, SIGALRM would cause the daemon to check for
* new and broken interfaces.
@@ -575,7 +569,7 @@ fix_select(void)
void
fix_sock(int sock,
- char *name)
+ const char *name)
{
int on;
#define MIN_SOCKBUF (4*1024)
@@ -631,14 +625,14 @@ get_rip_sock(naddr addr,
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
BADERR(1,"rip_sock = socket()");
- bzero(&sin,sizeof(sin));
+ memset(&sin, 0, sizeof(sin));
#ifdef _HAVE_SIN_LEN
sin.sin_len = sizeof(sin);
#endif
sin.sin_family = AF_INET;
sin.sin_port = htons(RIP_PORT);
sin.sin_addr.s_addr = addr;
- if (cap_bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+ if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
if (serious)
BADERR(errno != EADDRINUSE, "bind(rip_sock)");
return -1;
@@ -777,7 +771,7 @@ rip_on(struct interface *ifp)
*/
void *
rtmalloc(size_t size,
- char *msg)
+ const char *msg)
{
void *p = malloc(size);
if (p == 0)
@@ -806,7 +800,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;
}
@@ -831,7 +825,7 @@ timevalsub(struct timeval *t1,
/* put a message into the system log
*/
void
-msglog(char *p, ...)
+msglog(const char *p, ...)
{
va_list args;
@@ -857,12 +851,12 @@ msglog(char *p, ...)
* For example, there can be many systems with the wrong password.
*/
void
-msglim(struct msg_limit *lim, naddr addr, char *p, ...)
+msglim(struct msg_limit *lim, naddr addr, const char *p, ...)
{
va_list args;
int i;
struct msg_sub *ms1, *ms;
- char *p1;
+ const char *p1;
va_start(args, p);
@@ -912,7 +906,7 @@ msglim(struct msg_limit *lim, naddr addr, char *p, ...)
void
-logbad(int dump, char *p, ...)
+logbad(int dump, const char *p, ...)
{
va_list args;
View
47 sbin/routed/output.c
@@ -11,7 +11,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
@@ -31,17 +31,16 @@
* SUCH DAMAGE.
*/
-#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
-static char sccsid[] = "@(#)output.c 8.1 (Berkeley) 6/5/93";
+#if !defined(sgi) && !defined(__NetBSD__)
+static char sccsid[] __attribute__((unused)) = "@(#)output.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
-static char rcsid[] = "$NetBSD: output.c,v 1.1.1.6 1998/06/02 17:41:25 thorpej Exp $";
+__RCSID("$NetBSD: output.c,v 1.1.1.7 1999/02/23 09:56:51 christos Exp $");
#endif
-#ident "$Revision: 1.1.1.6 $"
#include "defs.h"
-int update_seqno;
+u_int update_seqno;
/* walk the tree of routes with this for output
@@ -102,7 +101,7 @@ output(enum output_type type,
{
struct sockaddr_in sin;
int flags;
- char *msg;
+ const char *msg;
int res;
naddr tgt_mcast;
int soc;
@@ -151,7 +150,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
@@ -211,7 +210,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.
*/
@@ -259,25 +258,26 @@ clr_ws_buf(struct ws_buf *wb,
wb->lim = wb->base + NETS_LEN;
wb->n = wb->base;
- bzero(wb->n, NETS_LEN*sizeof(*wb->n));
+ 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;
- bcopy(ap->key, na->au.au_pw, 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 */
}
@@ -290,17 +290,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;
- bcopy(ap->key, na2->au.au_pw, 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++;
}
@@ -312,7 +313,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) {
@@ -445,7 +446,7 @@ supply_out(struct ag_info *ag)
/* ARGSUSED */
static int
walk_supply(struct radix_node *rn,
- struct walkarg *w)
+ struct walkarg *argp UNUSED)
{
#define RT ((struct rt_entry *)rn)
u_short ags;
@@ -587,7 +588,7 @@ walk_supply(struct radix_node *rn,
* 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)
@@ -902,7 +903,7 @@ rip_query(void)
if (rip_sock < 0)
return;
- bzero(&buf, sizeof(buf));
+ memset(&buf, 0, sizeof(buf));
for (ifp = ifnet; ifp; ifp = ifp->int_next) {
/* Skip interfaces those already queried.
View
121 sbin/routed/parms.c
@@ -11,7 +11,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
@@ -31,12 +31,11 @@
* SUCH DAMAGE.
*/
-#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
-static char sccsid[] = "@(#)if.c 8.1 (Berkeley) 6/5/93";
+#if !defined(sgi) && !defined(__NetBSD__)
+static char sccsid[] __attribute__((unused)) = "@(#)if.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
-static char rcsid[] = "$NetBSD: parms.c,v 1.1.1.4 1998/06/02 17:41:26 thorpej Exp $";
+__RCSID("$NetBSD: parms.c,v 1.1.1.5 1999/02/23 09:56:51 christos Exp $");
#endif
-#ident "$Revision: 1.1.1.4 $"
#include "defs.h"
#include "pathnames.h"
@@ -54,7 +53,7 @@ struct tgate *tgates;
void
get_parms(struct interface *ifp)
{
- static warned_auth_in, warned_auth_out;
+ static int warned_auth_in, warned_auth_out;
struct parm *parmp;
int i, num_passwds = 0;
@@ -75,9 +74,9 @@ get_parms(struct interface *ifp)
if (parmp->parm_auth[0].type == RIP_AUTH_NONE
|| num_passwds >= MAX_AUTH_KEYS)
break;
- bcopy(&parmp->parm_auth[i],
- &ifp->int_auth[num_passwds++],
- sizeof(ifp->int_auth[0]));
+ memcpy(&ifp->int_auth[num_passwds++],
+ &parmp->parm_auth[i],
+ sizeof(ifp->int_auth[0]));
}
if (parmp->parm_rdisc_pref != 0)
ifp->int_rdisc_pref = parmp->parm_rdisc_pref;
@@ -164,6 +163,7 @@ gwkludge(void)
{
FILE *fp;
char *p, *lptr;
+ const char *cp;
char lbuf[200], net_host[5], dname[64+1+64+1];
char gname[GNAME_LEN+1], qual[9];
struct interface *ifp;
@@ -171,7 +171,7 @@ gwkludge(void)
int metric, n, lnum;
struct stat sb;
u_int state;
- char *type;
+ const char *type;
fp = fopen(_PATH_GATEWAYS, "r");
@@ -185,7 +185,7 @@ gwkludge(void)
}
for (lnum = 1; ; lnum++) {
- if (0 == fgets(lbuf, sizeof(lbuf)-1, fp))
+ if (0 == fgets(lbuf, sizeof(lbuf), fp))
break;
lptr = lbuf;
while (*lptr == ' ')
@@ -202,12 +202,12 @@ gwkludge(void)
*/
if (strncasecmp("net", lptr, 3)
&& strncasecmp("host", lptr, 4)) {
- p = parse_parms(lptr,
- (sb.st_uid == 0
- && !(sb.st_mode&(S_IRWXG|S_IRWXO))));
- if (p != 0)
+ cp = parse_parms(lptr,
+ (sb.st_uid == 0
+ && !(sb.st_mode&(S_IRWXG|S_IRWXO))));
+ if (cp != 0)
msglog("%s in line %d of "_PATH_GATEWAYS,
- p, lnum);
+ cp, lnum);
continue;
}
@@ -249,7 +249,7 @@ gwkludge(void)
HTONL(dst); /* make network # into IP address */
} else {
msglog("bad \"%s\" in "_PATH_GATEWAYS
- " entry \"%s\"", lptr);
+ " entry \"%s\"", net_host, lptr);
continue;
}
@@ -317,7 +317,7 @@ gwkludge(void)
}
ifp = (struct interface *)rtmalloc(sizeof(*ifp), "gwkludge()");
- bzero(ifp, sizeof(*ifp));
+ memset(ifp, 0, sizeof(*ifp));
ifp->int_state = state;
if (netmask == HOST_MASK)
@@ -364,12 +364,13 @@ gwkludge(void)
*/
static int /* 0=ok, -1=bad */
parse_quote(char **linep, /* look here */
- char *delims, /* for these delimiters */
+ const char *delims, /* for these delimiters */
char *delimp, /* 0 or put found delimiter here */
char *buf, /* copy token to here */
int lim) /* at most this many bytes */
{
- char c, *pc, *p;
+ char c = '\0', *pc;
+ const char *p;
pc = *linep;
@@ -381,7 +382,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') {
@@ -432,6 +433,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)
@@ -441,15 +445,26 @@ parse_ts(time_t *tp,
return buf;
}
strcat(buf,"\n");
- bzero(&tm, sizeof(tm));
+ 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_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;
}
- if (tm.tm_year <= 37)
- tm.tm_year += 100;
+ 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);
@@ -463,11 +478,11 @@ parse_ts(time_t *tp,
/* Get a password, key ID, and expiration date in the format
* passwd|keyID|year/mon/day@hour:min|year/mon/day@hour:min
*/
-static char * /* 0 or error message */
+static const 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];
@@ -486,7 +501,7 @@ get_passwd(char *tgt,
return "too many passwords";
}
- bzero(&k, sizeof(k));
+ memset(&k, 0, sizeof(k));
k.type = type;
k.end = -1-DAY;
@@ -537,13 +552,13 @@ get_passwd(char *tgt,
if (delim != '\0')
return tgt;
- bcopy(&k, ap, sizeof(*ap));
+ memmove(ap, &k, sizeof(*ap));
return 0;
}
-static char *
-bad_str(char *estr)
+static const char *
+bad_str(const char *estr)
{
static char buf[100+8];
@@ -554,7 +569,7 @@ bad_str(char *estr)
/* Parse a set of parameters for an interface.
*/
-char * /* 0 or error message */
+const char * /* 0 or error message */
parse_parms(char *line,
int safe) /* 1=from secure file */
{
@@ -567,7 +582,8 @@ 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;
+ const char *msg;
char buf[BUFSIZ], buf2[BUFSIZ];
int i;
@@ -599,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))
@@ -613,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);
}
@@ -622,9 +641,8 @@ parse_parms(char *line,
return 0;
}
- bzero(&parm, sizeof(parm));
+ memset(&parm, 0, sizeof(parm));
- tgt = "null";
for (;;) {
tgt = line + strspn(line, " ,\n\r");
if (*tgt == '\0' || *tgt == '#')
@@ -673,17 +691,17 @@ parse_parms(char *line,
/* since cleartext passwords are so weak allow
* them anywhere
*/
- tgt = get_passwd(tgt,val0,&parm,RIP_AUTH_PW,1);
- if (tgt) {
+ msg = get_passwd(tgt,val0,&parm,RIP_AUTH_PW,1);
+ if (msg) {
*val0 = '\0';
- return bad_str(tgt);
+ return bad_str(msg);
}
} else if (PARSEQ("md5_passwd")) {
- tgt = get_passwd(tgt,val0,&parm,RIP_AUTH_MD5,safe);
- if (tgt) {
+ msg = get_passwd(tgt,val0,&parm,RIP_AUTH_MD5,safe);
+ if (msg) {
*val0 = '\0';
- return bad_str(tgt);
+ return bad_str(msg);
}
} else if (PARS("no_ag")) {
@@ -775,7 +793,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. */
@@ -810,7 +828,7 @@ parse_parms(char *line,
/* check for duplicate parameter specifications */
-char * /* 0 or error message */
+const char * /* 0 or error message */
check_parms(struct parm *new)
{
struct parm *parmp, **parmpp;
@@ -879,7 +897,7 @@ check_parms(struct parm *new)
* they affect the result in the order the operator specified.
*/
parmp = (struct parm*)rtmalloc(sizeof(*parmp), "check_parms");
- bcopy(new, parmp, sizeof(*parmp));
+ memcpy(parmp, new, sizeof(*parmp));
*parmpp = parmp;
return 0;
@@ -904,11 +922,11 @@ getnet(char *name,
/* Detect and separate "1.2.3.4/24"
*/
- if (0 != (mname = rindex(name,'/'))) {
+ if (0 != (mname = strrchr(name,'/'))) {
i = (int)(mname - name);
- if (i > sizeof(hname)-1) /* name too long */
+ if (i > (int)sizeof(hname)-1) /* name too long */
return 0;
- bcopy(name, hname, i);
+ memmove(hname, name, i);
hname[i] = '\0';
mname++;
name = hname;
@@ -942,7 +960,8 @@ getnet(char *name,
mask = (naddr)strtoul(mname, &p, 0);
if (*p != '\0' || mask > 32)
return 0;
- mask = HOST_MASK << (32-mask);
+ if (mask != 0)
+ mask = HOST_MASK << (32-mask);
}
/* must have mask of 0 with default */
@@ -990,7 +1009,7 @@ gethost(char *name,
hp = gethostbyname(name);
if (hp) {
- bcopy(hp->h_addr, addrp, sizeof(*addrp));
+ memcpy(addrp, hp->h_addr, sizeof(*addrp));
return 1;
}
View
4 sbin/routed/pathnames.h
@@ -11,7 +11,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
@@ -32,7 +32,7 @@
*
* @(#)pathnames.h 8.1 (Berkeley) 6/5/93
*
- * $NetBSD: pathnames.h,v 1.1.1.4 1996/09/24 15:11:40 christos Exp $
+ * $NetBSD: pathnames.h,v 1.1.1.5 1999/02/23 09:56:51 christos Exp $
*/
#include <paths.h>
View
114 sbin/routed/radix.c
@@ -11,7 +11,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
@@ -36,12 +36,11 @@
/*
* Routines to build and maintain radix trees for routing lookups.
*/
-#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
-static char sccsid[] = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
+#if !defined(sgi) && !defined(__NetBSD__)
+static char sccsid[] __attribute__((unused)) = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
#elif defined(__NetBSD__)
-static char rcsid[] = "$NetBSD: radix.c,v 1.1.1.2 1996/09/24 15:11:40 christos Exp $";
+__RCSID("$NetBSD: radix.c,v 1.1.1.3 1999/02/23 09:56:51 christos Exp $");
#endif
-#ident "$Revision: 1.1.1.2 $"
#include "defs.h"
@@ -58,9 +57,10 @@ static char *rn_zeros, *rn_ones;
#define rn_masktop (mask_rnhead->rnh_treetop)
#undef Bcmp
-#define Bcmp(a, b, l) (l == 0 ? 0 : bcmp((caddr_t)(a), (caddr_t)(b), (u_long)l))
+#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
@@ -100,8 +100,8 @@ struct radix_node *
rn_search(void *v_arg,
struct radix_node *head)
{
- register struct radix_node *x;
- register caddr_t v;
+ struct radix_node *x;
+ caddr_t v;
for (x = head, v = v_arg; x->rn_b >= 0;) {
if (x->rn_bmask & v[x->rn_off])
@@ -117,8 +117,8 @@ rn_search_m(void *v_arg,
struct radix_node *head,
void *m_arg)
{
- register struct radix_node *x;
- register caddr_t v = v_arg, m = m_arg;
+ struct radix_node *x;
+ caddr_t v = v_arg, m = m_arg;
for (x = head; x->rn_b >= 0;) {
if ((x->rn_bmask & m[x->rn_off]) &&
@@ -133,8 +133,8 @@ rn_search_m(void *v_arg,
int
rn_refines(void* m_arg, void *n_arg)
{
- register caddr_t m = m_arg, n = n_arg;
- register caddr_t lim, lim2 = lim = n + *(u_char *)n;
+ caddr_t m = m_arg, n = n_arg;
+ caddr_t lim, lim2 = lim = n + *(u_char *)n;
int longer = (*(u_char *)n++) - (int)(*(u_char *)m++);
int masks_are_equal = 1;
@@ -157,11 +157,9 @@ rn_refines(void* m_arg, void *n_arg)
}
struct radix_node *
-rn_lookup(v_arg, m_arg, head)
- void *v_arg, *m_arg;
- struct radix_node_head *head;
+rn_lookup(void *v_arg, void *m_arg, struct radix_node_head *head)
{
- register struct radix_node *x;
+ struct radix_node *x;
caddr_t netmask = 0;
if (m_arg) {
@@ -178,11 +176,11 @@ rn_lookup(v_arg, m_arg, head)
}
static int
-rn_satsifies_leaf(char *trial,
- register struct radix_node *leaf,
+rn_satisfies_leaf(char *trial,
+ struct radix_node *leaf,
int skip)
{
- register char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask;
+ char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask;
char *cplim;
int length = min(*(u_char *)cp, *(u_char *)cp2);
@@ -202,12 +200,12 @@ rn_match(void *v_arg,
struct radix_node_head *head)
{
caddr_t v = v_arg;
- register struct radix_node *t = head->rnh_treetop, *x;
- register caddr_t cp = v, cp2;
+ struct radix_node *t = head->rnh_treetop, *x;
+ caddr_t cp = v, cp2;
caddr_t cplim;
struct radix_node *saved_t, *top = t;
int off = t->rn_off, vlen = *(u_char *)cp, matched_off;
- register int test, b, rn_b;
+ int test, b, rn_b;
/*
* Open code rn_search(v, top) to avoid overhead of extra
@@ -271,7 +269,7 @@ rn_match(void *v_arg,
*/
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
@@ -280,12 +278,14 @@ rn_match(void *v_arg,
if (t->rn_flags & RNF_NORMAL) {
if (rn_b <= t->rn_b)
return t;
- } else if (rn_satsifies_leaf(v, t, matched_off))
- return t;
+ } else if (rn_satisfies_leaf(v, t, matched_off)) {
+ return t;
+ }
+ }
t = saved_t;
/* start searching up the tree */
do {
- register struct radix_mask *m;
+ struct radix_mask *m;
t = t->rn_p;
if ((m = t->rn_mklist)) {
/*
@@ -303,7 +303,7 @@ rn_match(void *v_arg,
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));
@@ -322,7 +322,7 @@ int rn_debug = 1;
struct radix_node *
rn_newpair(void *v, int b, struct radix_node nodes[2])
{
- register struct radix_node *tt = nodes, *t = tt + 1;
+ struct radix_node *tt = nodes, *t = tt + 1;
t->rn_b = b; t->rn_bmask = 0x80 >> (b & 7);
t->rn_l = tt; t->rn_off = b >> 3;
tt->rn_b = -1; tt->rn_key = (caddr_t)v; tt->rn_p = t;
@@ -343,17 +343,17 @@ rn_insert(void* v_arg,
caddr_t v = v_arg;
struct radix_node *top = head->rnh_treetop;
int head_off = top->rn_off, vlen = (int)*((u_char *)v);
- register struct radix_node *t = rn_search(v_arg, top);
- register caddr_t cp = v + head_off;
- register int b;
+ struct radix_node *t = rn_search(v_arg, top);
+ caddr_t cp = v + head_off;
+ int b;
struct radix_node *tt;
/*
* Find first bit at which v and t->rn_key differ
*/
{
- register caddr_t cp2 = t->rn_key + head_off;
- register int cmp_res;
+ caddr_t cp2 = t->rn_key + head_off;
+ int cmp_res;
caddr_t cplim = v + vlen;
while (cp < cplim)
@@ -371,14 +371,14 @@ rn_insert(void* v_arg,
cmp_res >>= 1;
}
{
- register struct radix_node *p, *x = top;
+ struct radix_node *p, *x = top;
cp = v;
do {
p = x;
if (cp[x->rn_off] & x->rn_bmask)
x = x->rn_r;
else x = x->rn_l;
- } while (b > (unsigned) x->rn_b); /* x->rn_b < b && x->rn_b >= 0 */
+ } while (b > (int)(unsigned)x->rn_b); /* x->rn_b < b && x->rn_b >= 0 */
#ifdef RN_DEBUG
if (rn_debug)
log(LOG_DEBUG, "rn_insert: Going In:\n"), traverse(p);
@@ -406,9 +406,9 @@ struct radix_node *
rn_addmask(void *n_arg, int search, int skip)
{
caddr_t netmask = (caddr_t)n_arg;
- register struct radix_node *x;
- register caddr_t cp, cplim;
- register int b = 0, mlen, j;
+ struct radix_node *x;
+ caddr_t cp, cplim;
+ int b = 0, mlen, j;
int maskduplicated, m0, isnormal;
struct radix_node *saved_x;
static int last_zeroed = 0;
@@ -442,9 +442,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);
@@ -476,7 +476,7 @@ rn_addmask(void *n_arg, int search, int skip)
static int /* XXX: arbitrary ordering for non-contiguous masks */
rn_lexobetter(void *m_arg, void *n_arg)
{
- register u_char *mp = m_arg, *np = n_arg, *lim;
+ u_char *mp = m_arg, *np = n_arg, *lim;
if (*mp > *np)
return 1; /* not really, but need to check longer one first */
@@ -488,10 +488,10 @@ rn_lexobetter(void *m_arg, void *n_arg)
}
static struct radix_mask *
-rn_new_radix_mask(register struct radix_node *tt,
- register struct radix_mask *next)
+rn_new_radix_mask(struct radix_node *tt,
+ struct radix_mask *next)
{
- register struct radix_mask *m;
+ struct radix_mask *m;
MKGet(m);
if (m == 0) {
@@ -517,7 +517,7 @@ rn_addroute(void *v_arg,
struct radix_node treenodes[2])
{
caddr_t v = (caddr_t)v_arg, netmask = (caddr_t)n_arg;
- register struct radix_node *t, *x = 0, *tt;
+ struct radix_node *t, *x = 0, *tt;
struct radix_node *saved_tt, *top = head->rnh_treetop;
short b = 0, b_leaf = 0;
int keyduplicated;
@@ -658,7 +658,7 @@ rn_delete(void *v_arg,
void *netmask_arg,
struct radix_node_head *head)
{
- register struct radix_node *t, *p, *x, *tt;
+ struct radix_node *t, *p, *x, *tt;
struct radix_mask *m, *saved_m, **mp;
struct radix_node *dupedkey, *saved_tt, *top;
caddr_t v, netmask;
@@ -779,7 +779,7 @@ rn_delete(void *v_arg,
m = mm;
}
if (m)
- syslog(LOG_ERR, "%s %lx at %lx\n",
+ syslog(LOG_ERR, "%s 0x%lx at 0x%lx\n",
"rn_delete: Orphaned Mask",
(unsigned long)m,
(unsigned long)x);
@@ -807,12 +807,12 @@ rn_delete(void *v_arg,
int
rn_walktree(struct radix_node_head *h,
- register int (*f)(struct radix_node *, struct walkarg*),
+ int (*f)(struct radix_node *, struct walkarg *),
struct walkarg *w)
{
int error;
struct radix_node *base, *next;
- register struct radix_node *rn = h->rnh_treetop;
+ struct radix_node *rn = h->rnh_treetop;
/*
* This gets complicated because we may delete the node
* while applying the function f to it, so we need to calculate
@@ -846,13 +846,11 @@ rn_walktree(struct radix_node_head *h,
int
rn_inithead(void **head, int off)
{
- register struct radix_node_head *rnh;
- register struct radix_node *t, *tt, *ttt;
+ struct radix_node_head *rnh;
+ 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);
@@ -881,9 +879,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
20 sbin/routed/radix.h
@@ -11,7 +11,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
@@ -102,7 +102,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);}
@@ -134,18 +134,18 @@ struct radix_node_head {
};
-#define Bcmp(a, b, n) bcmp(((char *)(a)), ((char *)(b)), (n))
-#define Bcopy(a, b, n) bcopy(((char *)(a)), ((char *)(b)), (unsigned)(n))
-#define Bzero(p, n) bzero((char *)(p), (int)(n));
-#define R_Malloc(p, t, n) (p = (t) malloc((unsigned int)(n)))
-#define Free(p) free((char *)p);
+#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 Free(p) free((void *)p);
void rn_init __P((void));
int rn_inithead __P((void **, int));
int rn_refines __P((void *, void *));
int rn_walktree __P((struct radix_node_head *,
- int (*)__P((struct radix_node *, struct walkarg*)),
- struct walkarg*));
+ int (*)__P((struct radix_node *, struct walkarg *)),
+ struct walkarg *));
+
struct radix_node
*rn_addmask __P((void *, int, int)),
*rn_addroute __P((void *, void *, struct radix_node_head *,
@@ -158,4 +158,6 @@ struct radix_node
*rn_search __P((void *, struct radix_node *)),
*rn_search_m __P((void *, struct radix_node *, void *));
+struct radix_node *rn_lookup __P((void *, void *, struct radix_node_head *));
+
#endif /* __RADIX_H_ */
View
61 sbin/routed/rdisc.c
@@ -11,7 +11,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
@@ -31,22 +31,16 @@
* SUCH DAMAGE.
*/
-#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
-static char sccsid[] = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
+#if !defined(sgi) && !defined(__NetBSD__)
+static char sccsid[] __attribute__((unused)) = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
#elif defined(__NetBSD__)
-static char rcsid[] = "$NetBSD: rdisc.c,v 1.1.1.4 1998/06/02 17:41:26 thorpej Exp $";
+__RCSID"$NetBSD: rdisc.c,v 1.1.1.5 1999/02/23 09:56:52 christos Exp $");
#endif
-#ident "$Revision: 1.1.1.4 $"
#include "defs.h"
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
-#if defined(sgi) && !defined(PRE_KUDZU)
-#include <cap_net.h>
-#else
-#define cap_socket socket
-#endif
/* router advertisement ICMP packet */
struct icmp_ad {
@@ -81,7 +75,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 */
@@ -100,7 +94,7 @@ struct dr { /* accumulated advertisements */
#define UNSIGN_PREF(p) SIGN_PREF(p)
/* adjust unsigned preference by interface metric,
* without driving it to infinity */
-#define PREF(p, ifp) ((p) <= (ifp)->int_metric ? ((p) != 0 ? 1 : 0) \
+#define PREF(p, ifp) ((int)(p) <= (ifp)->int_metric ? ((p) != 0 ? 1 : 0) \
: (p) - ((ifp)->int_metric))
static void rdisc_sort(void);
@@ -109,7 +103,7 @@ static void rdisc_sort(void);
/* dump an ICMP Router Discovery Advertisement Message
*/
static void
-trace_rdisc(char *act,
+trace_rdisc(const char *act,
naddr from,
naddr to,
struct interface *ifp,
@@ -157,7 +151,7 @@ static void
get_rdisc_sock(void)
{
if (rdisc_sock < 0) {
- rdisc_sock = cap_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
+ rdisc_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
if (rdisc_sock < 0)
BADERR(1,"rdisc_sock = socket()");
fix_sock(rdisc_sock,"rdisc_sock");
@@ -193,7 +187,7 @@ set_rdisc_mg(struct interface *ifp,
if (ifp->int_if_flags & IFF_POINTOPOINT)
return;
#endif
- bzero(&m, sizeof(m));
+ memset(&m, 0, sizeof(m));
m.imr_interface.s_addr = ((ifp->int_if_flags & IFF_POINTOPOINT)
? ifp->int_dstaddr
: ifp->int_addr);
@@ -262,7 +256,7 @@ set_supplier(void)
if (supplier_set)
return;
- trace_act("start suppying routes");
+ trace_act("start supplying routes");
/* Forget discovered routes.
*/
@@ -304,7 +298,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.
@@ -317,7 +311,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.
@@ -455,8 +449,8 @@ 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.
@@ -539,7 +533,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;
@@ -633,7 +627,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))
@@ -698,11 +692,11 @@ send_rdisc(union ad_u *p,
{
struct sockaddr_in sin;
int flags;
- char *msg;
+ const char *msg;
naddr tgt_mcast;
- bzero(&sin, sizeof(sin));
+ memset(&sin, 0, sizeof(sin));
sin.sin_addr.s_addr = dst;
sin.sin_family = AF_INET;
#ifdef _HAVE_SIN_LEN
@@ -737,7 +731,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
@@ -794,7 +788,7 @@ send_adv(struct interface *ifp,
n_long pref;
- bzero(&u,sizeof(u.ad));
+ memset(&u, 0, sizeof(u.ad));
u.ad.icmp_type = ICMP_ROUTERADVERT;
u.ad.icmp_ad_num = 1;
@@ -877,7 +871,7 @@ rdisc_sol(void)
continue;
if (!timercmp(&ifp->int_rdisc_timer, &now, >)) {
- bzero(&u,sizeof(u.so));
+ memset(&u, 0, sizeof(u.so));
u.so.icmp_type = ICMP_ROUTERSOLICIT;
u.so.icmp_cksum = in_cksum((u_short*)&u.so,
sizeof(u.so));
@@ -901,14 +895,14 @@ rdisc_sol(void)
/* check the IP header of a possible Router Discovery ICMP packet */
static struct interface * /* 0 if bad */
-ck_icmp(char *act,
+ck_icmp(const char *act,
naddr from,
struct interface *ifp,
naddr to,
union ad_u *p,
u_int len)
{
- char *type;
+ const char *type;
if (p->icmp.icmp_type == ICMP_ROUTERADVERT) {
@@ -1014,7 +1008,7 @@ read_d(void)
switch (p->icmp.icmp_type) {
case ICMP_ROUTERADVERT:
if (p->ad.icmp_ad_asize*4
- < sizeof(p->ad.icmp_ad_info[0])) {
+ < (int)sizeof(p->ad.icmp_ad_info[0])) {
msglim(&bad_asize, from.sin_addr.s_addr,
"intolerable rdisc address size=%d",
p->ad.icmp_ad_asize);
@@ -1024,9 +1018,10 @@ read_d(void)
trace_pkt(" empty?");
continue;
}
- if (cc != (sizeof(p->ad) - sizeof(p->ad.icmp_ad_info)
- + (p->ad.icmp_ad_num
- * sizeof(p->ad.icmp_ad_info[0])))) {
+ if (cc != (int)(sizeof(p->ad)
+ - sizeof(p->ad.icmp_ad_info)
+ + (p->ad.icmp_ad_num
+ * sizeof(p->ad.icmp_ad_info[0])))) {
msglim(&bad_len, from.sin_addr.s_addr,
"rdisc length %d does not match ad_num"
" %d", cc, p->ad.icmp_ad_num);
View
93 sbin/routed/routed.8
@@ -1,3 +1,5 @@
+.\" $Revision: 1.1.1.7 $
+.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -35,26 +37,29 @@
.Dt ROUTED 8
.Os BSD 4.4
.Sh NAME
-.Nm routed
+.Nm routed ,
+.Nm rdisc
.Nd network RIP and router discovery routing daemon
.Sh SYNOPSIS
-.Nm
+.Nm routed
.Op Fl sqdghmpAtv
.Op Fl T Ar tracefile
.Oo
.Fl F
.Ar net Ns Op /mask Ns Op ,metric
.Oc
-.OP Fl P Ar parms
+.Op Fl P Ar parms
.Sh DESCRIPTION
.Nm Routed
-is a dameon invoked at boot time to manage the network
+is a daemon invoked at boot time to manage the network
routing tables.
It uses Routing Information Protocol, RIPv1 (RFC\ 1058),
RIPv2 (RFC\ 1723),
and Internet Router Discovery Protocol (RFC 1256)
to maintain the kernel routing table.
-The RIPv1 protocol is based on the reference 4.3BSD daemon.
+The RIPv1 protocol is based on the reference
+.Bx 4.3
+daemon.
.Pp
It listens on the
.Xr udp 4
@@ -160,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 routed ,
+.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
@@ -179,7 +184,7 @@ support multicasting.
If no response is received on a remote interface, if there are errors
while sending responses,
or if there are more errors than input or output (see
-.Xr netstat 8 ),
+.Xr netstat 1 ),
then the cable or some other part of the interface is assumed to be
disconnected or broken, and routes are adjusted appropriately.
.Pp
@@ -196,7 +201,7 @@ it stops listening for broadcast or multicast RIP responses.
It tracks several advertising routers to speed recovery when the
currently chosen router dies.
If all discovered routers disappear,
-the daemon resumes listening to RIP responses
+the daemon resumes listening to RIP responses.
It continues listen to RIP while using Router Discovery
if multi-homed to ensure all interfaces are used.
.Pp
@@ -231,15 +236,13 @@ By default, neither Router Discovery advertisements nor solicitations
are sent over point to point links (e.g. PPP).
The netmask associated with point-to-point links (such as SLIP
or PPP, with the IFF_POINTOPOINT flag) is used by
-.Nm routed
+.Nm
to infer the netmask used by the remote system when RIPv1 is used.
-
.Pp
-Options supported by
-.Nm routed :
-.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
@@ -251,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
@@ -263,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