+++ /dev/null
-/*\r
- * Copyright (c) 1980, 1986, 1993\r
- * The Regents of the University of California. All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- * 3. All advertising materials mentioning features or use of this software\r
- * must display the following acknowledgement:\r
- * This product includes software developed by the University of\r
- * California, Berkeley and its contributors.\r
- * 4. Neither the name of the University nor the names of its contributors\r
- * may be used to endorse or promote products derived from this software\r
- * without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- *\r
- * @(#)route.h 8.3 (Berkeley) 4/19/94\r
- * $Id: route.h,v 1.1.1.1 2006/05/30 06:12:46 hhzhou Exp $\r
- */\r
-\r
-#ifndef _NET_ROUTE_H_\r
-#define _NET_ROUTE_H_\r
-\r
-#define __P(protos) protos /* full-blown ANSI C */\r
-\r
-\r
-/*\r
- * Kernel resident routing tables.\r
- *\r
- * The routing tables are initialized when interface addresses\r
- * are set by making entries for all directly connected interfaces.\r
- */\r
-\r
-/*\r
- * A route consists of a destination address and a reference\r
- * to a routing entry. These are often held by protocols\r
- * in their control blocks, e.g. inpcb.\r
- */\r
-struct route {\r
- struct rtentry *ro_rt;\r
- struct sockaddr ro_dst;\r
-};\r
-\r
-/*\r
- * These numbers are used by reliable protocols for determining\r
- * retransmission behavior and are included in the routing structure.\r
- */\r
-struct rt_metrics {\r
- u_long rmx_locks; /* Kernel must leave these values alone */\r
- u_long rmx_mtu; /* MTU for this path */\r
- u_long rmx_hopcount; /* max hops expected */\r
- u_long rmx_expire; /* lifetime for route, e.g. redirect */\r
- u_long rmx_recvpipe; /* inbound delay-bandwidth product */\r
- u_long rmx_sendpipe; /* outbound delay-bandwidth product */\r
- u_long rmx_ssthresh; /* outbound gateway buffer limit */\r
- u_long rmx_rtt; /* estimated round trip time */\r
- u_long rmx_rttvar; /* estimated rtt variance */\r
- u_long rmx_pksent; /* packets sent using this route */\r
- u_long rmx_filler[4]; /* will be used for T/TCP later */\r
-};\r
-\r
-/*\r
- * rmx_rtt and rmx_rttvar are stored as microseconds;\r
- * RTTTOPRHZ(rtt) converts to a value suitable for use\r
- * by a protocol slowtimo counter.\r
- */\r
-#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */\r
-#define RTTTOPRHZ(r) ((r) / (RTM_RTTUNIT / PR_SLOWHZ))\r
-\r
-/*\r
- * XXX kernel function pointer `rt_output' is visible to applications.\r
- */\r
-struct mbuf;\r
-\r
-/*\r
- * We distinguish between routes to hosts and routes to networks,\r
- * preferring the former if available. For each route we infer\r
- * the interface to use from the gateway address supplied when\r
- * the route was entered. Routes that forward packets through\r
- * gateways are marked so that the output routines know to address the\r
- * gateway rather than the ultimate destination.\r
- */\r
-#ifndef RNF_NORMAL\r
-#include <net/radix.h>\r
-#endif\r
-struct rtentry {\r
- struct radix_node rt_nodes[2]; /* tree glue, and other values */\r
-#define rt_key(r) ((struct sockaddr *)((r)->rt_nodes->rn_key))\r
-#define rt_mask(r) ((struct sockaddr *)((r)->rt_nodes->rn_mask))\r
- struct sockaddr *rt_gateway; /* value */\r
- short rt_filler; /* was short flags field */\r
- short rt_refcnt; /* # held references */\r
- u_long rt_flags; /* up/down?, host/net */\r
- struct ifnet *rt_ifp; /* the answer: interface to use */\r
- struct ifaddr *rt_ifa; /* the answer: interface to use */\r
- struct sockaddr *rt_genmask; /* for generation of cloned routes */\r
- caddr_t rt_llinfo; /* pointer to link level info cache */\r
- struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */\r
- struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */\r
- int (*rt_output) __P((struct ifnet *, struct mbuf *,\r
- struct sockaddr *, struct rtentry *));\r
- /* output routine for this (rt,if) */\r
- struct rtentry *rt_parent; /* cloning parent of this route */\r
- void *rt_filler2; /* more filler */\r
-};\r
-\r
-/*\r
- * Following structure necessary for 4.3 compatibility;\r
- * We should eventually move it to a compat file.\r
- */\r
-struct ortentry {\r
- u_long rt_hash; /* to speed lookups */\r
- struct sockaddr rt_dst; /* key */\r
- struct sockaddr rt_gateway; /* value */\r
- short rt_flags; /* up/down?, host/net */\r
- short rt_refcnt; /* # held references */\r
- u_long rt_use; /* raw # packets forwarded */\r
- struct ifnet *rt_ifp; /* the answer: interface to use */\r
-};\r
-\r
-#define rt_use rt_rmx.rmx_pksent\r
-\r
-#define RTF_UP 0x1 /* route usable */\r
-#define RTF_GATEWAY 0x2 /* destination is a gateway */\r
-#define RTF_HOST 0x4 /* host entry (net otherwise) */\r
-#define RTF_REJECT 0x8 /* host or net unreachable */\r
-#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */\r
-#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */\r
-#define RTF_DONE 0x40 /* message confirmed */\r
-/* 0x80 unused */\r
-#define RTF_CLONING 0x100 /* generate new routes on use */\r
-#define RTF_XRESOLVE 0x200 /* external daemon resolves name */\r
-#define RTF_LLINFO 0x400 /* generated by link layer (e.g. ARP) */\r
-#define RTF_STATIC 0x800 /* manually added */\r
-#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */\r
-#define RTF_PROTO2 0x4000 /* protocol specific routing flag */\r
-#define RTF_PROTO1 0x8000 /* protocol specific routing flag */\r
-\r
-#define RTF_PRCLONING 0x10000 /* protocol requires cloning */\r
-#define RTF_WASCLONED 0x20000 /* route generated through cloning */\r
-#define RTF_PROTO3 0x40000 /* protocol specific routing flag */\r
-/* 0x80000 unused */\r
-#define RTF_PINNED 0x100000 /* future use */\r
-#define RTF_LOCAL 0x200000 /* route represents a local address */\r
-#define RTF_BROADCAST 0x400000 /* route represents a bcast address */\r
-#define RTF_MULTICAST 0x800000 /* route represents a mcast address */\r
- /* 0x1000000 and up unassigned */\r
-\r
-/*\r
- * Routing statistics.\r
- */\r
-struct rtstat {\r
- short rts_badredirect; /* bogus redirect calls */\r
- short rts_dynamic; /* routes created by redirects */\r
- short rts_newgateway; /* routes modified by redirects */\r
- short rts_unreach; /* lookups which failed */\r
- short rts_wildcard; /* lookups satisfied by a wildcard */\r
-};\r
-/*\r
- * Structures for routing messages.\r
- */\r
-struct rt_msghdr {\r
- u_short rtm_msglen; /* to skip over non-understood messages */\r
- u_char rtm_version; /* future binary compatibility */\r
- u_char rtm_type; /* message type */\r
- u_short rtm_index; /* index for associated ifp */\r
- int rtm_flags; /* flags, incl. kern & message, e.g. DONE */\r
- int rtm_addrs; /* bitmask identifying sockaddrs in msg */\r
- pid_t rtm_pid; /* identify sender */\r
- int rtm_seq; /* for sender to identify action */\r
- int rtm_errno; /* why failed */\r
- int rtm_use; /* from rtentry */\r
- u_long rtm_inits; /* which metrics we are initializing */\r
- struct rt_metrics rtm_rmx; /* metrics themselves */\r
-};\r
-\r
-#define RTM_VERSION 5 /* Up the ante and ignore older versions */\r
-\r
-#define RTM_ADD 0x1 /* Add Route */\r
-#define RTM_DELETE 0x2 /* Delete Route */\r
-#define RTM_CHANGE 0x3 /* Change Metrics or flags */\r
-#define RTM_GET 0x4 /* Report Metrics */\r
-#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */\r
-#define RTM_REDIRECT 0x6 /* Told to use different route */\r
-#define RTM_MISS 0x7 /* Lookup failed on this address */\r
-#define RTM_LOCK 0x8 /* fix specified metrics */\r
-#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */\r
-#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */\r
-#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */\r
-#define RTM_NEWADDR 0xc /* address being added to iface */\r
-#define RTM_DELADDR 0xd /* address being removed from iface */\r
-#define RTM_IFINFO 0xe /* iface going up/down etc. */\r
-#define RTM_NEWMADDR 0xf /* mcast group membership being added to if */\r
-#define RTM_DELMADDR 0x10 /* mcast group membership being deleted */\r
-\r
-#define RTV_MTU 0x1 /* init or lock _mtu */\r
-#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */\r
-#define RTV_EXPIRE 0x4 /* init or lock _hopcount */\r
-#define RTV_RPIPE 0x8 /* init or lock _recvpipe */\r
-#define RTV_SPIPE 0x10 /* init or lock _sendpipe */\r
-#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */\r
-#define RTV_RTT 0x40 /* init or lock _rtt */\r
-#define RTV_RTTVAR 0x80 /* init or lock _rttvar */\r
-\r
-/*\r
- * Bitmask values for rtm_addr.\r
- */\r
-#define RTA_DST 0x1 /* destination sockaddr present */\r
-#define RTA_GATEWAY 0x2 /* gateway sockaddr present */\r
-#define RTA_NETMASK 0x4 /* netmask sockaddr present */\r
-#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */\r
-#define RTA_IFP 0x10 /* interface name sockaddr present */\r
-#define RTA_IFA 0x20 /* interface addr sockaddr present */\r
-#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */\r
-#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */\r
-\r
-/*\r
- * Index offsets for sockaddr array for alternate internal encoding.\r
- */\r
-#define RTAX_DST 0 /* destination sockaddr present */\r
-#define RTAX_GATEWAY 1 /* gateway sockaddr present */\r
-#define RTAX_NETMASK 2 /* netmask sockaddr present */\r
-#define RTAX_GENMASK 3 /* cloning mask sockaddr present */\r
-#define RTAX_IFP 4 /* interface name sockaddr present */\r
-#define RTAX_IFA 5 /* interface addr sockaddr present */\r
-#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */\r
-#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */\r
-#define RTAX_MAX 8 /* size of array to allocate */\r
-\r
-struct rt_addrinfo {\r
- int rti_addrs;\r
- struct sockaddr *rti_info[RTAX_MAX];\r
-};\r
-\r
-struct route_cb {\r
- int ip_count;\r
- int ipx_count;\r
- int ns_count;\r
- int iso_count;\r
- int any_count;\r
-};\r
-\r
-#ifdef KERNEL\r
-#define RTFREE(rt) \\r
- if ((rt)->rt_refcnt <= 1) \\r
- rtfree(rt); \\r
- else \\r
- (rt)->rt_refcnt--;\r
-\r
-extern struct route_cb route_cb;\r
-extern struct radix_node_head *rt_tables[AF_MAX+1];\r
-\r
-struct ifmultiaddr;\r
-struct proc;\r
-\r
-void route_init __P((void));\r
-void rt_ifmsg __P((struct ifnet *));\r
-void rt_missmsg __P((int, struct rt_addrinfo *, int, int));\r
-void rt_newaddrmsg __P((int, struct ifaddr *, int, struct rtentry *));\r
-void rt_newmaddrmsg __P((int, struct ifmultiaddr *));\r
-int rt_setgate __P((struct rtentry *,\r
- struct sockaddr *, struct sockaddr *));\r
-void rtalloc __P((struct route *));\r
-void rtalloc_ign __P((struct route *, unsigned long));\r
-struct rtentry *\r
- rtalloc1 __P((struct sockaddr *, int, unsigned long));\r
-void rtfree __P((struct rtentry *));\r
-int rtinit __P((struct ifaddr *, int, int));\r
-int rtioctl __P((int, caddr_t, struct proc *));\r
-void rtredirect __P((struct sockaddr *, struct sockaddr *,\r
- struct sockaddr *, int, struct sockaddr *, struct rtentry **));\r
-int rtrequest __P((int, struct sockaddr *,\r
- struct sockaddr *, struct sockaddr *, int, struct rtentry **));\r
-#endif\r
-\r
-#endif\r