17c478bd9Sstevel@tonic-gate /* 2e11c3f44Smeem * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate /* 67c478bd9Sstevel@tonic-gate * Copyright (c) 1980, 1986, 1993 77c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 107c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions 117c478bd9Sstevel@tonic-gate * are met: 127c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 137c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 147c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 157c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 167c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 177c478bd9Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 187c478bd9Sstevel@tonic-gate * must display the following acknowledgement: 197c478bd9Sstevel@tonic-gate * This product includes software developed by the University of 207c478bd9Sstevel@tonic-gate * California, Berkeley and its contributors. 217c478bd9Sstevel@tonic-gate * 4. Neither the name of the University nor the names of its contributors 227c478bd9Sstevel@tonic-gate * may be used to endorse or promote products derived from this software 237c478bd9Sstevel@tonic-gate * without specific prior written permission. 247c478bd9Sstevel@tonic-gate * 257c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 267c478bd9Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 277c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 287c478bd9Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 297c478bd9Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 307c478bd9Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 317c478bd9Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 327c478bd9Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 337c478bd9Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 347c478bd9Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 357c478bd9Sstevel@tonic-gate * SUCH DAMAGE. 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * Kernel resident routing tables. 407c478bd9Sstevel@tonic-gate * 417c478bd9Sstevel@tonic-gate * The routing tables are initialized when interface addresses 427c478bd9Sstevel@tonic-gate * are set by making entries for all directly connected interfaces. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #ifndef _NET_ROUTE_H 467c478bd9Sstevel@tonic-gate #define _NET_ROUTE_H 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* from UCB 8.5 (Berkeley) 2/8/95 */ 497c478bd9Sstevel@tonic-gate 5045916cd2Sjpk #include <sys/tsol/label.h> 5145916cd2Sjpk #include <sys/tsol/label_macro.h> 5245916cd2Sjpk 537c478bd9Sstevel@tonic-gate #ifdef __cplusplus 547c478bd9Sstevel@tonic-gate extern "C" { 557c478bd9Sstevel@tonic-gate #endif 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 587c478bd9Sstevel@tonic-gate * A route consists of a destination address and a reference 597c478bd9Sstevel@tonic-gate * to a routing entry. These are often held by protocols 607c478bd9Sstevel@tonic-gate * in their control blocks, e.g. inpcb. 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate struct route { 637c478bd9Sstevel@tonic-gate struct rtentry *ro_rt; 647c478bd9Sstevel@tonic-gate struct sockaddr ro_dst; 657c478bd9Sstevel@tonic-gate }; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * These numbers are used by reliable protocols for determining 697c478bd9Sstevel@tonic-gate * retransmission behavior and are included in the routing structure. 707c478bd9Sstevel@tonic-gate * 717c478bd9Sstevel@tonic-gate * rmx_rtt and rmx_rttvar are stored as microseconds; 727c478bd9Sstevel@tonic-gate */ 737c478bd9Sstevel@tonic-gate typedef struct rt_metrics { 747c478bd9Sstevel@tonic-gate uint32_t rmx_locks; /* Kernel must leave these values */ 757c478bd9Sstevel@tonic-gate /* alone */ 767c478bd9Sstevel@tonic-gate uint32_t rmx_mtu; /* MTU for this path */ 777c478bd9Sstevel@tonic-gate uint32_t rmx_hopcount; /* max hops expected */ 787c478bd9Sstevel@tonic-gate uint32_t rmx_expire; /* lifetime for route, e.g. redirect */ 797c478bd9Sstevel@tonic-gate uint32_t rmx_recvpipe; /* inbound delay-bandwith product */ 807c478bd9Sstevel@tonic-gate uint32_t rmx_sendpipe; /* outbound delay-bandwith product */ 817c478bd9Sstevel@tonic-gate uint32_t rmx_ssthresh; /* outbound gateway buffer limit */ 827c478bd9Sstevel@tonic-gate uint32_t rmx_rtt; /* estimated round trip time */ 837c478bd9Sstevel@tonic-gate uint32_t rmx_rttvar; /* estimated rtt variance */ 847c478bd9Sstevel@tonic-gate uint32_t rmx_pksent; /* packets sent using this route */ 857c478bd9Sstevel@tonic-gate } rt_metrics_t; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * OLD rtentry structure not used in the kernel. Instead the kernel 897c478bd9Sstevel@tonic-gate * uses struct ire defined in <inet/ip.h>. 907c478bd9Sstevel@tonic-gate * 917c478bd9Sstevel@tonic-gate * We distinguish between routes to hosts and routes to networks, 927c478bd9Sstevel@tonic-gate * preferring the former if available. For each route we infer 937c478bd9Sstevel@tonic-gate * the interface to use from the gateway address supplied when 947c478bd9Sstevel@tonic-gate * the route was entered. Routes that forward packets through 957c478bd9Sstevel@tonic-gate * gateways are marked so that the output routines know to address the 967c478bd9Sstevel@tonic-gate * gateway rather than the ultimate destination. 977c478bd9Sstevel@tonic-gate */ 987c478bd9Sstevel@tonic-gate struct rtentry { 997c478bd9Sstevel@tonic-gate uint_t rt_hash; /* to speed lookups */ 1007c478bd9Sstevel@tonic-gate struct sockaddr rt_dst; /* key */ 1017c478bd9Sstevel@tonic-gate struct sockaddr rt_gateway; /* value */ 1027c478bd9Sstevel@tonic-gate short rt_flags; /* up/down?, host/net */ 1037c478bd9Sstevel@tonic-gate short rt_refcnt; /* # held references */ 1047c478bd9Sstevel@tonic-gate uint_t rt_use; /* raw # packets forwarded */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * The kernel does not use this field, and without it the structure is 1087c478bd9Sstevel@tonic-gate * datamodel independent. 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) 1117c478bd9Sstevel@tonic-gate struct ifnet *rt_ifp; /* the answer: interface to use */ 1127c478bd9Sstevel@tonic-gate #endif /* !defined(_KERNEL) */ 1137c478bd9Sstevel@tonic-gate }; 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #define RTF_UP 0x1 /* route usable */ 1167c478bd9Sstevel@tonic-gate #define RTF_GATEWAY 0x2 /* destination is a gateway */ 1177c478bd9Sstevel@tonic-gate #define RTF_HOST 0x4 /* host entry (net otherwise) */ 1187c478bd9Sstevel@tonic-gate #define RTF_REJECT 0x8 /* host or net unreachable */ 1197c478bd9Sstevel@tonic-gate #define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ 1207c478bd9Sstevel@tonic-gate #define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ 1217c478bd9Sstevel@tonic-gate #define RTF_DONE 0x40 /* message confirmed */ 1227c478bd9Sstevel@tonic-gate #define RTF_MASK 0x80 /* subnet mask present */ 1237c478bd9Sstevel@tonic-gate #define RTF_CLONING 0x100 /* generate new routes on use */ 1247c478bd9Sstevel@tonic-gate #define RTF_XRESOLVE 0x200 /* external daemon resolves name */ 1257c478bd9Sstevel@tonic-gate #define RTF_LLINFO 0x400 /* generated by ARP or ESIS */ 1267c478bd9Sstevel@tonic-gate #define RTF_STATIC 0x800 /* manually added */ 1277c478bd9Sstevel@tonic-gate #define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ 1287c478bd9Sstevel@tonic-gate #define RTF_PRIVATE 0x2000 /* do not advertise this route */ 1297c478bd9Sstevel@tonic-gate #define RTF_PROTO2 0x4000 /* protocol specific routing flag */ 1307c478bd9Sstevel@tonic-gate #define RTF_PROTO1 0x8000 /* protocol specific routing flag */ 1317c478bd9Sstevel@tonic-gate #define RTF_MULTIRT 0x10000 /* multiroute */ 1327c478bd9Sstevel@tonic-gate #define RTF_SETSRC 0x20000 /* set default outgoing src address */ 133*bd670b35SErik Nordmark #define RTF_INDIRECT 0x40000 /* gateway not directly reachable */ 134*bd670b35SErik Nordmark #define RTF_KERNEL 0x80000 /* created by kernel; can't delete */ 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * OLD statistics not used by the kernel. The kernel uses <inet/mib2.h>. 1387c478bd9Sstevel@tonic-gate * 1397c478bd9Sstevel@tonic-gate * Routing statistics. 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate struct rtstat { 1427c478bd9Sstevel@tonic-gate short rts_badredirect; /* bogus redirect calls */ 1437c478bd9Sstevel@tonic-gate short rts_dynamic; /* routes created by redirects */ 1447c478bd9Sstevel@tonic-gate short rts_newgateway; /* routes modified by redirects */ 1457c478bd9Sstevel@tonic-gate short rts_unreach; /* lookups which failed */ 1467c478bd9Sstevel@tonic-gate short rts_wildcard; /* lookups satisfied by a wildcard */ 1477c478bd9Sstevel@tonic-gate }; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate /* 1507c478bd9Sstevel@tonic-gate * Structures for routing messages. 1517c478bd9Sstevel@tonic-gate */ 1527c478bd9Sstevel@tonic-gate typedef struct rt_msghdr { 1537c478bd9Sstevel@tonic-gate ushort_t rtm_msglen; /* to skip over non-understood messages */ 1547c478bd9Sstevel@tonic-gate uchar_t rtm_version; /* future binary compatibility */ 1557c478bd9Sstevel@tonic-gate uchar_t rtm_type; /* message type */ 1567c478bd9Sstevel@tonic-gate ushort_t rtm_index; /* index for associated ifp */ 1577c478bd9Sstevel@tonic-gate int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ 1587c478bd9Sstevel@tonic-gate int rtm_addrs; /* bitmask identifying sockaddrs in msg */ 1597c478bd9Sstevel@tonic-gate pid_t rtm_pid; /* identify sender */ 1607c478bd9Sstevel@tonic-gate int rtm_seq; /* for sender to identify action */ 1617c478bd9Sstevel@tonic-gate int rtm_errno; /* why failed */ 1627c478bd9Sstevel@tonic-gate int rtm_use; /* from rtentry */ 1637c478bd9Sstevel@tonic-gate uint_t rtm_inits; /* which metrics we are initializing */ 1647c478bd9Sstevel@tonic-gate struct rt_metrics rtm_rmx; /* metrics themselves */ 1657c478bd9Sstevel@tonic-gate } rt_msghdr_t; 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate #define RTM_VERSION 3 /* Up the ante and ignore older versions */ 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate #define RTM_ADD 0x1 /* Add Route */ 1707c478bd9Sstevel@tonic-gate #define RTM_DELETE 0x2 /* Delete Route */ 1717c478bd9Sstevel@tonic-gate #define RTM_CHANGE 0x3 /* Change Metrics or flags */ 1727c478bd9Sstevel@tonic-gate #define RTM_GET 0x4 /* Report Metrics */ 1737c478bd9Sstevel@tonic-gate #define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */ 1747c478bd9Sstevel@tonic-gate #define RTM_REDIRECT 0x6 /* Told to use different route */ 1757c478bd9Sstevel@tonic-gate #define RTM_MISS 0x7 /* Lookup failed on this address */ 1767c478bd9Sstevel@tonic-gate #define RTM_LOCK 0x8 /* fix specified metrics */ 1777c478bd9Sstevel@tonic-gate #define RTM_OLDADD 0x9 /* caused by SIOCADDRT */ 1787c478bd9Sstevel@tonic-gate #define RTM_OLDDEL 0xa /* caused by SIOCDELRT */ 1797c478bd9Sstevel@tonic-gate #define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */ 1807c478bd9Sstevel@tonic-gate #define RTM_NEWADDR 0xc /* address being added to iface */ 1817c478bd9Sstevel@tonic-gate #define RTM_DELADDR 0xd /* address being removed from iface */ 1827c478bd9Sstevel@tonic-gate #define RTM_IFINFO 0xe /* iface going up/down etc. */ 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate #define RTV_MTU 0x1 /* init or lock _mtu */ 1857c478bd9Sstevel@tonic-gate #define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ 1867c478bd9Sstevel@tonic-gate #define RTV_EXPIRE 0x4 /* init or lock _expire */ 1877c478bd9Sstevel@tonic-gate #define RTV_RPIPE 0x8 /* init or lock _recvpipe */ 1887c478bd9Sstevel@tonic-gate #define RTV_SPIPE 0x10 /* init or lock _sendpipe */ 1897c478bd9Sstevel@tonic-gate #define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ 1907c478bd9Sstevel@tonic-gate #define RTV_RTT 0x40 /* init or lock _rtt */ 1917c478bd9Sstevel@tonic-gate #define RTV_RTTVAR 0x80 /* init or lock _rttvar */ 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate /* 1947c478bd9Sstevel@tonic-gate * Bitmask values for rtm_addr. 1957c478bd9Sstevel@tonic-gate */ 1967c478bd9Sstevel@tonic-gate #define RTA_DST 0x1 /* destination sockaddr present */ 1977c478bd9Sstevel@tonic-gate #define RTA_GATEWAY 0x2 /* gateway sockaddr present */ 1987c478bd9Sstevel@tonic-gate #define RTA_NETMASK 0x4 /* netmask sockaddr present */ 1997c478bd9Sstevel@tonic-gate #define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ 2007c478bd9Sstevel@tonic-gate #define RTA_IFP 0x10 /* interface name sockaddr present */ 2017c478bd9Sstevel@tonic-gate #define RTA_IFA 0x20 /* interface addr sockaddr present */ 2027c478bd9Sstevel@tonic-gate #define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ 2037c478bd9Sstevel@tonic-gate #define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */ 2047c478bd9Sstevel@tonic-gate #define RTA_SRC 0x100 /* source sockaddr present */ 2057c478bd9Sstevel@tonic-gate 2065c0b7edeSseb #define RTA_NUMBITS 9 /* Number of bits used in RTA_* */ 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* 2097c478bd9Sstevel@tonic-gate * Index offsets for sockaddr_storage array for alternate internal encoding. 2107c478bd9Sstevel@tonic-gate * There should be an RTAX_* associated with each RTA_*. 2117c478bd9Sstevel@tonic-gate */ 2127c478bd9Sstevel@tonic-gate #define RTAX_DST 0 2137c478bd9Sstevel@tonic-gate #define RTAX_GATEWAY 1 2147c478bd9Sstevel@tonic-gate #define RTAX_NETMASK 2 2157c478bd9Sstevel@tonic-gate #define RTAX_GENMASK 3 2167c478bd9Sstevel@tonic-gate #define RTAX_IFP 4 2177c478bd9Sstevel@tonic-gate #define RTAX_IFA 5 2187c478bd9Sstevel@tonic-gate #define RTAX_AUTHOR 6 2197c478bd9Sstevel@tonic-gate #define RTAX_BRD 7 2207c478bd9Sstevel@tonic-gate #define RTAX_SRC 8 2217c478bd9Sstevel@tonic-gate #define RTAX_MAX RTA_NUMBITS /* size of array to allocate */ 2227c478bd9Sstevel@tonic-gate 22345916cd2Sjpk /* 22445916cd2Sjpk * Routing socket message extension after sockaddrs. 22545916cd2Sjpk */ 22645916cd2Sjpk typedef struct rtm_ext_s { 22745916cd2Sjpk uint32_t rtmex_type; /* identifier for type of extension */ 22845916cd2Sjpk uint32_t rtmex_len; /* length of this extension */ 22945916cd2Sjpk } rtm_ext_t; 23045916cd2Sjpk 23145916cd2Sjpk #define RTMEX_GATEWAY_SECATTR 1 /* extension is tsol_rtsecattr */ 23245916cd2Sjpk #define RTMEX_MAX RTMEX_GATEWAY_SECATTR 23345916cd2Sjpk 23445916cd2Sjpk /* 23545916cd2Sjpk * Trusted Solaris route security attributes extension. 23645916cd2Sjpk */ 237b7b2cb06Sjarrett typedef struct rtsa_s { 238b7b2cb06Sjarrett uint32_t rtsa_mask; /* see RTSA_* below */ 239b7b2cb06Sjarrett uint32_t rtsa_doi; /* domain of interpretation */ 240b7b2cb06Sjarrett brange_t rtsa_slrange; /* sensitivity label range */ 241b7b2cb06Sjarrett } rtsa_t; 242b7b2cb06Sjarrett 24345916cd2Sjpk typedef struct tsol_rtsecattr_s { 24445916cd2Sjpk uint32_t rtsa_cnt; /* number of attributes */ 245b7b2cb06Sjarrett rtsa_t rtsa_attr[1]; 24645916cd2Sjpk } tsol_rtsecattr_t; 24745916cd2Sjpk 24845916cd2Sjpk #define TSOL_RTSECATTR_SIZE(n) \ 24945916cd2Sjpk (sizeof (tsol_rtsecattr_t) + (((n) - 1) * sizeof (struct rtsa_s))) 25045916cd2Sjpk 25145916cd2Sjpk #define RTSA_MINSL 0x1 /* minimum sensitivity label is valid */ 25245916cd2Sjpk #define RTSA_MAXSL 0x2 /* maximum sensitivity label is valid */ 25345916cd2Sjpk #define RTSA_DOI 0x4 /* domain of interpretation is valid */ 25445916cd2Sjpk #define RTSA_CIPSO 0x100 /* CIPSO protocol */ 25545916cd2Sjpk #define RTSA_SLRANGE (RTSA_MINSL|RTSA_MAXSL) 25645916cd2Sjpk 257e11c3f44Smeem /* 258e11c3f44Smeem * Routing socket options. 259e11c3f44Smeem */ 260e11c3f44Smeem #define RT_AWARE 0x0001 /* set awareness of hidden interfaces */ 261e11c3f44Smeem 262e11c3f44Smeem /* 263e11c3f44Smeem * Supported RT_AWARE values. As a convenience, the bit-values here mirror 264e11c3f44Smeem * the LIFC_* values. 265e11c3f44Smeem */ 266e11c3f44Smeem #define RTAW_DEFAULT 0x0000 /* unaware application */ 267e11c3f44Smeem #define RTAW_UNDER_IPMP 0x0010 /* aware of underlying IPMP interfaces */ 268e11c3f44Smeem 2697c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2707c478bd9Sstevel@tonic-gate } 2717c478bd9Sstevel@tonic-gate #endif 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate #endif /* _NET_ROUTE_H */ 274