Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef __LINUX_IF_ADDR_H
0003 #define __LINUX_IF_ADDR_H
0004 
0005 #include <linux/types.h>
0006 #include <linux/netlink.h>
0007 
0008 struct ifaddrmsg {
0009     __u8        ifa_family;
0010     __u8        ifa_prefixlen;  /* The prefix length        */
0011     __u8        ifa_flags;  /* Flags            */
0012     __u8        ifa_scope;  /* Address scope        */
0013     __u32       ifa_index;  /* Link index           */
0014 };
0015 
0016 /*
0017  * Important comment:
0018  * IFA_ADDRESS is prefix address, rather than local interface address.
0019  * It makes no difference for normally configured broadcast interfaces,
0020  * but for point-to-point IFA_ADDRESS is DESTINATION address,
0021  * local address is supplied in IFA_LOCAL attribute.
0022  *
0023  * IFA_FLAGS is a u32 attribute that extends the u8 field ifa_flags.
0024  * If present, the value from struct ifaddrmsg will be ignored.
0025  */
0026 enum {
0027     IFA_UNSPEC,
0028     IFA_ADDRESS,
0029     IFA_LOCAL,
0030     IFA_LABEL,
0031     IFA_BROADCAST,
0032     IFA_ANYCAST,
0033     IFA_CACHEINFO,
0034     IFA_MULTICAST,
0035     IFA_FLAGS,
0036     IFA_RT_PRIORITY,    /* u32, priority/metric for prefix route */
0037     IFA_TARGET_NETNSID,
0038     IFA_PROTO,      /* u8, address protocol */
0039     __IFA_MAX,
0040 };
0041 
0042 #define IFA_MAX (__IFA_MAX - 1)
0043 
0044 /* ifa_flags */
0045 #define IFA_F_SECONDARY     0x01
0046 #define IFA_F_TEMPORARY     IFA_F_SECONDARY
0047 
0048 #define IFA_F_NODAD     0x02
0049 #define IFA_F_OPTIMISTIC    0x04
0050 #define IFA_F_DADFAILED     0x08
0051 #define IFA_F_HOMEADDRESS   0x10
0052 #define IFA_F_DEPRECATED    0x20
0053 #define IFA_F_TENTATIVE     0x40
0054 #define IFA_F_PERMANENT     0x80
0055 #define IFA_F_MANAGETEMPADDR    0x100
0056 #define IFA_F_NOPREFIXROUTE 0x200
0057 #define IFA_F_MCAUTOJOIN    0x400
0058 #define IFA_F_STABLE_PRIVACY    0x800
0059 
0060 struct ifa_cacheinfo {
0061     __u32   ifa_prefered;
0062     __u32   ifa_valid;
0063     __u32   cstamp; /* created timestamp, hundredths of seconds */
0064     __u32   tstamp; /* updated timestamp, hundredths of seconds */
0065 };
0066 
0067 /* backwards compatibility for userspace */
0068 #ifndef __KERNEL__
0069 #define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
0070 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
0071 #endif
0072 
0073 /* ifa_proto */
0074 #define IFAPROT_UNSPEC      0
0075 #define IFAPROT_KERNEL_LO   1   /* loopback */
0076 #define IFAPROT_KERNEL_RA   2   /* set by kernel from router announcement */
0077 #define IFAPROT_KERNEL_LL   3   /* link-local set by kernel */
0078 
0079 #endif