]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/route.h
xnu-517.tar.gz
[apple/xnu.git] / bsd / net / route.h
index 0e2c09f912a4e2188ac5387874e0b43841b39f9e..2cc379b55dbafa27b5b37ed26b8257bf234bde65 100644 (file)
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
  * SUCH DAMAGE.
  *
  *     @(#)route.h     8.3 (Berkeley) 4/19/94
+ * $FreeBSD: src/sys/net/route.h,v 1.36.2.1 2000/08/16 06:14:23 jayanth Exp $
  */
 
 #ifndef _NET_ROUTE_H_
 #define _NET_ROUTE_H_
+#include <sys/appleapiopts.h>
 
 /*
  * Kernel resident routing tables.
  * to a routing entry.  These are often held by protocols
  * in their control blocks, e.g. inpcb.
  */
+#if !defined(KERNEL) || defined(__APPLE_API_PRIVATE)
 struct route {
        struct  rtentry *ro_rt;
        struct  sockaddr ro_dst;
+       u_long  reserved[2];    /* for future use if needed */
 };
+#else
+struct route;
+#endif
 
 /*
  * These numbers are used by reliable protocols for determining
@@ -116,13 +126,13 @@ struct mbuf;
 #ifndef RNF_NORMAL
 #include <net/radix.h>
 #endif
+#ifdef __APPLE_API_UNSTABLE
 struct rtentry {
        struct  radix_node rt_nodes[2]; /* tree glue, and other values */
 #define        rt_key(r)       ((struct sockaddr *)((r)->rt_nodes->rn_key))
 #define        rt_mask(r)      ((struct sockaddr *)((r)->rt_nodes->rn_mask))
        struct  sockaddr *rt_gateway;   /* value */
-       short   rt_filler;              /* was short flags field */
-       short   rt_refcnt;              /* # held references */
+       int32_t rt_refcnt;              /* # held references */
        u_long  rt_flags;               /* up/down?, host/net */
        struct  ifnet *rt_ifp;          /* the answer: interface to use */
         u_long  rt_dlt;                        /* DLIL dl_tag */
@@ -135,8 +145,9 @@ struct rtentry {
                                  struct sockaddr *, struct rtentry *));
                                        /* output routine for this (rt,if) */
        struct  rtentry *rt_parent;     /* cloning parent of this route */
-       void    *rt_filler2;            /* more filler */
+       u_long  generation_id;          /* route generation id */
 };
+#endif /* __APPLE_API_UNSTABLE */
 
 /*
  * Following structure necessary for 4.3 compatibility;
@@ -161,7 +172,7 @@ struct ortentry {
 #define        RTF_DYNAMIC     0x10            /* created dynamically (by redirect) */
 #define        RTF_MODIFIED    0x20            /* modified dynamically (by redirect) */
 #define RTF_DONE       0x40            /* message confirmed */
-/*                     0x80               unused */
+#define RTF_DELCLONE   0x80            /* delete cloned route */
 #define RTF_CLONING    0x100           /* generate new routes on use */
 #define RTF_XRESOLVE   0x200           /* external daemon resolves name */
 #define RTF_LLINFO     0x400           /* generated by link layer (e.g. ARP) */
@@ -229,6 +240,9 @@ struct rt_msghdr {
 #define RTM_IFINFO     0xe     /* iface going up/down etc. */
 #define        RTM_NEWMADDR    0xf     /* mcast group membership being added to if */
 #define        RTM_DELMADDR    0x10    /* mcast group membership being deleted */
+#ifdef KERNEL_PRIVATE
+#define RTM_GET_SILENT 0x11
+#endif
 
 /*
  * Bitmask values for rtm_inits and rmx_locks.
@@ -282,16 +296,19 @@ struct route_cb {
 };
 
 #ifdef KERNEL
+#ifndef __APPLE__
 #define        RTFREE(rt) \
-       if ((rt)->rt_refcnt <= 1) \
-               rtfree(rt); \
-       else \
-               (rt)->rt_refcnt--;
-#define RTHOLD(rt) {                    \
-        if (++(rt)->rt_refcnt <= 0)    \
-                panic("RTHOLD");       \
-}
+       do { \
+               if ((rt)->rt_refcnt <= 1) \
+                       rtfree(rt); \
+               else \
+                       (rt)->rt_refcnt--; \
+       } while (0)
+#else
+#define RTFREE(rt)     rtfree(rt)
+#endif
 
+#ifdef __APPLE_API_PRIVATE
 extern struct route_cb route_cb;
 extern struct radix_node_head *rt_tables[AF_MAX+1];
 
@@ -306,16 +323,25 @@ void       rt_newmaddrmsg __P((int, struct ifmultiaddr *));
 int     rt_setgate __P((struct rtentry *,
            struct sockaddr *, struct sockaddr *));
 void    rtalloc __P((struct route *));
-void    rtalloc_ign __P((struct route *, unsigned long));
+void    rtalloc_ign __P((struct route *, u_long));
 struct rtentry *
-        rtalloc1 __P((struct sockaddr *, int, unsigned long));
-void    rtfree __P((struct rtentry *));
+        rtalloc1 __P((struct sockaddr *, int, u_long));
+void   rtfree __P((struct rtentry *));
+void   rtref __P((struct rtentry *));
+/*
+ * rtunref will decrement the refcount, rtfree will decrement and free if
+ * the refcount has reached zero and the route is not up.
+ * Unless you have good reason to do otherwise, use rtfree.
+ */
+void   rtunref __P((struct rtentry *));
+void   rtsetifa __P((struct rtentry *, struct ifaddr *));
 int     rtinit __P((struct ifaddr *, int, int));
 int     rtioctl __P((int, caddr_t, struct proc *));
 void    rtredirect __P((struct sockaddr *, struct sockaddr *,
            struct sockaddr *, int, struct sockaddr *, struct rtentry **));
 int     rtrequest __P((int, struct sockaddr *,
            struct sockaddr *, struct sockaddr *, int, struct rtentry **));
+#endif /* __APPLE_API_PRIVATE */
 #endif
 
 #endif