troglobit / netcalc

Simplified clone of sipcalc with ipcalc looks
BSD 3-Clause "New" or "Revised" License
67 stars 12 forks source link

IPv6 address types are missing ULA #13

Closed dkerr64 closed 7 years ago

dkerr64 commented 7 years ago

RFC 4193 specifies range of IPv6 for Unique Local Addressing unicast. Netcalc is not recognizing those, instead returning "Unassigned"

David

troglobit commented 7 years ago

That's unfortunate. Care to submit a small patch or pull request? :)

dkerr64 commented 7 years ago

I will try and find some time this evening.

David

troglobit commented 7 years ago

Got a bit curious myself. Would this work? :dizzy_face:

diff --git a/misc.c b/misc.c
index 085069d..06533e6 100644
--- a/misc.c
+++ b/misc.c
@@ -1040,6 +1040,8 @@ void v6_type(struct v6addr *in6_addr)
                snprintf(buf, len, "Reserved");
        if ((a & 0xff00) == 0xff00)
                snprintf(buf, len, "Multicast Addresses");
+       if ((a & 0xfc00) == 0xfc00 && in6_addr->nmaskbits == 7)
+               snprintf(buf, len, "Unique Local Unicast");
        if ((a & 0xff80) == 0xfe80)
                snprintf(buf, len, "Link-Local Unicast Addresses");
        if ((a & 0xffc0) == 0xfec0)
abelbeck commented 7 years ago

ULA's use /48 prefixes.

labeling any ((a & 0xfd00) == 0xfd00) should be enough, I think...

Ref: http://unique-local-ipv6.com

dkerr64 commented 7 years ago

I think it would be useful to have separate message for fc00 and fd00. Most (if not all for now) ULA's will be fdxx (signifying a "locally-assigned ULA") as a value of 0 in the least significant bit is reserved for future use. I would use the terms.. fd00... Locally-Assigned Unique Local Address fc00... Unique Local Address Who knows, at some point in the future the difference might be meaningful.

David

troglobit commented 7 years ago

Aha, I see. I was reading https://tools.ietf.org/html/rfc4193#section-8, so that's what confused me.

OK, I'll add two new types and reference this issue, if you can audit it later I'd be very grateful :)

troglobit commented 7 years ago

GitHub auto-closes issues with 'Fix #...'. If you find a problem with 694614e, just reopen this issue.

I'll hold off the v2.1 release another day.