Skip to content

Convert IPv4 mapped IPv6 subnet masks to 4 bytes from 16 bytes (using the last 4 bytes)#30

Open
damilola-bello wants to merge 1 commit intoyl2chen:masterfrom
aterlo:master
Open

Convert IPv4 mapped IPv6 subnet masks to 4 bytes from 16 bytes (using the last 4 bytes)#30
damilola-bello wants to merge 1 commit intoyl2chen:masterfrom
aterlo:master

Conversation

@damilola-bello
Copy link
Copy Markdown

@yl2chen
Currently, you can't add IPv4 mapped IPv6 networks.

For example, If you try insert ::ffff:d1ad:35a7/128, a nil network will be inserted. This uses ipV4Ranger (as it is stored as IPv4 address internally), but the mask isn't converted and remains 16 bytes. Hence you have something like this 209.173.53.167/128 instead of 209.173.53.167/32.

func (n Network) Masked(ones int) Network {
mask := net.CIDRMask(ones, len(n.Number)*BitsPerUint32)
return NewNetwork(net.IPNet{
IP: n.IP.Mask(mask),
Mask: mask,
})
}

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.09%) to 91.327% when pulling 6ba34bb on aterlo:master into e434ea7 on yl2chen:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants