defs.h revision 1.11 1 /* $NetBSD: defs.h,v 1.11 1995/06/20 22:26:57 christos 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 "table.h"
61 #include "trace.h"
62 #include "interface.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 /* inet.c */
101 struct in_addr inet_makeaddr __P((u_long, u_long ));
102 u_long inet_netof_subnet __P((struct in_addr));
103 u_long inet_lnaof_subnet __P((struct in_addr));
104 int inet_maskof __P((u_long));
105 int inet_rtflags __P((struct sockaddr *));
106 int inet_sendroute __P((struct rt_entry *, struct sockaddr *));
107
108 /* input.c */
109 void rip_input __P((struct sockaddr *, struct rip *, int));
110
111 /* main.c */
112 int main __P((int, char *[]));
113 void process __P((int));
114 int getsocket __P((int, int , struct sockaddr_in *));
115
116 /* output.c */
117 void toall __P((void (*)(struct sockaddr *, int, struct interface *, int),
118 int, struct interface *));
119 void sndmsg __P((struct sockaddr *, int, struct interface *, int));
120 void supply __P((struct sockaddr *, int, struct interface *, int));
121
122 /* startup.c */
123 void quit __P((char *));
124 void rt_xaddrs __P((caddr_t, caddr_t , struct rt_addrinfo *));
125 void ifinit __P((void));
126 void addrouteforif __P((struct interface *));
127 void add_ptopt_localrt __P((struct interface *));
128 void gwkludge __P((void));
129 int getnetorhostname __P((char *, char *, struct sockaddr_in *));
130 int gethostnameornumber __P((char *, struct sockaddr_in *));
131
132 /* timer.c */
133 void timer __P((int));
134 void hup __P((int));
135
136 #define ADD 1
137 #define DELETE 2
138 #define CHANGE 3
139