1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __LINUX_IF_ADDR_H
3 #define __LINUX_IF_ADDR_H
4 
5 #include <linux/types.h>
6 #include <linux/netlink.h>
7 
8 struct ifaddrmsg {
9 	uint8_t		ifa_family;
10 	uint8_t		ifa_prefixlen;	/* The prefix length		*/
11 	uint8_t		ifa_flags;	/* Flags			*/
12 	uint8_t		ifa_scope;	/* Address scope		*/
13 	uint32_t		ifa_index;	/* Link index			*/
14 };
15 
16 /*
17  * Important comment:
18  * IFA_ADDRESS is prefix address, rather than local interface address.
19  * It makes no difference for normally configured broadcast interfaces,
20  * but for point-to-point IFA_ADDRESS is DESTINATION address,
21  * local address is supplied in IFA_LOCAL attribute.
22  *
23  * IFA_FLAGS is a u32 attribute that extends the u8 field ifa_flags.
24  * If present, the value from struct ifaddrmsg will be ignored.
25  */
26 enum {
27 	IFA_UNSPEC,
28 	IFA_ADDRESS,
29 	IFA_LOCAL,
30 	IFA_LABEL,
31 	IFA_BROADCAST,
32 	IFA_ANYCAST,
33 	IFA_CACHEINFO,
34 	IFA_MULTICAST,
35 	IFA_FLAGS,
36 	IFA_RT_PRIORITY,  /* u32, priority/metric for prefix route */
37 	IFA_TARGET_NETNSID,
38 	__IFA_MAX,
39 };
40 
41 #define IFA_MAX (__IFA_MAX - 1)
42 
43 /* ifa_flags */
44 #define IFA_F_SECONDARY		0x01
45 #define IFA_F_TEMPORARY		IFA_F_SECONDARY
46 
47 #define	IFA_F_NODAD		0x02
48 #define IFA_F_OPTIMISTIC	0x04
49 #define IFA_F_DADFAILED		0x08
50 #define	IFA_F_HOMEADDRESS	0x10
51 #define IFA_F_DEPRECATED	0x20
52 #define IFA_F_TENTATIVE		0x40
53 #define IFA_F_PERMANENT		0x80
54 #define IFA_F_MANAGETEMPADDR	0x100
55 #define IFA_F_NOPREFIXROUTE	0x200
56 #define IFA_F_MCAUTOJOIN	0x400
57 #define IFA_F_STABLE_PRIVACY	0x800
58 
59 struct ifa_cacheinfo {
60 	uint32_t	ifa_prefered;
61 	uint32_t	ifa_valid;
62 	uint32_t	cstamp; /* created timestamp, hundredths of seconds */
63 	uint32_t	tstamp; /* updated timestamp, hundredths of seconds */
64 };
65 
66 /* backwards compatibility for userspace */
67 #ifndef __KERNEL__
68 #define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
69 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
70 #endif
71 
72 #endif
73