/* $FreeBSD$ */ /*- * Copyright (c) 2007 Bruce M. Simpson. * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ /* * Netlink Protocol -- Routing Services [RFC 3549]. * * This is an implementation of the routing-table specific portions of * the Netlink Protocol for FreeBSD as documented within RFC 3549. */ #ifndef _NET_RTNETLINK_H_ #define _NET_RTNETLINK_H_ #include #include struct rtmsg { uint8_t rtm_family; /* Protocol family */ uint8_t rtm_dst_len; /* ? */ uint8_t rtm_src_len; /* ? */ uint8_t rtm_tos; /* ? */ uint8_t rtm_table; uint8_t rtm_protocol; /* Originating routing protocol */ uint8_t rtm_scope; uint8_t rtm_type; uint32_t rtm_flags; }; /* rtm_table */ #define RT_TABLE_UNSPEC 0 #define RT_TABLE_DEFAULT 253 #define RT_TABLE_MAIN 254 #define RT_TABLE_LOCAL 255 #define RT_TABLE_MAX 0xFFFFFFFF /* rtm_protocol */ #define RTPROT_UNSPEC 0 #define RTPROT_REDIRECT 1 #define RTPROT_KERNEL 2 #define RTPROT_BOOT 3 #define RTPROT_STATIC 4 #define RTPROT_ZEBRA 11 #define RTPROT_XORP 14 /* rtm_scope */ #define RT_SCOPE_UNIVERSE 0 #define RT_SCOPE_SITE 200 #define RT_SCOPE_LINK 253 #define RT_SCOPE_HOST 254 #define RT_SCOPE_NOWHERE 255 /* rtm_type */ #define RTN_UNSPEC 0 #define RTN_UNICAST 1 #define RTN_LOCAL 2 #define RTN_BROADCAST 3 #define RTN_ANYCAST 4 #define RTN_MULTICAST 5 #define RTN_BLACKHOLE 6 #define RTN_UNREACHABLE 7 #define RTN_PROHIBIT 8 #define RTN_THROW 9 #define RTN_NAT 10 /* Not used by FreeBSD */ #define RTN_XRESOLVE 11 #define RTN_MAX RTN_XRESOLVE /* rtm_flags */ #define RTM_F_NOTIFY 0x00000100 #define RTM_F_CLONED 0x00000200 #define RTM_F_EQUALIZE 0x00000400 #define RTM_F_PREFIX 0x00000800 /* TODO: Do multicast forwarding lookups from unified FIB */ enum rtattr_type_t { RTA_UNSPEC = 0, RTA_DST, /* Destination */ RTA_SRC, /* Source */ RTA_IIF, /* Input interface */ RTA_OIF, /* Output interface */ RTA_GATEWAY, /* Next-hop */ RTA_PRIORITY, /* ? */ RTA_PREFSRC, /* ? */ RTA_METRICS, /* MTU etc XXX TODO */ RTA_MULTIPATH, /* read more */ RTA_PROTOINFO, /* Unsupported in FreeBSD */ RTA_FLOW, /* Unsupported in FreeBSD */ RTA_CACHEINFO, /* Unsupported in FreeBSD */ RTA_SESSION, /* Unsupported in FreeBSD */ RTA_MP_ALGO, /* Unsupported in FreeBSD */ RTA_TABLE, /* ? */ __RTA_MAX }; #define RTA_MAX (__RTA_MAX - 1) /* TODO */ #define RTM_RTA(r) #define RTM_PAYLOAD(n) struct rtnexthop { uint16_t rtnh_len; uint8_t rtnh_flags; uint8_t rtnh_hops; int32_t rtnh_ifindex; }; #define RTNH_F_DEAD 0x01 #define RTNH_F_PERVASIVE 0x02 #define RTNH_F_ONLINK 0x04 /* RTNH MACROS */ /* METRICS mtu etc */ struct rtgenmsg { uint8_t rtgen_family; }; /* * Link layer stuff. */ struct ifinfomsg { uint8_t ifi_family; uint8_t ifi_family; uint16_t ifi_type; int32_t ifi_index; uint32_t ifi_flags; uint32_t ifi_change; /* XXX BSD capabilities */ }; struct prefixmsg { uint8_t prefix_family; uint8_t prefix_pad1; uint16_t prefix_pad2; int32_t prefix_ifindex; uint8_t prefix_type; uint8_t prefix_len; uint8_t prefix_flags; uint8_t prefix_pad3; }; #define PREFIX_UNSPEC 0 #define PREFIX_ADDRESS 1 #define PREFIX_CACHEINFO 2 /* will we implement this? */ /* * Multicast groups for PF_NETLINK-NETLINK_ROUTE. */ #define RTNLGRP_NONE 0 #define RTNLGRP_LINK 1 #define RTNLGRP_NOTIFY 2 #define RTNLGRP_NEIGH 3 /* skip the 4 */ #define RTNLGRP_IPV4_IFADDR 5 #define RTNLGRP_IPV4_MROUTE 6 #define RTNLGRP_IPV4_ROUTE 7 #ifdef _KERNEL /* Kernel internals go here. mbufs, not skbufs. */ #endif /* _KERNEL */ #endif /* _NET_RTNETLINK_H_ */