date and time created 82/11/02 22:28:03 by sam
[unix-history] / usr / src / sbin / routed / defs.h
index ad5c95c..1c4dc0a 100644 (file)
@@ -1,4 +1,4 @@
-/*     defs.h  4.4     82/05/31        */
+/*     defs.h  4.10    82/06/10        */
 
 /*
  * Internal data structure definitions for
 
 /*
  * Internal data structure definitions for
@@ -8,6 +8,41 @@
  */
 #include <net/route.h>
 
  */
 #include <net/route.h>
 
+/*
+ * 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 # */
+};
+
+/*
+ * 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.
  *
 /*
  * Routing table structure; differs a bit from kernel tables.
  *
@@ -27,13 +62,12 @@ struct rt_entry {
                struct {
                        u_long  rtu_hash;
                        struct  sockaddr rtu_dst;
                struct {
                        u_long  rtu_hash;
                        struct  sockaddr rtu_dst;
-                       struct  sockaddr rtu_gateway;
+                       struct  sockaddr rtu_router;
                        short   rtu_flags;
                        short   rtu_flags;
-                       short   rtu_retry;
-                       short   rtu_timer;
                        short   rtu_state;
                        short   rtu_state;
+                       int     rtu_timer;
                        int     rtu_metric;
                        int     rtu_metric;
-                       struct  ifnet *rtu_ifp;
+                       struct  interface *rtu_ifp;
                } rtu_entry;
        } rt_rtu;
 };
                } rtu_entry;
        } rt_rtu;
 };
@@ -41,9 +75,8 @@ struct rt_entry {
 #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_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_gateway      rt_rtu.rtu_entry.rtu_gateway    /* who to forward to */
+#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_flags        rt_rtu.rtu_entry.rtu_flags      /* kernel flags */
-#define        rt_retry        rt_rtu.rtu_entry.rtu_retry      /* retries of ioctl */
 #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_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 */
@@ -54,13 +87,13 @@ struct rt_entry {
 /*
  * "State" of routing table entry.
  */
 /*
  * "State" of routing table entry.
  */
-#define        RTS_DELRT       0x1             /* delete pending */
-#define        RTS_CHGRT       0x2             /* change command pending */
-#define        RTS_ADDRT       0x4             /* add command pending */
-#define        RTS_HIDDEN      0x8             /* don't send to router */
+#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 rthash nethash[ROUTEHASHSIZ], hosthash[ROUTEHASHSIZ];
-struct rt_entry *rtlookup();
+struct rt_entry *rtlookup(), *rtfind();
 
 /*
  * Per address family routines.
 
 /*
  * Per address family routines.
@@ -69,9 +102,10 @@ 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_hash)();           /* returns keys based on address */
        int     (*af_netmatch)();       /* verifies net # matching */
        int     (*af_output)();         /* interprets address for sending */
-       int     (*af_portmatch)();      /* interprets address on receipt */
+       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_checkhost)();      /* tells if address for host or net */
-       int     (*af_canon)();          /* purges extraneous part of address */
+       int     (*af_canon)();          /* canonicalize address for compares */
 };
 
 /*
 };
 
 /*
@@ -83,3 +117,10 @@ struct afhash {
 };
 
 struct afswitch afswitch[AF_MAX];      /* table proper */
 };
 
 struct afswitch afswitch[AF_MAX];      /* table proper */
+
+/*
+ * When we find any interfaces marked down we rescan the
+ * kernel every CHECK_INTERVAL seconds to see if they've
+ * come up.
+ */
+#define        CHECK_INTERVAL  (1*60)