162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
262306a36Sopenharmony_ci#ifndef __LINUX_IF_ADDR_H
362306a36Sopenharmony_ci#define __LINUX_IF_ADDR_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/types.h>
662306a36Sopenharmony_ci#include <linux/netlink.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_cistruct ifaddrmsg {
962306a36Sopenharmony_ci	__u8		ifa_family;
1062306a36Sopenharmony_ci	__u8		ifa_prefixlen;	/* The prefix length		*/
1162306a36Sopenharmony_ci	__u8		ifa_flags;	/* Flags			*/
1262306a36Sopenharmony_ci	__u8		ifa_scope;	/* Address scope		*/
1362306a36Sopenharmony_ci	__u32		ifa_index;	/* Link index			*/
1462306a36Sopenharmony_ci};
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/*
1762306a36Sopenharmony_ci * Important comment:
1862306a36Sopenharmony_ci * IFA_ADDRESS is prefix address, rather than local interface address.
1962306a36Sopenharmony_ci * It makes no difference for normally configured broadcast interfaces,
2062306a36Sopenharmony_ci * but for point-to-point IFA_ADDRESS is DESTINATION address,
2162306a36Sopenharmony_ci * local address is supplied in IFA_LOCAL attribute.
2262306a36Sopenharmony_ci *
2362306a36Sopenharmony_ci * IFA_FLAGS is a u32 attribute that extends the u8 field ifa_flags.
2462306a36Sopenharmony_ci * If present, the value from struct ifaddrmsg will be ignored.
2562306a36Sopenharmony_ci */
2662306a36Sopenharmony_cienum {
2762306a36Sopenharmony_ci	IFA_UNSPEC,
2862306a36Sopenharmony_ci	IFA_ADDRESS,
2962306a36Sopenharmony_ci	IFA_LOCAL,
3062306a36Sopenharmony_ci	IFA_LABEL,
3162306a36Sopenharmony_ci	IFA_BROADCAST,
3262306a36Sopenharmony_ci	IFA_ANYCAST,
3362306a36Sopenharmony_ci	IFA_CACHEINFO,
3462306a36Sopenharmony_ci	IFA_MULTICAST,
3562306a36Sopenharmony_ci	IFA_FLAGS,
3662306a36Sopenharmony_ci	IFA_RT_PRIORITY,	/* u32, priority/metric for prefix route */
3762306a36Sopenharmony_ci	IFA_TARGET_NETNSID,
3862306a36Sopenharmony_ci	IFA_PROTO,		/* u8, address protocol */
3962306a36Sopenharmony_ci	__IFA_MAX,
4062306a36Sopenharmony_ci};
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define IFA_MAX (__IFA_MAX - 1)
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/* ifa_flags */
4562306a36Sopenharmony_ci#define IFA_F_SECONDARY		0x01
4662306a36Sopenharmony_ci#define IFA_F_TEMPORARY		IFA_F_SECONDARY
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define	IFA_F_NODAD		0x02
4962306a36Sopenharmony_ci#define IFA_F_OPTIMISTIC	0x04
5062306a36Sopenharmony_ci#define IFA_F_DADFAILED		0x08
5162306a36Sopenharmony_ci#define	IFA_F_HOMEADDRESS	0x10
5262306a36Sopenharmony_ci#define IFA_F_DEPRECATED	0x20
5362306a36Sopenharmony_ci#define IFA_F_TENTATIVE		0x40
5462306a36Sopenharmony_ci#define IFA_F_PERMANENT		0x80
5562306a36Sopenharmony_ci#define IFA_F_MANAGETEMPADDR	0x100
5662306a36Sopenharmony_ci#define IFA_F_NOPREFIXROUTE	0x200
5762306a36Sopenharmony_ci#define IFA_F_MCAUTOJOIN	0x400
5862306a36Sopenharmony_ci#define IFA_F_STABLE_PRIVACY	0x800
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_cistruct ifa_cacheinfo {
6162306a36Sopenharmony_ci	__u32	ifa_prefered;
6262306a36Sopenharmony_ci	__u32	ifa_valid;
6362306a36Sopenharmony_ci	__u32	cstamp; /* created timestamp, hundredths of seconds */
6462306a36Sopenharmony_ci	__u32	tstamp; /* updated timestamp, hundredths of seconds */
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/* backwards compatibility for userspace */
6862306a36Sopenharmony_ci#ifndef __KERNEL__
6962306a36Sopenharmony_ci#define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
7062306a36Sopenharmony_ci#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
7162306a36Sopenharmony_ci#endif
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci/* ifa_proto */
7462306a36Sopenharmony_ci#define IFAPROT_UNSPEC		0
7562306a36Sopenharmony_ci#define IFAPROT_KERNEL_LO	1	/* loopback */
7662306a36Sopenharmony_ci#define IFAPROT_KERNEL_RA	2	/* set by kernel from router announcement */
7762306a36Sopenharmony_ci#define IFAPROT_KERNEL_LL	3	/* link-local set by kernel */
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#endif
80