]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/route.h
xnu-792.tar.gz
[apple/xnu.git] / bsd / net / route.h
index e4c06e50aefcd727f182b4c302edc3d474b1b4bd..5d1ab8ab266e25b0d696493d8e1e38bb79c2a5ad 100644 (file)
  * 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>
+#include <sys/types.h>
+#include <sys/socket.h>
 
 /*
  * Kernel resident routing tables.
  * to a routing entry.  These are often held by protocols
  * in their control blocks, e.g. inpcb.
  */
+#ifdef PRIVATE
+struct  rtentry;
 struct route {
        struct  rtentry *ro_rt;
        struct  sockaddr ro_dst;
        u_long  reserved[2];    /* for future use if needed */
 };
+#else
+struct route;
+#endif /* PRIVATE */
 
 /*
  * These numbers are used by reliable protocols for determining
@@ -83,7 +92,7 @@ struct rt_metrics {
        u_long  rmx_locks;      /* Kernel must leave these values alone */
        u_long  rmx_mtu;        /* MTU for this path */
        u_long  rmx_hopcount;   /* max hops expected */
-       u_long  rmx_expire;     /* lifetime for route, e.g. redirect */
+       int32_t rmx_expire;     /* lifetime for route, e.g. redirect */
        u_long  rmx_recvpipe;   /* inbound delay-bandwidth product */
        u_long  rmx_sendpipe;   /* outbound delay-bandwidth product */
        u_long  rmx_ssthresh;   /* outbound gateway buffer limit */
@@ -104,7 +113,6 @@ struct rt_metrics {
 /*
  * XXX kernel function pointer `rt_output' is visible to applications.
  */
-struct mbuf;
 
 /*
  * We distinguish between routes to hosts and routes to networks,
@@ -114,6 +122,7 @@ struct mbuf;
  * gateways are marked so that the output routines know to address the
  * gateway rather than the ultimate destination.
  */
+#ifdef PRIVATE
 #ifndef RNF_NORMAL
 #include <net/radix.h>
 #endif
@@ -122,8 +131,7 @@ struct rtentry {
 #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 */
@@ -132,13 +140,15 @@ struct rtentry {
        caddr_t rt_llinfo;              /* pointer to link level info cache */
        struct  rt_metrics rt_rmx;      /* metrics used by rx'ing protocols */
        struct  rtentry *rt_gwroute;    /* implied entry for gatewayed routes */
-       int     (*rt_output) __P((struct ifnet *, struct mbuf *,
-                                 struct sockaddr *, struct rtentry *));
+       int     (*rt_output)(struct ifnet *, struct mbuf *,
+                                 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 /* PRIVATE */
 
+#ifdef __APPLE_API_OBSOLETE
 /*
  * Following structure necessary for 4.3 compatibility;
  * We should eventually move it to a compat file.
@@ -152,8 +162,11 @@ struct ortentry {
        u_long  rt_use;                 /* raw # packets forwarded */
        struct  ifnet *rt_ifp;          /* the answer: interface to use */
 };
+#endif /* __APPLE_API_OBSOLETE */
 
+#ifdef PRIVATE
 #define rt_use rt_rmx.rmx_pksent
+#endif /* PRIVATE */
 
 #define        RTF_UP          0x1             /* route usable */
 #define        RTF_GATEWAY     0x2             /* destination is a gateway */
@@ -162,7 +175,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) */
@@ -174,7 +187,7 @@ struct ortentry {
 #define RTF_PRCLONING  0x10000         /* protocol requires cloning */
 #define RTF_WASCLONED  0x20000         /* route generated through cloning */
 #define RTF_PROTO3     0x40000         /* protocol specific routing flag */
-/*                     0x80000            unused */
+                                       /* 0x80000 unused */
 #define RTF_PINNED     0x100000        /* future use */
 #define        RTF_LOCAL       0x200000        /* route represents a local address */
 #define        RTF_BROADCAST   0x400000        /* route represents a bcast address */
@@ -191,6 +204,7 @@ struct      rtstat {
        short   rts_unreach;            /* lookups which failed */
        short   rts_wildcard;           /* lookups satisfied by a wildcard */
 };
+
 /*
  * Structures for routing messages.
  */
@@ -201,14 +215,30 @@ struct rt_msghdr {
        u_short rtm_index;      /* index for associated ifp */
        int     rtm_flags;      /* flags, incl. kern & message, e.g. DONE */
        int     rtm_addrs;      /* bitmask identifying sockaddrs in msg */
-       pid_t   rtm_pid;        /* identify sender */
-       int     rtm_seq;        /* for sender to identify action */
-       int     rtm_errno;      /* why failed */
+       pid_t   rtm_pid;        /* identify sender */
+       int     rtm_seq;        /* for sender to identify action */
+       int     rtm_errno;      /* why failed */
        int     rtm_use;        /* from rtentry */
        u_long  rtm_inits;      /* which metrics we are initializing */
        struct  rt_metrics rtm_rmx; /* metrics themselves */
 };
 
+struct rt_msghdr2 {
+        u_short rtm_msglen;     /* to skip over non-understood messages */
+        u_char  rtm_version;    /* future binary compatibility */
+        u_char  rtm_type;       /* message type */
+        u_short rtm_index;      /* index for associated ifp */
+        int     rtm_flags;      /* flags, incl. kern & message, e.g. DONE */
+        int     rtm_addrs;      /* bitmask identifying sockaddrs in msg */
+       int32_t rtm_refcnt;         /* reference count */
+       int     rtm_parentflags;      /* flags of the parent route */
+        int     rtm_reserved;      /* reserved field set to 0 */
+        int     rtm_use;        /* from rtentry */
+        u_long  rtm_inits;      /* which metrics we are initializing */
+        struct  rt_metrics rtm_rmx; /* metrics themselves */
+};
+
+
 #define RTM_VERSION    5       /* Up the ante and ignore older versions */
 
 /*
@@ -230,6 +260,12 @@ 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 PRIVATE
+#define RTM_GET_SILENT 0x11
+#endif PRIVATE
+#define RTM_IFINFO2    0x12    /* */
+#define RTM_NEWMADDR2  0x13    /* */
+#define RTM_GET2       0x14    /* */
 
 /*
  * Bitmask values for rtm_inits and rmx_locks.
@@ -282,41 +318,45 @@ struct route_cb {
        int     any_count;
 };
 
-#ifdef KERNEL
-#define        RTFREE(rt) \
-       if ((rt)->rt_refcnt <= 1) \
-               rtfree(rt); \
-       else \
-               (rt)->rt_refcnt--;
-#define RTHOLD(rt) {                    \
-        if (++(rt)->rt_refcnt <= 0)    \
-                panic("RTHOLD");       \
-}
-
+#ifdef KERNEL_PRIVATE
+#define RTFREE(rt)     rtfree(rt)
 extern struct route_cb route_cb;
 extern struct radix_node_head *rt_tables[AF_MAX+1];
 
 struct ifmultiaddr;
 struct proc;
 
-void    route_init __P((void));
-void    rt_ifmsg __P((struct ifnet *));
-void    rt_missmsg __P((int, struct rt_addrinfo *, int, int));
-void    rt_newaddrmsg __P((int, struct ifaddr *, int, struct rtentry *));
-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    route_init(void);
+void    rt_ifmsg(struct ifnet *);
+void    rt_missmsg(int, struct rt_addrinfo *, int, int);
+void    rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
+void    rt_newmaddrmsg(int, struct ifmultiaddr *);
+int     rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *);
+void    rtalloc(struct route *);
+void    rtalloc_ign(struct route *, u_long);
 struct rtentry *
-        rtalloc1 __P((struct sockaddr *, int, unsigned long));
-void    rtfree __P((struct rtentry *));
-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
+        rtalloc1(struct sockaddr *, int, u_long);
+struct rtentry *
+        rtalloc1_locked(const struct sockaddr *, int, u_long);
+void   rtfree(struct rtentry *);
+void   rtfree_locked(struct rtentry *);
+void   rtref(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(struct rtentry *);
+void   rtsetifa(struct rtentry *, struct ifaddr *);
+int     rtinit(struct ifaddr *, int, int);
+int     rtinit_locked(struct ifaddr *, int, int);
+int     rtioctl(int, caddr_t, struct proc *);
+void    rtredirect(struct sockaddr *, struct sockaddr *,
+           struct sockaddr *, int, struct sockaddr *, struct rtentry **);
+int     rtrequest(int, struct sockaddr *,
+           struct sockaddr *, struct sockaddr *, int, struct rtentry **);
+int     rtrequest_locked(int, struct sockaddr *,
+           struct sockaddr *, struct sockaddr *, int, struct rtentry **);
+#endif KERNEL_PRIVATE
 
 #endif