this will help This will get you started. I didn't bother including the "link local" address range, but that's an exercise left for you to complete by modifying the code below. IPV6 is slightly different. And your question is slightly malformed since most systems don't have a native 128-bit type. IPv6 addresses are usually contained as an array of 16 bytes embedded in a sockaddr_in6 struct.
// assumes ip is in HOST order. Use ntohl() to convert as approrpriate
bool IsPrivateAddress(uint32_t ip)
uint8_t b1, b2, b3, b4;
b1 = (uint8_t)(ip >> 24);
b2 = (uint8_t)((ip >> 16) & 0x0ff);
b3 = (uint8_t)((ip >> 8) & 0x0ff);
b4 = (uint8_t)(ip & 0x0ff);
if (b1 == 10)
// 172.16.0.0 - 172.31.255.255
if ((b1 == 172) && (b2 >= 16) && (b2 <= 31))
// 192.168.0.0 - 192.168.255.255
if ((b1 == 192) && (b2 == 168))
How to extract local computers Site Local and Link Local IPv6 address in Delphi?
it helps some times Site local addresses have been deprecated. Unique local addresses are designed to be used instead. Because site local addresses would cause conflicts when setting up VPNs between networks and when merging networks they were deprecated. Unique local addresses make sure that each network uses different addresses so that linking and merging won't be a problem.
How to transform a link-local IPv6 address into the corresponding global unicast address?
hop of those help? IPv6 link-local and global unicast addresses have no real relationship to each other. In fact, you could have multiple IPv6 global unicast addresses on an interface, and then which one would you want to resolve? You may also not have any IPv6 global unicast addresses on an interface; only a link-local address, or one or more ULA addresses along with the link-local address. You could also have a combination of global unicast and ULA addresses (including single or multiple addresses of each type).
Converting mac address to IPv6 link local address in Ruby
hop of those help? Here is your main problem: Ruby is an object-oriented language. You create programs by manipulating rich, structured objects, more precisely by telling rich, structured objects to manipulate themselves. You, however, are manipulating Strings. Now, of course, Strings are also objects in Ruby, but they are objects which represent text, they are not objects which represent IP addresses or EUIs.
eui48 = '00-16-3E-15-D3-A9'
# eliminate all delimiters, note that only ':' is not enough; the standard is '-', but '.' is also sometimes used
eui48 = eui48.gsub(/[^0-9a-zA-Z]/, '')
# parse the EUI-48 as a number
eui48 = eui48.to_i(16)
# split the EUI-48 into the OUI and the manufacturer-assigned parts
oui, assigned = eui48.divmod(1 << 24)
# append 16 zero bits to the OUI
left = oui << 16
# add the standard bit sequence
left += 0xfffe
# append 24 zero bits
left <<= 24
# now we have an EUI-64
eui64 = left + assigned
# flip bit index 57 to create a modified EUI-64
modified_eui64 = eui64 ^ 1 << 57
# the prefix for link-local IPv6 addresses is fe80::/10, link-local addresses are in the fe80::/64 network
prefix = IPAddr.new('fe80::/64')
# the suffix is based on our modified EUI-64
suffix = IPAddr.new(modified_eui64, Socket::AF_INET6)
# the final result is the bitwise logical OR of the prefix and suffix
link_local_ipv6 = prefix | suffix
# the IP address library knows how to correctly format an address according to RFC 5952 Section 4