I want to get specific attributes associated with an IPv6 address on a network interface. (Basically I want to know whether this IP address is anycast address, detached, tentative, duplicated, or deprecated. If the address has any of these properties, I want to discard this address.)
For macOS, I can use ioctl command to get this done.
ioctl (ioctl_socket, SIOCGIFAFLAG_IN6, &ifr);
Here, in the last parameter, I am passing a struct of type in6_ifreq. It contains interface name and the IP address (which will be IPv6 address). Interface name and IP address are obtained by getifaddrs
API.
On making ioctl call, flags will be set in the in6_ifreq struct (ifr).
This flag contains the required information of the IP address.
For macOS, this information can be obtained by following expression.
bool shouldDiscard = ifr.ifr_ifru.ifru_flags & (IN6_IFF_ANYCAST | IN6_IFF_DETACHED | IN6_IFF_TENTATIVE | IN6_IFF_DUPLICATED | IN6_IFF_DEPRECATED)
These flags (IN6_IFF_ANYCAST, IN6_IFF_DETACHED, etc.) are defined in the header file netinet6/in6_var.h for macOS.
But, for iOS, iPadOS, tvOS this file is not present there.
So, is there any other way to get these IPv6 specific attributes in these operating systems using the same approach or any different approach? I'm interested in only these five flags mentioned above.
I tried to look for relevant header file in iOS which could contain these flags, but I couldn't find them anywhere.