xref: /freebsd/sys/netlink/route/ifaddrs.h (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2022 Alexander V. Chernikov <melifaro@FreeBSD.org>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 /*
29  * Interface address-related (RTM_<NEW|DEL|GET>ADDR) message header and attributes.
30  */
31 
32 #ifndef _NETLINK_ROUTE_IFADDRS_H_
33 #define _NETLINK_ROUTE_IFADDRS_H_
34 
35 /* Base header for all of the relevant messages */
36 struct ifaddrmsg {
37 	uint8_t		ifa_family;	/* Address family */
38 	uint8_t		ifa_prefixlen;	/* Prefix length */
39 	uint8_t		ifa_flags;	/* Address-specific flags */
40 	uint8_t		ifa_scope;	/* Address scope */
41 	uint32_t	ifa_index;	/* Link ifindex */
42 };
43 
44 #ifndef _KERNEL
45 #define	_NL_IFA_HDRLEN		((int)sizeof(struct ifaddrmsg))
46 #define	IFA_RTA(_ifa)		((struct rtattr *)(NL_ITEM_DATA(_ifa, _NL_IFA_HDRLEN)))
47 #define	IFA_PAYLOAD(_hdr)	NLMSG_PAYLOAD(_hdr, _NL_IFA_HDRLEN)
48 #endif
49 
50 /* Defined attributes */
51 enum {
52 	IFA_UNSPEC,
53 	IFA_ADDRESS		= 1, /* binary, prefix address (destination for p2p) */
54 	IFA_LOCAL		= 2, /* binary, interface address */
55 	IFA_LABEL		= 3, /* string, interface name */
56 	IFA_BROADCAST		= 4, /* binary, broadcast ifa */
57 	IFA_ANYCAST		= 5, /* not supported */
58 	IFA_CACHEINFO		= 6, /* not supported */
59 	IFA_MULTICAST		= 7, /* not supported */
60 	IFA_FLAGS		= 8, /* not supported */
61 	IFA_RT_PRIORITY		= 9, /* not supported */
62 	IFA_TARGET_NETNSID	= 10, /* not supported */
63 	__IFA_MAX,
64 };
65 #define IFA_MAX (__IFA_MAX - 1)
66 
67 /* IFA_FLAGS attribute flags */
68 #define IFA_F_SECONDARY		0x0001
69 #define IFA_F_TEMPORARY		IFA_F_SECONDARY
70 #define IFA_F_NODAD		0x0002
71 #define IFA_F_OPTIMISTIC	0x0004
72 #define IFA_F_DADFAILED		0x0008
73 #define IFA_F_HOMEADDRESS	0x0010
74 #define IFA_F_DEPRECATED	0x0020
75 #define IFA_F_TENTATIVE		0x0040
76 #define IFA_F_PERMANENT		0x0080
77 #define IFA_F_MANAGETEMPADDR	0x0100
78 #define IFA_F_NOPREFIXROUTE	0x0200
79 #define IFA_F_MCAUTOJOIN	0x0400
80 #define IFA_F_STABLE_PRIVACY	0x0800
81 
82 /* IFA_CACHEINFO value */
83 struct ifa_cacheinfo {
84 	uint32_t ifa_prefered;
85 	uint32_t ifa_valid;
86 	uint32_t cstamp;
87 	uint32_t tstamp;
88 };
89 
90 #endif
91