Improved IPv6 netmask parsing
The subnet mask parsing in toV6CIDR only worked for very well behaved
subnet strings. This became apparent after the BMC received a DHCP
assigned IPv6 address with an Address Prefix equal to /128. Any
netmask values trailing the final ":" character were ignored. In
addition it assumed all subnet entries would be submitted in shorthand
form.
The changes here handle mask values supplied following the final ":"
character. It also does more sanity checking on the incoming subnet
string.
Tested:
Supplied the function with the following test patterns, and confirmed
the function returns accurate address prefix values.
ffff:ffff::
ffff:ffff:ffff::
ffff:ffff:fc00::
ffff:0:0:0:0:0:0:0
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffc
ffff:0fff::
ffff:fgff::
ffff:0:0:6:0:0:0:0
::
:
abcd:efgh:ijkl:mnop:pqrs:tuvw:xyz:abcd
ffff:0:0:0:0:0:0
Change-Id: Ib2c73fe07a6a3f1c7a5f0e8f231dfef21badb3af
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2 files changed