10Sstevel@tonic-gate /* 2*12748SSowmini.Varadhan@oracle.COM * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. 30Sstevel@tonic-gate */ 40Sstevel@tonic-gate /* 50Sstevel@tonic-gate * Copyright (c) 1980, 1986, 1993 60Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 90Sstevel@tonic-gate * modification, are permitted provided that the following conditions 100Sstevel@tonic-gate * are met: 110Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 120Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 130Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 140Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 150Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 160Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 170Sstevel@tonic-gate * must display the following acknowledgement: 180Sstevel@tonic-gate * This product includes software developed by the University of 190Sstevel@tonic-gate * California, Berkeley and its contributors. 200Sstevel@tonic-gate * 4. Neither the name of the University nor the names of its contributors 210Sstevel@tonic-gate * may be used to endorse or promote products derived from this software 220Sstevel@tonic-gate * without specific prior written permission. 230Sstevel@tonic-gate * 240Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 250Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 260Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 270Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 280Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 290Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 300Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 310Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 320Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 330Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 340Sstevel@tonic-gate * SUCH DAMAGE. 350Sstevel@tonic-gate */ 360Sstevel@tonic-gate 370Sstevel@tonic-gate /* 380Sstevel@tonic-gate * Kernel resident routing tables. 390Sstevel@tonic-gate * 400Sstevel@tonic-gate * The routing tables are initialized when interface addresses 410Sstevel@tonic-gate * are set by making entries for all directly connected interfaces. 420Sstevel@tonic-gate */ 430Sstevel@tonic-gate 440Sstevel@tonic-gate #ifndef _NET_ROUTE_H 450Sstevel@tonic-gate #define _NET_ROUTE_H 460Sstevel@tonic-gate 470Sstevel@tonic-gate /* from UCB 8.5 (Berkeley) 2/8/95 */ 480Sstevel@tonic-gate 491676Sjpk #include <sys/tsol/label.h> 501676Sjpk #include <sys/tsol/label_macro.h> 511676Sjpk 520Sstevel@tonic-gate #ifdef __cplusplus 530Sstevel@tonic-gate extern "C" { 540Sstevel@tonic-gate #endif 550Sstevel@tonic-gate 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * A route consists of a destination address and a reference 580Sstevel@tonic-gate * to a routing entry. These are often held by protocols 590Sstevel@tonic-gate * in their control blocks, e.g. inpcb. 600Sstevel@tonic-gate */ 610Sstevel@tonic-gate struct route { 620Sstevel@tonic-gate struct rtentry *ro_rt; 630Sstevel@tonic-gate struct sockaddr ro_dst; 640Sstevel@tonic-gate }; 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * These numbers are used by reliable protocols for determining 680Sstevel@tonic-gate * retransmission behavior and are included in the routing structure. 690Sstevel@tonic-gate * 700Sstevel@tonic-gate * rmx_rtt and rmx_rttvar are stored as microseconds; 710Sstevel@tonic-gate */ 720Sstevel@tonic-gate typedef struct rt_metrics { 730Sstevel@tonic-gate uint32_t rmx_locks; /* Kernel must leave these values */ 740Sstevel@tonic-gate /* alone */ 750Sstevel@tonic-gate uint32_t rmx_mtu; /* MTU for this path */ 760Sstevel@tonic-gate uint32_t rmx_hopcount; /* max hops expected */ 770Sstevel@tonic-gate uint32_t rmx_expire; /* lifetime for route, e.g. redirect */ 780Sstevel@tonic-gate uint32_t rmx_recvpipe; /* inbound delay-bandwith product */ 790Sstevel@tonic-gate uint32_t rmx_sendpipe; /* outbound delay-bandwith product */ 800Sstevel@tonic-gate uint32_t rmx_ssthresh; /* outbound gateway buffer limit */ 810Sstevel@tonic-gate uint32_t rmx_rtt; /* estimated round trip time */ 820Sstevel@tonic-gate uint32_t rmx_rttvar; /* estimated rtt variance */ 830Sstevel@tonic-gate uint32_t rmx_pksent; /* packets sent using this route */ 840Sstevel@tonic-gate } rt_metrics_t; 850Sstevel@tonic-gate 860Sstevel@tonic-gate /* 870Sstevel@tonic-gate * OLD rtentry structure not used in the kernel. Instead the kernel 880Sstevel@tonic-gate * uses struct ire defined in <inet/ip.h>. 890Sstevel@tonic-gate * 900Sstevel@tonic-gate * We distinguish between routes to hosts and routes to networks, 910Sstevel@tonic-gate * preferring the former if available. For each route we infer 920Sstevel@tonic-gate * the interface to use from the gateway address supplied when 930Sstevel@tonic-gate * the route was entered. Routes that forward packets through 940Sstevel@tonic-gate * gateways are marked so that the output routines know to address the 950Sstevel@tonic-gate * gateway rather than the ultimate destination. 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate struct rtentry { 980Sstevel@tonic-gate uint_t rt_hash; /* to speed lookups */ 990Sstevel@tonic-gate struct sockaddr rt_dst; /* key */ 1000Sstevel@tonic-gate struct sockaddr rt_gateway; /* value */ 1010Sstevel@tonic-gate short rt_flags; /* up/down?, host/net */ 1020Sstevel@tonic-gate short rt_refcnt; /* # held references */ 1030Sstevel@tonic-gate uint_t rt_use; /* raw # packets forwarded */ 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * The kernel does not use this field, and without it the structure is 1070Sstevel@tonic-gate * datamodel independent. 1080Sstevel@tonic-gate */ 1090Sstevel@tonic-gate #if !defined(_KERNEL) 1100Sstevel@tonic-gate struct ifnet *rt_ifp; /* the answer: interface to use */ 1110Sstevel@tonic-gate #endif /* !defined(_KERNEL) */ 1120Sstevel@tonic-gate }; 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate #define RTF_UP 0x1 /* route usable */ 1150Sstevel@tonic-gate #define RTF_GATEWAY 0x2 /* destination is a gateway */ 1160Sstevel@tonic-gate #define RTF_HOST 0x4 /* host entry (net otherwise) */ 1170Sstevel@tonic-gate #define RTF_REJECT 0x8 /* host or net unreachable */ 1180Sstevel@tonic-gate #define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ 1190Sstevel@tonic-gate #define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ 1200Sstevel@tonic-gate #define RTF_DONE 0x40 /* message confirmed */ 1210Sstevel@tonic-gate #define RTF_MASK 0x80 /* subnet mask present */ 1220Sstevel@tonic-gate #define RTF_CLONING 0x100 /* generate new routes on use */ 1230Sstevel@tonic-gate #define RTF_XRESOLVE 0x200 /* external daemon resolves name */ 1240Sstevel@tonic-gate #define RTF_LLINFO 0x400 /* generated by ARP or ESIS */ 1250Sstevel@tonic-gate #define RTF_STATIC 0x800 /* manually added */ 1260Sstevel@tonic-gate #define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ 1270Sstevel@tonic-gate #define RTF_PRIVATE 0x2000 /* do not advertise this route */ 1280Sstevel@tonic-gate #define RTF_PROTO2 0x4000 /* protocol specific routing flag */ 1290Sstevel@tonic-gate #define RTF_PROTO1 0x8000 /* protocol specific routing flag */ 1300Sstevel@tonic-gate #define RTF_MULTIRT 0x10000 /* multiroute */ 1310Sstevel@tonic-gate #define RTF_SETSRC 0x20000 /* set default outgoing src address */ 13211042SErik.Nordmark@Sun.COM #define RTF_INDIRECT 0x40000 /* gateway not directly reachable */ 13311042SErik.Nordmark@Sun.COM #define RTF_KERNEL 0x80000 /* created by kernel; can't delete */ 134*12748SSowmini.Varadhan@oracle.COM #define RTF_ZONE 0x100000 /* (NGZ only) route from global zone */ 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* 1370Sstevel@tonic-gate * OLD statistics not used by the kernel. The kernel uses <inet/mib2.h>. 1380Sstevel@tonic-gate * 1390Sstevel@tonic-gate * Routing statistics. 1400Sstevel@tonic-gate */ 1410Sstevel@tonic-gate struct rtstat { 1420Sstevel@tonic-gate short rts_badredirect; /* bogus redirect calls */ 1430Sstevel@tonic-gate short rts_dynamic; /* routes created by redirects */ 1440Sstevel@tonic-gate short rts_newgateway; /* routes modified by redirects */ 1450Sstevel@tonic-gate short rts_unreach; /* lookups which failed */ 1460Sstevel@tonic-gate short rts_wildcard; /* lookups satisfied by a wildcard */ 1470Sstevel@tonic-gate }; 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate /* 1500Sstevel@tonic-gate * Structures for routing messages. 1510Sstevel@tonic-gate */ 1520Sstevel@tonic-gate typedef struct rt_msghdr { 1530Sstevel@tonic-gate ushort_t rtm_msglen; /* to skip over non-understood messages */ 1540Sstevel@tonic-gate uchar_t rtm_version; /* future binary compatibility */ 1550Sstevel@tonic-gate uchar_t rtm_type; /* message type */ 1560Sstevel@tonic-gate ushort_t rtm_index; /* index for associated ifp */ 1570Sstevel@tonic-gate int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ 1580Sstevel@tonic-gate int rtm_addrs; /* bitmask identifying sockaddrs in msg */ 1590Sstevel@tonic-gate pid_t rtm_pid; /* identify sender */ 1600Sstevel@tonic-gate int rtm_seq; /* for sender to identify action */ 1610Sstevel@tonic-gate int rtm_errno; /* why failed */ 1620Sstevel@tonic-gate int rtm_use; /* from rtentry */ 1630Sstevel@tonic-gate uint_t rtm_inits; /* which metrics we are initializing */ 1640Sstevel@tonic-gate struct rt_metrics rtm_rmx; /* metrics themselves */ 1650Sstevel@tonic-gate } rt_msghdr_t; 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate #define RTM_VERSION 3 /* Up the ante and ignore older versions */ 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate #define RTM_ADD 0x1 /* Add Route */ 1700Sstevel@tonic-gate #define RTM_DELETE 0x2 /* Delete Route */ 1710Sstevel@tonic-gate #define RTM_CHANGE 0x3 /* Change Metrics or flags */ 1720Sstevel@tonic-gate #define RTM_GET 0x4 /* Report Metrics */ 1730Sstevel@tonic-gate #define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */ 1740Sstevel@tonic-gate #define RTM_REDIRECT 0x6 /* Told to use different route */ 1750Sstevel@tonic-gate #define RTM_MISS 0x7 /* Lookup failed on this address */ 1760Sstevel@tonic-gate #define RTM_LOCK 0x8 /* fix specified metrics */ 1770Sstevel@tonic-gate #define RTM_OLDADD 0x9 /* caused by SIOCADDRT */ 1780Sstevel@tonic-gate #define RTM_OLDDEL 0xa /* caused by SIOCDELRT */ 1790Sstevel@tonic-gate #define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */ 1800Sstevel@tonic-gate #define RTM_NEWADDR 0xc /* address being added to iface */ 1810Sstevel@tonic-gate #define RTM_DELADDR 0xd /* address being removed from iface */ 1820Sstevel@tonic-gate #define RTM_IFINFO 0xe /* iface going up/down etc. */ 18311076SCathy.Zhou@Sun.COM #define RTM_CHGADDR 0xf /* address added/changed (even while down) */ 18411076SCathy.Zhou@Sun.COM #define RTM_FREEADDR 0x10 /* address removed (even while down) */ 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate #define RTV_MTU 0x1 /* init or lock _mtu */ 1870Sstevel@tonic-gate #define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ 1880Sstevel@tonic-gate #define RTV_EXPIRE 0x4 /* init or lock _expire */ 1890Sstevel@tonic-gate #define RTV_RPIPE 0x8 /* init or lock _recvpipe */ 1900Sstevel@tonic-gate #define RTV_SPIPE 0x10 /* init or lock _sendpipe */ 1910Sstevel@tonic-gate #define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ 1920Sstevel@tonic-gate #define RTV_RTT 0x40 /* init or lock _rtt */ 1930Sstevel@tonic-gate #define RTV_RTTVAR 0x80 /* init or lock _rttvar */ 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate /* 1960Sstevel@tonic-gate * Bitmask values for rtm_addr. 1970Sstevel@tonic-gate */ 1980Sstevel@tonic-gate #define RTA_DST 0x1 /* destination sockaddr present */ 1990Sstevel@tonic-gate #define RTA_GATEWAY 0x2 /* gateway sockaddr present */ 2000Sstevel@tonic-gate #define RTA_NETMASK 0x4 /* netmask sockaddr present */ 2010Sstevel@tonic-gate #define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ 2020Sstevel@tonic-gate #define RTA_IFP 0x10 /* interface name sockaddr present */ 2030Sstevel@tonic-gate #define RTA_IFA 0x20 /* interface addr sockaddr present */ 2040Sstevel@tonic-gate #define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ 2050Sstevel@tonic-gate #define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */ 2060Sstevel@tonic-gate #define RTA_SRC 0x100 /* source sockaddr present */ 2070Sstevel@tonic-gate 2084823Sseb #define RTA_NUMBITS 9 /* Number of bits used in RTA_* */ 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate /* 2110Sstevel@tonic-gate * Index offsets for sockaddr_storage array for alternate internal encoding. 2120Sstevel@tonic-gate * There should be an RTAX_* associated with each RTA_*. 2130Sstevel@tonic-gate */ 2140Sstevel@tonic-gate #define RTAX_DST 0 2150Sstevel@tonic-gate #define RTAX_GATEWAY 1 2160Sstevel@tonic-gate #define RTAX_NETMASK 2 2170Sstevel@tonic-gate #define RTAX_GENMASK 3 2180Sstevel@tonic-gate #define RTAX_IFP 4 2190Sstevel@tonic-gate #define RTAX_IFA 5 2200Sstevel@tonic-gate #define RTAX_AUTHOR 6 2210Sstevel@tonic-gate #define RTAX_BRD 7 2220Sstevel@tonic-gate #define RTAX_SRC 8 2230Sstevel@tonic-gate #define RTAX_MAX RTA_NUMBITS /* size of array to allocate */ 2240Sstevel@tonic-gate 2251676Sjpk /* 2261676Sjpk * Routing socket message extension after sockaddrs. 2271676Sjpk */ 2281676Sjpk typedef struct rtm_ext_s { 2291676Sjpk uint32_t rtmex_type; /* identifier for type of extension */ 2301676Sjpk uint32_t rtmex_len; /* length of this extension */ 2311676Sjpk } rtm_ext_t; 2321676Sjpk 2331676Sjpk #define RTMEX_GATEWAY_SECATTR 1 /* extension is tsol_rtsecattr */ 2341676Sjpk #define RTMEX_MAX RTMEX_GATEWAY_SECATTR 2351676Sjpk 2361676Sjpk /* 2371676Sjpk * Trusted Solaris route security attributes extension. 2381676Sjpk */ 2391919Sjarrett typedef struct rtsa_s { 2401919Sjarrett uint32_t rtsa_mask; /* see RTSA_* below */ 2411919Sjarrett uint32_t rtsa_doi; /* domain of interpretation */ 2421919Sjarrett brange_t rtsa_slrange; /* sensitivity label range */ 2431919Sjarrett } rtsa_t; 2441919Sjarrett 2451676Sjpk typedef struct tsol_rtsecattr_s { 2461676Sjpk uint32_t rtsa_cnt; /* number of attributes */ 2471919Sjarrett rtsa_t rtsa_attr[1]; 2481676Sjpk } tsol_rtsecattr_t; 2491676Sjpk 2501676Sjpk #define TSOL_RTSECATTR_SIZE(n) \ 2511676Sjpk (sizeof (tsol_rtsecattr_t) + (((n) - 1) * sizeof (struct rtsa_s))) 2521676Sjpk 2531676Sjpk #define RTSA_MINSL 0x1 /* minimum sensitivity label is valid */ 2541676Sjpk #define RTSA_MAXSL 0x2 /* maximum sensitivity label is valid */ 2551676Sjpk #define RTSA_DOI 0x4 /* domain of interpretation is valid */ 2561676Sjpk #define RTSA_CIPSO 0x100 /* CIPSO protocol */ 2571676Sjpk #define RTSA_SLRANGE (RTSA_MINSL|RTSA_MAXSL) 2581676Sjpk 2598485SPeter.Memishian@Sun.COM /* 2608485SPeter.Memishian@Sun.COM * Routing socket options. 2618485SPeter.Memishian@Sun.COM */ 2628485SPeter.Memishian@Sun.COM #define RT_AWARE 0x0001 /* set awareness of hidden interfaces */ 2638485SPeter.Memishian@Sun.COM 2648485SPeter.Memishian@Sun.COM /* 2658485SPeter.Memishian@Sun.COM * Supported RT_AWARE values. As a convenience, the bit-values here mirror 2668485SPeter.Memishian@Sun.COM * the LIFC_* values. 2678485SPeter.Memishian@Sun.COM */ 2688485SPeter.Memishian@Sun.COM #define RTAW_DEFAULT 0x0000 /* unaware application */ 2698485SPeter.Memishian@Sun.COM #define RTAW_UNDER_IPMP 0x0010 /* aware of underlying IPMP interfaces */ 2708485SPeter.Memishian@Sun.COM 2710Sstevel@tonic-gate #ifdef __cplusplus 2720Sstevel@tonic-gate } 2730Sstevel@tonic-gate #endif 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate #endif /* _NET_ROUTE_H */ 276