xref: /linux/include/uapi/linux/if_addr.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells #ifndef __LINUX_IF_ADDR_H
3607ca46eSDavid Howells #define __LINUX_IF_ADDR_H
4607ca46eSDavid Howells 
5607ca46eSDavid Howells #include <linux/types.h>
6607ca46eSDavid Howells #include <linux/netlink.h>
7607ca46eSDavid Howells 
8607ca46eSDavid Howells struct ifaddrmsg {
9607ca46eSDavid Howells 	__u8		ifa_family;
10607ca46eSDavid Howells 	__u8		ifa_prefixlen;	/* The prefix length		*/
11607ca46eSDavid Howells 	__u8		ifa_flags;	/* Flags			*/
12607ca46eSDavid Howells 	__u8		ifa_scope;	/* Address scope		*/
13607ca46eSDavid Howells 	__u32		ifa_index;	/* Link index			*/
14607ca46eSDavid Howells };
15607ca46eSDavid Howells 
16607ca46eSDavid Howells /*
17607ca46eSDavid Howells  * Important comment:
18607ca46eSDavid Howells  * IFA_ADDRESS is prefix address, rather than local interface address.
19607ca46eSDavid Howells  * It makes no difference for normally configured broadcast interfaces,
20607ca46eSDavid Howells  * but for point-to-point IFA_ADDRESS is DESTINATION address,
21607ca46eSDavid Howells  * local address is supplied in IFA_LOCAL attribute.
22479840ffSJiri Pirko  *
23479840ffSJiri Pirko  * IFA_FLAGS is a u32 attribute that extends the u8 field ifa_flags.
24479840ffSJiri Pirko  * If present, the value from struct ifaddrmsg will be ignored.
25607ca46eSDavid Howells  */
26607ca46eSDavid Howells enum {
27607ca46eSDavid Howells 	IFA_UNSPEC,
28607ca46eSDavid Howells 	IFA_ADDRESS,
29607ca46eSDavid Howells 	IFA_LOCAL,
30607ca46eSDavid Howells 	IFA_LABEL,
31607ca46eSDavid Howells 	IFA_BROADCAST,
32607ca46eSDavid Howells 	IFA_ANYCAST,
33607ca46eSDavid Howells 	IFA_CACHEINFO,
34607ca46eSDavid Howells 	IFA_MULTICAST,
35479840ffSJiri Pirko 	IFA_FLAGS,
36620dee94SDavid Ahern 	IFA_RT_PRIORITY,	/* u32, priority/metric for prefix route */
379f3c057cSChristian Brauner 	IFA_TARGET_NETNSID,
38*47f0bd50SJacques de Laval 	IFA_PROTO,		/* u8, address protocol */
39607ca46eSDavid Howells 	__IFA_MAX,
40607ca46eSDavid Howells };
41607ca46eSDavid Howells 
42607ca46eSDavid Howells #define IFA_MAX (__IFA_MAX - 1)
43607ca46eSDavid Howells 
44607ca46eSDavid Howells /* ifa_flags */
45607ca46eSDavid Howells #define IFA_F_SECONDARY		0x01
46607ca46eSDavid Howells #define IFA_F_TEMPORARY		IFA_F_SECONDARY
47607ca46eSDavid Howells 
48607ca46eSDavid Howells #define	IFA_F_NODAD		0x02
49607ca46eSDavid Howells #define IFA_F_OPTIMISTIC	0x04
50607ca46eSDavid Howells #define IFA_F_DADFAILED		0x08
51607ca46eSDavid Howells #define	IFA_F_HOMEADDRESS	0x10
52607ca46eSDavid Howells #define IFA_F_DEPRECATED	0x20
53607ca46eSDavid Howells #define IFA_F_TENTATIVE		0x40
54607ca46eSDavid Howells #define IFA_F_PERMANENT		0x80
5553bd6749SJiri Pirko #define IFA_F_MANAGETEMPADDR	0x100
56761aac73SThomas Haller #define IFA_F_NOPREFIXROUTE	0x200
5793a714d6SMadhu Challa #define IFA_F_MCAUTOJOIN	0x400
5864236f3fSHannes Frederic Sowa #define IFA_F_STABLE_PRIVACY	0x800
59607ca46eSDavid Howells 
60607ca46eSDavid Howells struct ifa_cacheinfo {
61607ca46eSDavid Howells 	__u32	ifa_prefered;
62607ca46eSDavid Howells 	__u32	ifa_valid;
63607ca46eSDavid Howells 	__u32	cstamp; /* created timestamp, hundredths of seconds */
64607ca46eSDavid Howells 	__u32	tstamp; /* updated timestamp, hundredths of seconds */
65607ca46eSDavid Howells };
66607ca46eSDavid Howells 
67607ca46eSDavid Howells /* backwards compatibility for userspace */
68607ca46eSDavid Howells #ifndef __KERNEL__
69607ca46eSDavid Howells #define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
70607ca46eSDavid Howells #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
71607ca46eSDavid Howells #endif
72607ca46eSDavid Howells 
73*47f0bd50SJacques de Laval /* ifa_proto */
74*47f0bd50SJacques de Laval #define IFAPROT_UNSPEC		0
75*47f0bd50SJacques de Laval #define IFAPROT_KERNEL_LO	1	/* loopback */
76*47f0bd50SJacques de Laval #define IFAPROT_KERNEL_RA	2	/* set by kernel from router announcement */
77*47f0bd50SJacques de Laval #define IFAPROT_KERNEL_LL	3	/* link-local set by kernel */
78*47f0bd50SJacques de Laval 
79607ca46eSDavid Howells #endif
80