ipaddr
ipaddr copied to clipboard
Make correct mask when converting IPv4 <=> IPv6
When converting IPv4 to/from IPv6, IPAddr#set
generates incorrect mask value.
This causes IPAddr#include?
returns incorrect result.
ip4 = IPAddr.new('::ffff:127.0.0.1').native
p [ip4.to_s, ip4.prefix]
ip6 = IPAddr.new('127.0.0.1').ipv4_mapped
p [ip6.to_s, ip6.prefix]
Expected
["127.0.0.1", 32]
["::ffff:127.0.0.1", 128]
Actual
["127.0.0.1", -96] # @mask_addr == 0xFFFFFFFFFFFFFFFF
["::ffff:127.0.0.1", 0] # @mask_addr == 0x000000000000FFFF
@Tietew can you rebase on master.
@ioquatix done.
Can you please squash typo fix.