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