umount -> unmount
[unix-history] / usr / src / sbin / routed / defs.h
index 10b14a5..ecb81c0 100644 (file)
@@ -1,4 +1,4 @@
-/*     defs.h  4.9     82/06/09        */
+/*     defs.h  4.12    82/11/14        */
 
 /*
  * Internal data structure definitions for
 
 /*
  * Internal data structure definitions for
@@ -6,7 +6,79 @@
  * protocol specs with mods relevant to more
  * general addressing scheme.
  */
  * protocol specs with mods relevant to more
  * general addressing scheme.
  */
+#include <sys/types.h>
+#include <sys/socket.h>
+
 #include <net/route.h>
 #include <net/route.h>
+#include <netinet/in.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.
 
 /*
  * Routing table structure; differs a bit from kernel tables.
@@ -32,8 +104,7 @@ struct rt_entry {
                        short   rtu_state;
                        int     rtu_timer;
                        int     rtu_metric;
                        short   rtu_state;
                        int     rtu_timer;
                        int     rtu_metric;
-                       struct  ifnet *rtu_ifp;
-                       struct  sockaddr rtu_oldrouter;
+                       struct  interface *rtu_ifp;
                } rtu_entry;
        } rt_rtu;
 };
                } rtu_entry;
        } rt_rtu;
 };
@@ -47,20 +118,16 @@ struct rt_entry {
 #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        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        rt_oldrouter    rt_rtu.rtu_entry.rtu_oldrouter  /* for change's */
 
 #define        ROUTEHASHSIZ    19
 
 /*
  * "State" of routing table entry.
  */
 
 #define        ROUTEHASHSIZ    19
 
 /*
  * "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_PASSIVE     0x8             /* don't time out route */
-#define        RTS_DONTDELETE  0x10            /* don't remove route if timed out */
-#define        RTS_DONTROUTE   0x20            /* don't route outgoing packets */
-#define        RTS_HIDDEN      0x40            /* deleted but still reclaimable */
+#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();
 
 struct rthash nethash[ROUTEHASHSIZ], hosthash[ROUTEHASHSIZ];
 struct rt_entry *rtlookup(), *rtfind();
@@ -87,3 +154,67 @@ 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)
+
+#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))
+
+struct sockaddr_in routingaddr;
+struct sockaddr_in noroutingaddr;
+
+int    s;
+int    snoroute;               /* socket with no routing */
+int    kmem;
+int    supplier;               /* process should supply updates */
+int    install;                /* if 1 call kernel */
+int    lookforinterfaces;
+int    performnlist;
+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); \
+       }
+
+char   packet[MAXPACKETSIZE+1];
+struct rip *msg;
+
+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();
+
+int    sendmsg(), supply();
+int    timer(), cleanup();