Rewrite, fix and improve str2net().
authorEtienne Dechamps <etienne@edechamps.fr>
Sat, 5 Jul 2014 17:05:55 +0000 (18:05 +0100)
committerEtienne Dechamps <etienne@edechamps.fr>
Sat, 5 Jul 2014 19:00:50 +0000 (20:00 +0100)
This is a complete rewrite of the str2net() function. Besides
refactoring duplicate code, this new code brings the following fixes
and improvements:

 - Fixes handling of leading/trailing double colon in IPv6 addresses.
   For example, with the previous code the address
   2001:0db8:85a3:0000:0000:8a2e:0370:: is interpreted as a MAC address,
   and ::0db8:85a3:0000:0000:8a2e:0370:7334 is rejected.

 - Catches more invalid cases, such as garbage at the end of the string.

 - Adds support for dotted quad notation in IPv6 (e.g. ::1.2.3.4).

See RFC 4291, section 2.2 for details on the textual format of IPv6
addresses.


No differences found