Home | History | Annotate | Line # | Download | only in routed
defs.h revision 1.9
      1 /*	$NetBSD: defs.h,v 1.9 1995/03/18 15:00:26 cgd Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1983, 1988, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the University of
     18  *	California, Berkeley and its contributors.
     19  * 4. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  *	@(#)defs.h	8.1 (Berkeley) 6/5/93
     36  */
     37 
     38 /*
     39  * Internal data structure definitions for
     40  * user routing process.  Based on Xerox NS
     41  * protocol specs with mods relevant to more
     42  * general addressing scheme.
     43  */
     44 #include <sys/param.h>
     45 #include <sys/socket.h>
     46 #include <sys/time.h>
     47 
     48 #include <net/route.h>
     49 #include <netinet/in.h>
     50 #include <protocols/routed.h>
     51 #include <arpa/inet.h>
     52 
     53 #include <netdb.h>
     54 #include <signal.h>
     55 #include <stdio.h>
     56 #include <stdlib.h>
     57 #include <string.h>
     58 #include <unistd.h>
     59 
     60 #include "trace.h"
     61 #include "interface.h"
     62 #include "table.h"
     63 #include "af.h"
     64 
     65 /*
     66  * When we find any interfaces marked down we rescan the
     67  * kernel every CHECK_INTERVAL seconds to see if they've
     68  * come up.
     69  */
     70 #define	CHECK_INTERVAL	(1*60)
     71 
     72 #define equal(a1, a2) \
     73 	(memcmp((a1), (a2), sizeof (struct sockaddr)) == 0)
     74 
     75 struct	sockaddr_in addr;	/* address of daemon's socket */
     76 
     77 int	s;			/* source and sink of all data */
     78 int	r;			/* routing socket */
     79 pid_t	pid;			/* process id for identifying messages */
     80 uid_t	uid;			/* user id for identifying messages */
     81 int	seqno;			/* sequence number for identifying messages */
     82 int	kmem;
     83 int	supplier;		/* process should supply updates */
     84 int	install;		/* if 1 call kernel */
     85 int	lookforinterfaces;	/* if 1 probe kernel for new up interfaces */
     86 int	performnlist;		/* if 1 check if /vmunix has changed */
     87 int	externalinterfaces;	/* # of remote and local interfaces */
     88 struct	timeval now;		/* current idea of time */
     89 struct	timeval lastbcast;	/* last time all/changes broadcast */
     90 struct	timeval lastfullupdate;	/* last time full table broadcast */
     91 struct	timeval nextbcast;	/* time to wait before changes broadcast */
     92 int	needupdate;		/* true if we need update at nextbcast */
     93 
     94 char	packet[MAXPACKETSIZE+1];
     95 struct	rip *msg;
     96 
     97 char	**argv0;
     98 struct	servent *sp;
     99 
    100 struct	in_addr inet_makeaddr();
    101 int	sndmsg();
    102 int	supply();
    103 
    104 void addrouteforif __P((struct interface *));
    105 void bumploglevel();
    106 void dumppacket __P((FILE *, char *, struct sockaddr_in *, char *,
    107     int, struct timeval *));
    108 void gwkludge();
    109 void hup();
    110 void ifinit();
    111 #ifdef notdef /* XXX FUNCTION UNUSED */
    112 u_long inet_lnaof_subnet __P((struct in_addr));
    113 #endif
    114 int inet_maskof __P((u_long));
    115 u_long inet_netof_subnet __P((struct in_addr));
    116 int inet_rtflags __P((struct sockaddr_in *));
    117 int inet_sendroute __P((struct rt_entry *, struct sockaddr_in *));
    118 void rip_input __P((struct sockaddr *, struct rip *, int));
    119 void rtadd __P((struct sockaddr *, struct sockaddr *, int, int));
    120 void rtchange __P((struct rt_entry *, struct sockaddr *, short));
    121 void rtdefault();
    122 void rtdelete __P((struct rt_entry *));
    123 void rtdeleteall __P((int));
    124 void rtinit();
    125 int rtioctl __P((int, struct rtuentry *));
    126 void sigtrace __P((int));
    127 int sndmsg __P((struct sockaddr *, int, struct interface *, int));
    128 void timer();
    129 void timevaladd __P((struct timeval *, struct timeval *));
    130 void toall __P((int (*)(), int, struct interface *));
    131 void traceoff();
    132 void traceon __P((char *));
    133 void trace __P((struct ifdebug *, struct sockaddr *, char *, int, int));
    134 void traceaction __P((FILE *, char *, struct rt_entry *));
    135 void traceinit __P((struct interface *));
    136 void tracenewmetric __P((FILE *, struct rt_entry *, int));
    137 
    138 #define ADD 1
    139 #define DELETE 2
    140 #define CHANGE 3
    141