111820Sjulian/*
211820Sjulian * Copyright (c) 1983, 1993
311820Sjulian *	The Regents of the University of California.  All rights reserved.
411820Sjulian *
511820Sjulian * Copyright (c) 1995 John Hay.  All rights reserved.
611820Sjulian *
711820Sjulian * Redistribution and use in source and binary forms, with or without
811820Sjulian * modification, are permitted provided that the following conditions
911820Sjulian * are met:
1011820Sjulian * 1. Redistributions of source code must retain the above copyright
1111820Sjulian *    notice, this list of conditions and the following disclaimer.
1211820Sjulian * 2. Redistributions in binary form must reproduce the above copyright
1311820Sjulian *    notice, this list of conditions and the following disclaimer in the
1411820Sjulian *    documentation and/or other materials provided with the distribution.
1511820Sjulian * 3. All advertising materials mentioning features or use of this software
1611820Sjulian *    must display the following acknowledgement:
1711820Sjulian *	This product includes software developed by the University of
1811820Sjulian *	California, Berkeley and its contributors.
1911820Sjulian * 4. Neither the name of the University nor the names of its contributors
2011820Sjulian *    may be used to endorse or promote products derived from this software
2111820Sjulian *    without specific prior written permission.
2211820Sjulian *
2311820Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2411820Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2511820Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2611820Sjulian * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2711820Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2811820Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2911820Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3011820Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3111820Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3211820Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3311820Sjulian * SUCH DAMAGE.
3411820Sjulian *
3511820Sjulian *	@(#)defs.h	8.1 (Berkeley) 6/5/93
3611820Sjulian *
3750479Speter * $FreeBSD$
3811820Sjulian */
3911820Sjulian
4011820Sjulian#include <sys/types.h>
4111820Sjulian#include <sys/socket.h>
4211820Sjulian
4390868Smike#include <arpa/inet.h>
4411820Sjulian#include <net/route.h>
4511820Sjulian#include <netipx/ipx.h>
4611820Sjulian#if defined(vax) || defined(pdp11)
4711820Sjulian#define xnnet(x) ((u_long) (x)->rip_dst[1] << 16 | (u_long) (x)->rip_dst[0] )
4811820Sjulian#else
4911820Sjulian#define xnnet(x) ((u_long) (x)->rip_dst[0] << 16 | (u_long) (x)->rip_dst[1] )
5011820Sjulian#endif
5111820Sjulian
5211820Sjulian#include <stdio.h>
5311820Sjulian#include <string.h>
5411820Sjulian#include <syslog.h>
5511820Sjulian
5611820Sjulian#include "protocol.h"
5711820Sjulian#include "sap.h"
5811820Sjulian#include "table.h"
5911820Sjulian#include "trace.h"
6011820Sjulian#include "interface.h"
6111820Sjulian#include "af.h"
6211820Sjulian
6311820Sjulian
6411820Sjulian/*
6511820Sjulian * When we find any interfaces marked down we rescan the
6611820Sjulian * kernel every CHECK_INTERVAL seconds to see if they've
6711820Sjulian * come up.
6811820Sjulian */
6911820Sjulian#define	CHECK_INTERVAL	(5*60)
7011820Sjulian
7111820Sjulian#define equal(a1, a2) \
7211820Sjulian	(bcmp((caddr_t)(a1), (caddr_t)(a2), sizeof (struct sockaddr)) == 0)
7311820Sjulian#define	min(a,b)	((a)>(b)?(b):(a))
7411820Sjulian#define	max(a,b)	((a)<(b)?(b):(a))
7511820Sjulian
7611820Sjulianextern int	ripsock;		/* Socket to listen on */
7711820Sjulianextern int	sapsock;		/* Socket to listen on */
7811820Sjulianextern int	kmem;
7911820Sjulianextern int	supplier;		/* process should supply updates */
8011820Sjulianextern int	dosap;			/* SAP is enabled */
8145988Sjhayextern int	dognreply;		/* enable GET_NEAREST response */
8211820Sjulianextern int	install;		/* if 1 call kernel */
8311820Sjulianextern int	lookforinterfaces;	/* if 1 probe kernel for new up ifs */
8411820Sjulianextern int	performnlist;		/* if 1 check if /kernel has changed */
8511820Sjulianextern int	externalinterfaces;	/* # of remote and local interfaces */
8611820Sjulianextern int	timeval;		/* local idea of time */
8711820Sjulianextern int	noteremoterequests;	/* squawk on requests from non-local nets */
8811820Sjulianextern int	r;			/* Routing socket to install updates with */
8911820Sjulianextern int gateway;
9011820Sjulianextern struct	sockaddr_ipx ipx_netmask;	/* Used in installing routes */
9111820Sjulian
9215248Sjhayextern char	packet[MAXRXPACKETSIZE+1];
9311820Sjulianextern struct	rip *msg;
9411820Sjulian
9511820Sjulianextern char	**argv0;
9611820Sjulian
9711820Sjulian#define	ADD	1
9811820Sjulian#define	DELETE	2
9911820Sjulian#define CHANGE	3
10011820Sjulian
10127244Sjhayvoid	sndmsg(struct sockaddr *, int, struct interface *, int);
10227244Sjhayvoid	supply(struct sockaddr *, int, struct interface *, int);
10311820Sjulianvoid	addrouteforif(struct interface *);
10411820Sjulianvoid	ifinit(void);
10527244Sjhayvoid	toall(void (*f)(struct sockaddr *, int, struct interface *, int),
10627244Sjhay	      struct rt_entry *, int);
10711820Sjulianvoid	rip_input(struct sockaddr *, int);
10811820Sjulian
109