umount -> unmount
[unix-history] / usr / src / sbin / routed / defs.h
index 9de9ffc..ecb81c0 100644 (file)
@@ -1,4 +1,4 @@
-/*     defs.h  4.5     82/05/31        */
+/*     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.
@@ -27,13 +99,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 +112,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,10 +124,10 @@ 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 rt_entry *rtlookup(), *rtfind();
 
 struct rthash nethash[ROUTEHASHSIZ], hosthash[ROUTEHASHSIZ];
 struct rt_entry *rtlookup(), *rtfind();
@@ -69,9 +139,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 +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();