Permalink
Browse files

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

…e.com>
  • Loading branch information...
1 parent 1bc0260 commit 8e9982193594cc72e8d530ef545aa584e174ac41 christos committed Feb 23, 1999
View
@@ -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
@@ -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,21 +108,23 @@
* 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
/* 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,45 +532,46 @@ 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)
#else
#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
@@ -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);
Oops, something went wrong.

0 comments on commit 8e99821

Please sign in to comment.