📄 route.h
字号:
/* route.h - routing table *//* Copyright 2001-2005 Wind River Systems, Inc. *//* * Copyright (c) 1980, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)route.h 8.4 (Berkeley) 1/9/95 * $FreeBSD: src/sys/net/route.h,v 1.36.2.5 2002/02/01 11:48:01 ru Exp $ *//*modification history--------------------01z,19may05,rp added RTM_ADDRINFO01y,01mar05,niq Include in6.h01x,24feb05,spm removed unneeded route format storage (SPR #100995)01w,24feb05,spm performance updates and code cleanup (SPR #100995)01v,08feb05,vvv _KERNEL cleanup01u,17sep04,niq Scale out routing sockets01t,23aug04,rp merged from COMP_WN_IPV6_BASE6_ITER5_TO_UNIFIED_PRE_MERGE01s,28may04,niq Merging from base6 label POST_ITER5_FRZ16_REBASE (ver /main/vdt/base6_itn5_networking-int/2)01r,06dec03,niq Add the RTF_PRIMARY flag01q,24nov03,vvv updated for RTP support01p,20nov03,niq Remove copyright_wrs.h file inclusion01o,10nov03,cdw Rebase from base6 iteration 1 view01n,04nov03,rlm Ran batch header path update for header re-org.01m,03nov03,rlm Removed wrn/coreip/ prefix from #includes for header re-org.01l,27sep03,vvv moved RTFREE out of #ifdef _KERNEL01k,23sep03,asr Moved the #include <route/ipRouteLib.h> outside of #ifdef _KERNEL 01j,06aug03,niq Merge from Accordion into Base6 Iteration 1 branch01i,10jun03,vvv include netVersion.h01h,01feb03,pas merge from FreeBSD 4.7 - added rt_getifa(), rt_ifannouncemsg(), rtrequest1()01g,05sep02,hsh add cplusplus protection01f,16may02,ant field rmx_filler[4] in the struct rt_metrics expand to rmx_filler[5]. New definitions rt_mod and RTF_MGMT01e,11mar02,ham reverted previous checkin 01d01d,27feb02,nee extending the rt_metrics for rip01c,02feb02,ham changed for tornado build.01b,19dec01,nee Adding multipath capability01a,08sep01,qli 1st round of porting*/#ifndef _NET_ROUTE_H_#define _NET_ROUTE_H_#include <sys/socket.h>#ifdef __cplusplusextern "C" {#endif#include <netVersion.h>/* * Kernel resident routing tables. * * The routing tables are initialized when interface addresses * are set by making entries for all directly connected interfaces. *//* * 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. *//* * Following structure necessary for 4.3 compatibility; * We should eventually move it to a compat file. */struct ortentry { u_long ort_hash; /* to speed lookups */ struct sockaddr ort_dst; /* key */ struct sockaddr ort_gateway; /* value */ short ort_flags; /* up/down?, host/net */ short ort_refcnt; /* # held references */ u_long ort_use; /* raw # packets forwarded */ struct ifnet *ort_ifp; /* the answer: interface to use */};/* * These numbers are used by reliable protocols for determining * retransmission behavior and are included in the routing structure. */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 */ u_long rmx_recvpipe; /* inbound delay-bandwidth product */ u_long rmx_sendpipe; /* outbound delay-bandwidth product */ u_long rmx_ssthresh; /* outbound gateway buffer limit */ u_long rmx_rtt; /* estimated round trip time */ u_long rmx_rttvar; /* estimated rtt variance */ u_long rmx_pksent; /* packets sent using this route */ u_long rmx_filler[5]; /* will be used for T/TCP later */ /* the last field is used for storing of the last modification of the route */ /* Additional WRN metrics for routing protocols */ long value1; long value2; long value3; long value4; long value5; long routeTag; u_long weight;};/* RTM entry header - pointed to by RIB node */struct routeHdr { struct sockaddr * pDstAddr; /* Route destination */ struct sockaddr * pNetmask; /* Route netmask */ struct rtentry * pFirstRoute; /* Initial route entry (weight) */ struct rtentry * pFirstLexRoute; /* Initial route entry (SNMP) */ unsigned short routeHdrFlags; /* Route header flags */ UCHAR routeCount; /* Number of shared route entries */ };/* * Generic route entry to store route information. * The fields are layed out based on the cache locality consideration. * Please do not move them around merely for aesthetic purposes. */struct mbuf;struct rtentry { struct routeHdr * pRtmHdr; /* RTM header */ struct sockaddr * rt_gateway; /* Next-hop gateway */ struct rtentry * rt_gwroute; /* Pointer to gateway entry */ struct ifnet * rt_ifp; /* Which interface to use */ ULONG rt_flags; /* Route flags: Uses RTF_ values: */ long rt_refcnt; /* # of held references */ caddr_t rt_llinfo; /* pointer to link level info cache */ struct ifaddr * rt_ifa; /* Interface address */ struct rtentry * rt_parent; /* cloning parent of this route */ ULONG routeTos; /* Type-of-service information */ struct rt_metrics rt_rmx; /* Route metrics */ struct sockaddr * rt_genmask; /* For generation of cloned routes */ int (*rt_output) (struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); /* output routine for this (rt,if) */ void * rt_filler2; /* more filler */ struct rtentry * pNextRoute; /* Additional route entry (weight) */ struct rtentry * pNextLexRoute; /* Additional route entry (SNMP) */ void * pRibNode; /* Pointer to RIB node */ ULONG routeOwner; /* Route ownership information */ ULONG rtmFlags; /* Proxy ARP entry or not. See below */ /* for the values */ };#define rt_use rt_rmx.rmx_pksent#define rt_mod rt_rmx.rmx_filler[4]/* * The following macros SHOULD be used to access the fields of the rtentry * structures. Directly accessing fields might not be portable */#define rt_key(r) ((r)->pRtmHdr->pDstAddr)#define rt_mask(r) ((r)->pRtmHdr->pNetmask)/* * This constant defines the weight for every interface route installed by * the system. This value should be the lowest possible weight so that the * system interface route is always preferred over any other interface routes * which a routing protocol may create. This priority is necessary since * the system's interface route generates all ARP/ND entries through cloning, * so it must be the first entry in the weighted list if duplicates exist. * Without this value, the system route is often still the first entry in the * list since the RIP interface routes (and any others) are added with the * the default weight value. However, if any routing protocols install routes * with a weight lower than the default, then the system's interface route * would no longer be first, so it is assigned the lowest possible weight. */#define INTERFACE_ROUTE_WEIGHT 1/* * macros for getting and setting tos values in sockaddr_in * structures. A new sockaddr structure is defined for this * purpose as shown below. */struct sockaddr_rt { u_char srt_len; u_char srt_family; u_char srt_proto; u_char srt_tos; ULONG srt_addr; char sin_zero[8]; };#define TOS_GET(pSockaddr) (((struct sockaddr_rt *)(pSockaddr))->srt_tos)#define TOS_SET(pSockaddr, tosVal) \ (((struct sockaddr_rt *)(pSockaddr))->srt_tos = tosVal)#define RT_PROTO_GET(pSockaddr) (((struct sockaddr_rt *)(pSockaddr))->srt_proto)#define RT_PROTO_SET(pSockaddr, proto) \ (((struct sockaddr_rt *)(pSockaddr))->srt_proto = proto)/* * Set the route tos and proto from the route in the provided dst address * Saves the original Tos and Proto value if pointers are provided */#define SET_TOS_AND_PROTO(dst, rt) \ do { \ TOS_SET (dst, ROUTE_TOS (rt)); \ RT_PROTO_SET (dst, ROUTE_PROTO (rt)); \ } while (0)/* * Reset the original route tos and proto values in the route's dst address */#define RESET_TOS_AND_PROTO(dst) \ do { \ TOS_SET (dst, 0); \ RT_PROTO_SET (dst, 0); \ } while (0)/* * 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;};#ifdef ROUTER_STACK/* * This expanded "gateway" structure contains the address of the next-hop * router and all the new metrics for a route, as well as the protocol * identifier which created it. The RTM_GETALL routing socket message * contains a list of these structures. * * NOTE: don't change the position of the gate_addr field. It is designed to * overlay the sockaddr_in(6) structures. */struct sockaddr_gate {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -