don't send net route to subnet gw's unless on subnet 0;
[unix-history] / usr / src / sbin / routed / defs.h
index ecb81c0..8abb105 100644 (file)
@@ -1,4 +1,10 @@
-/*     defs.h  4.12    82/11/14        */
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)defs.h      5.3 (Berkeley) %G%
+ */
 
 /*
  * Internal data structure definitions for
 
 /*
  * Internal data structure definitions for
 
 #include <net/route.h>
 #include <netinet/in.h>
 
 #include <net/route.h>
 #include <netinet/in.h>
+#include <protocols/routed.h>
 
 #include <stdio.h>
 #include <netdb.h>
 
 
 #include <stdio.h>
 #include <netdb.h>
 
-#include "rip.h"
-
-/*
- * Trace record format.
- */
-struct iftrace {
-       time_t  ift_stamp;              /* time stamp */
-       struct  sockaddr ift_who;       /* from/to */
-       char    *ift_packet;            /* pointer to packet */
-       short   ift_size;               /* size of packet */
-       short   ift_metric;             /* metric on associated metric */
-};
-
-/*
- * Per interface packet tracing buffers.  An incoming and
- * outgoing circular buffer of packets is maintained, per
- * interface, for debugging.  Buffers are dumped whenever
- * an interface is marked down.
- */
-struct ifdebug {
-       struct  iftrace *ifd_records;   /* array of trace records */
-       struct  iftrace *ifd_front;     /* next empty trace record */
-       struct  interface *ifd_if;      /* for locating stuff */
-};
-
-/*
- * An ``interface'' is similar to an ifnet structure,
- * except it doesn't contain q'ing info, and it also
- * handles ``logical'' interfaces (remote gateways
- * that we want to keep polling even if they go down).
- * The list of interfaces which we maintain is used
- * in supplying the gratuitous routing table updates.
- */
-struct interface {
-       struct  interface *int_next;
-       struct  sockaddr int_addr;              /* address on this host */
-       union {
-               struct  sockaddr intu_broadaddr;
-               struct  sockaddr intu_dstaddr;
-       } int_intu;
-#define        int_broadaddr   int_intu.intu_broadaddr /* broadcast address */
-#define        int_dstaddr     int_intu.intu_dstaddr   /* other end of p-to-p link */
-       int     int_metric;                     /* init's routing entry */
-       int     int_flags;                      /* see below */
-       int     int_net;                        /* network # */
-       struct  ifdebug int_input, int_output;  /* packet tracing stuff */
-       int     int_ipackets;                   /* input packets received */
-       int     int_opackets;                   /* output packets sent */
-       char    *int_name;                      /* from kernel if structure */
-       u_short int_transitions;                /* times gone up-down */
-};
-
-/*
- * 0x1 to 0x10 are reused from the kernel's ifnet definitions,
- * the others agree with the RTS_ flags defined below
- */
-#define        IFF_UP          0x1             /* interface is up */
-#define        IFF_BROADCAST   0x2             /* broadcast address valid */
-#define        IFF_DEBUG       0x4             /* turn on debugging */
-#define        IFF_ROUTE       0x8             /* routing entry installed */
-#define        IFF_POINTOPOINT 0x10            /* interface is point-to-point link */
-#define        IFF_PASSIVE     0x20            /* can't tell if up/down */
-#define        IFF_INTERFACE   0x40            /* hardware interface */
-#define        IFF_REMOTE      0x80            /* interface isn't on this machine */
-
-/*
- * Routing table structure; differs a bit from kernel tables.
- *
- * Note: the union below must agree in the first 4 members
- * so the ioctl's will work.
- */
-struct rthash {
-       struct  rt_entry *rt_forw;
-       struct  rt_entry *rt_back;
-};
-
-struct rt_entry {
-       struct  rt_entry *rt_forw;
-       struct  rt_entry *rt_back;
-       union {
-               struct  rtentry rtu_rt;
-               struct {
-                       u_long  rtu_hash;
-                       struct  sockaddr rtu_dst;
-                       struct  sockaddr rtu_router;
-                       short   rtu_flags;
-                       short   rtu_state;
-                       int     rtu_timer;
-                       int     rtu_metric;
-                       struct  interface *rtu_ifp;
-               } rtu_entry;
-       } rt_rtu;
-};
-
-#define        rt_rt           rt_rtu.rtu_rt                   /* pass to ioctl */
-#define        rt_hash         rt_rtu.rtu_entry.rtu_hash       /* for net or host */
-#define        rt_dst          rt_rtu.rtu_entry.rtu_dst        /* match value */
-#define        rt_router       rt_rtu.rtu_entry.rtu_router     /* who to forward to */
-#define        rt_flags        rt_rtu.rtu_entry.rtu_flags      /* kernel flags */
-#define        rt_timer        rt_rtu.rtu_entry.rtu_timer      /* for invalidation */
-#define        rt_state        rt_rtu.rtu_entry.rtu_state      /* see below */
-#define        rt_metric       rt_rtu.rtu_entry.rtu_metric     /* cost of route */
-#define        rt_ifp          rt_rtu.rtu_entry.rtu_ifp        /* interface to take */
-
-#define        ROUTEHASHSIZ    19
-
-/*
- * "State" of routing table entry.
- */
-#define        RTS_CHANGED     0x1             /* route has been altered recently */
-#define        RTS_PASSIVE     0x20            /* don't time out route */
-#define        RTS_INTERFACE   0x40            /* route is for network interface */
-#define        RTS_REMOTE      0x80            /* route is for ``remote'' entity */
-
-struct rthash nethash[ROUTEHASHSIZ], hosthash[ROUTEHASHSIZ];
-struct rt_entry *rtlookup(), *rtfind();
-
-/*
- * Per address family routines.
- */
-struct afswitch {
-       int     (*af_hash)();           /* returns keys based on address */
-       int     (*af_netmatch)();       /* verifies net # matching */
-       int     (*af_output)();         /* interprets address for sending */
-       int     (*af_portmatch)();      /* packet from some other router? */
-       int     (*af_portcheck)();      /* packet from priviledged peer? */
-       int     (*af_checkhost)();      /* tells if address for host or net */
-       int     (*af_canon)();          /* canonicalize address for compares */
-};
-
-/*
- * Structure returned by af_hash routines.
- */
-struct afhash {
-       u_int   afh_hosthash;           /* host based hash */
-       u_int   afh_nethash;            /* network based hash */
-};
-
-struct afswitch afswitch[AF_MAX];      /* table proper */
+#include "trace.h"
+#include "interface.h"
+#include "table.h"
+#include "af.h"
 
 /*
  * When we find any interfaces marked down we rescan the
 
 /*
  * When we find any interfaces marked down we rescan the
@@ -162,48 +34,20 @@ struct     afswitch afswitch[AF_MAX];      /* table proper */
  */
 #define        CHECK_INTERVAL  (1*60)
 
  */
 #define        CHECK_INTERVAL  (1*60)
 
-#define        LOOPBACKNET     0177
-/* casts to keep lint happy */
-#define        insque(q,p)     _insque((caddr_t)q,(caddr_t)p)
-#define        remque(q)       _remque((caddr_t)q)
 #define equal(a1, a2) \
        (bcmp((caddr_t)(a1), (caddr_t)(a2), sizeof (struct sockaddr)) == 0)
 #define        min(a,b)        ((a)>(b)?(b):(a))
 
 #define equal(a1, a2) \
        (bcmp((caddr_t)(a1), (caddr_t)(a2), sizeof (struct sockaddr)) == 0)
 #define        min(a,b)        ((a)>(b)?(b):(a))
 
-struct sockaddr_in routingaddr;
-struct sockaddr_in noroutingaddr;
+struct sockaddr_in addr;       /* address of daemon's socket */
 
 
-int    s;
-int    snoroute;               /* socket with no routing */
+int    s;                      /* source and sink of all data */
 int    kmem;
 int    supplier;               /* process should supply updates */
 int    install;                /* if 1 call kernel */
 int    kmem;
 int    supplier;               /* process should supply updates */
 int    install;                /* if 1 call kernel */
-int    lookforinterfaces;
-int    performnlist;
+int    lookforinterfaces;      /* if 1 probe kernel for new up interfaces */
+int    performnlist;           /* if 1 check if /vmunix has changed */
 int    externalinterfaces;     /* # of remote and local interfaces */
 int    externalinterfaces;     /* # of remote and local interfaces */
-int    timeval;
-
-/*
- * Packet tracing stuff.
- */
-int    tracing;                /* on/off */
-FILE   *ftrace;                /* output trace file */
-#define        TRACE_ACTION(action, route) \
-       { if (tracing) \
-               traceaction(ftrace, "action", route); \
-       }
-#define        TRACE_INPUT(ifp, from, size) \
-       { if (tracing) { \
-               ifp = if_iflookup(from); \
-               if (ifp) \
-                       trace(&ifp->int_input, from, packet, size, \
-                               ifp->int_metric); \
-         } \
-       }
-#define        TRACE_OUTPUT(ifp, to, size) \
-       { if (tracing) \
-               trace(&ifp->int_output, to, packet, size, ifp->int_metric); \
-       }
+int    timeval;                /* local idea of time */
 
 char   packet[MAXPACKETSIZE+1];
 struct rip *msg;
 
 char   packet[MAXPACKETSIZE+1];
 struct rip *msg;
@@ -211,10 +55,14 @@ struct     rip *msg;
 char   **argv0;
 struct servent *sp;
 
 char   **argv0;
 struct servent *sp;
 
-struct in_addr inet_makeaddr();
-struct interface *if_ifwithaddr(), *if_ifwithnet(), *if_iflookup();
-extern char *malloc(), *sys_errlist[];
-extern int errno, exit();
+extern char *sys_errlist[];
+extern int errno;
 
 
-int    sendmsg(), supply();
-int    timer(), cleanup();
+struct in_addr inet_makeaddr();
+int    inet_addr();
+char   *malloc();
+int    exit();
+int    sendmsg();
+int    supply();
+int    timer();
+int    cleanup();