use socket DONTROUTE flag instead of that in rcb_flags
[unix-history] / usr / src / sys / net / route.h
index 44034b3..e99c847 100644 (file)
@@ -1,46 +1,81 @@
-/*     route.h 4.2     82/03/28        */
-
 /*
 /*
- * Structure of kernel resident routing
- * data base.  Assumption is user routing
- * daemon maintains this data base based
- * on routing information it gleans from
- * gateway protocols it listens to (e.g. GGP).
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
  *
  *
- * TO ADD:
- *     more statistics -- smooth usage figures
+ *     @(#)route.h     6.7 (Berkeley) %G%
  */
  */
-struct rtentry {
-       u_long  rt_key;                 /* lookup key */
-       struct  sockaddr rt_dst;        /* match value */
-       struct  sockaddr rt_gateway;    /* who to forward to */
-       short   rt_flags;               /* see below */
-       short   rt_refcnt;              /* # held references */
-       u_long  rt_use;                 /* raw # packets forwarded */
-       struct  ifnet *rt_ifp;          /* interface to use */
-};
 
 
+/*
+ * Kernel resident routing tables.
+ * 
+ * The routing tables are initialized when interface addresses
+ * are set by making entries for all directly connected interfaces.
+ */
+
+/*
+ * A route consists of a destination address and a reference
+ * to a routing entry.  These are often held by protocols
+ * in their control blocks, e.g. inpcb.
+ */
 struct route {
        struct  rtentry *ro_rt;
        struct  sockaddr ro_dst;
 struct route {
        struct  rtentry *ro_rt;
        struct  sockaddr ro_dst;
-       caddr_t ro_pcb;                 /* back pointer? */
 };
 
 /*
 };
 
 /*
- * Flags and host/network status.
+ * We distinguish between routes to hosts and routes to networks,
+ * preferring the former if available.  For each route we infer
+ * the interface to use from the gateway address supplied when
+ * the route was entered.  Routes that forward packets through
+ * gateways are marked so that the output routines know to address the
+ * gateway rather than the ultimate destination.
  */
  */
+struct rtentry {
+       u_long  rt_hash;                /* to speed lookups */
+       struct  sockaddr rt_dst;        /* key */
+       struct  sockaddr rt_gateway;    /* value */
+       short   rt_flags;               /* up/down?, host/net */
+       short   rt_refcnt;              /* # held references */
+       u_long  rt_use;                 /* raw # packets forwarded */
+       struct  ifnet *rt_ifp;          /* the answer: interface to use */
+};
+
 #define        RTF_UP          0x1             /* route useable */
 #define        RTF_UP          0x1             /* route useable */
-#define        RTF_MUNGE       0x2             /* munge packet src address */
+#define        RTF_GATEWAY     0x2             /* destination is a gateway */
+#define        RTF_HOST        0x4             /* host entry (net otherwise) */
+#define RTF_REINSTATE  0x8             /* re-instate route after timeout */
+#define        RTF_DYNAMIC     0x10            /* created dynamically (by redirect) */
 
 
-#ifdef KERNEL
 /*
 /*
- * Lookup are hashed by a key.  Each hash bucket
- * consists of a linked list of mbuf's
- * containing routing entries.  Dead entries are
- * reclaimed along with mbufs.
+ * Routing statistics.
  */
  */
-#define        RTHASHSIZ       16
-struct mbuf *routehash[RTHASHSIZ];
+struct rtstat {
+       short   rts_badredirect;        /* bogus redirect calls */
+       short   rts_dynamic;            /* routes created by redirects */
+       short   rts_newgateway;         /* routes modified by redirects */
+       short   rts_unreach;            /* lookups which failed */
+       short   rts_wildcard;           /* lookups satisfied by a wildcard */
+};
+
+#ifdef KERNEL
+#define        RTFREE(rt) \
+       if ((rt)->rt_refcnt == 1) \
+               rtfree(rt); \
+       else \
+               (rt)->rt_refcnt--;
 
 
-struct rtentry *reroute();
+#ifdef GATEWAY
+#define        RTHASHSIZ       64
+#else
+#define        RTHASHSIZ       8
+#endif
+#if    (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
+#define RTHASHMOD(h)   ((h) & (RTHASHSIZ - 1))
+#else
+#define RTHASHMOD(h)   ((h) % RTHASHSIZ)
+#endif
+struct mbuf *rthost[RTHASHSIZ];
+struct mbuf *rtnet[RTHASHSIZ];
+struct rtstat  rtstat;
 #endif
 #endif