开发者

How to read TENTATIVE flag of IPv6 Address?

开发者 https://www.devze.com 2023-01-06 14:18 出处:网络
I am assigning ip开发者_运维百科v6 address using ioctl() system call prgramtically. I want to know if there is a way, i can find the assigned ip is tentative/duplicate ?

I am assigning ip开发者_运维百科v6 address using ioctl() system call prgramtically. I want to know if there is a way, i can find the assigned ip is tentative/duplicate ?

Thanks.


Host: Enumerate the interfaces with getifaddrs().

(edit) Looks like you need to call sysctl(NET_IPV6_OPT_DAD_ENABLE) before getifaddrs()?

http://lwn.net/Articles/218597/

Network: Send an ICMP ping is the typical but not fool proof method that DHCP servers use.

It is assumed if you are setting the IP then you are implementing a form of DHCP and you control all the addresses for that segment. Otherwise just use the link-local scope already unique addresses.


You can read TENTATIVE flag of IPv6 Address as below:

Indicates flags that are set on the multicast address. As of RFC 2373, the only flag defined is the Transient (T) flag. The T flag uses the low-order bit of the Flags field.

* If 0, the multicast address is a permanently assigned, well-known multicast address allocated by the Internet Assigned Numbers Authority (IANA).
* If 1, the multicast address is a not permanently assigned, or transient.


One way to get the state of the address is to use the rtnetlink library via the RTM_GETADDR message which retrieves the ifaddrmsg structure which contains ifa_flags. Look at the man page here for information:

http://man7.org/linux/man-pages/man7/rtnetlink.7.html

The flags and ifaddrmsg structure are shown in if_addr.h:

https://github.com/torvalds/linux/blob/master/include/uapi/linux/if_addr.h

0

精彩评论

暂无评论...
验证码 换一张
取 消