Updated (Aug 3, 2016): After searching on and off for the past couple months on this question (because I'm actually in need of this answer myself). I believe I have found the Windows-centric answer. I've only tested this on Windows 10, so I don't know about older versions. But this API shouldn't have changed if someone wants to verify it for me :-)
All _IP_ADAPTER_UNICAST_ADDRESS structures have an enumeration for the address prefix and suffix. I've now bothered to look at them and they are the entire key to solving this issue!
What is a Temporary IPv6 address....it's an address with a RANDOM SUFFIX! So for all IPv6 addresses in a IP_ADAPTER_UNICAST_ADDRESS look at the IP_SUFFIX_ORIGIN see if it is IpSuffixOriginRandom. Thats...it.
I'm really still shocked at how little there on this topic online and this will be a huge issue in a few years for network application developers if no one knows how to solve this issue for server-side applications (even ones running on consumer PCs)
You heard the answer here first!!!
(Original Answer): I've been looking at this exact topic for a cross-platform application as well. I think I've found "a" way to filter IPv6 temporary addresses in Windows. Basically RFC 4941 claims temporary addresses must:
- Have a Valid Lifetime less than the "Public" Address
- Have a Preferred Lifetime less than the "Public" Address
So for C++, when using a function like GetAdaptersAddresses you can look in the PIP_ADAPTER_ADDRESSES struct for the _IP_ADAPTER_UNICAST_ADDRESS struct and evaluate the ValidLifetime and PreferredLifetime members. After filtering for address type (if you need to know Local-Link vs Public) you can keep a running tally of the largest lifetime. The largest life time (per adapter) should be the public address!
To see the address lifetime info quickly run the Windows terminal command: netsh interface ipv6 show address
You can see all temporary addresses are much smaller than the defaulted SLAAC lifetimes.
I'm working with this assumption for now until testing proves otherwise. All Temporary addresses are based on the public and so cannot out live it.
Hope this helps
octl
on OS X that does the trick? – Fascinating<netinet6/in6_var.h>
is not include in iOS on devices. I suspect Apple does not want anyone to know if IPv6 addresses on iOS are private/temporary. – Fascinating