Skip to content
Snippets Groups Projects
Commit 88f59ebb authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Split IPs by family in parse_host_mac_ip_list().

Change the return value of the parse_host_mac_ip_list() function to
separate IP addresses by address family (IPv4 and IPv6).  Instead of
just putting all the addresses in the 'ip' element of the returned
hash, we now split them into three lists: 'ipv4', 'ipv6' and 'ip_Name'.
The latter element is used for IP "addresses" that are actually names
within square brackets ("[" and "]").  For example, the line

    foo     123456-789abc   192.0.2.99  2001:db8:01::0:099  [fie]

will now generate the element

    'foo' => {
        'mac'      => [ '123456-789abc' ],
        'ipv4'     => [ '192.0.2.99' ],
        'ipv6'     => [ '2001:db8:1::99' ],
        'ip_Name'  => [ 'fie' ],
        'ip'       => [ '192.0.2.99', '2001:db8:1::99', 'fie' ],
    }

in the return value.  The 'ip' element is retained for backward com-
patibility, but users are recommended to stop using it, as it will
likely be deprecated in the future.

Separating the addresses by address family is helpful in many cases,
as they often need to be treated differently or handled separately,
and users would otherwise need to do that separation themselves.  In
particular, a primary use for this function is to provide data for
DHCP servers, and at least the ISC DHCP server needs entirely separate
config files for DHCPv4 and DHCPv6.

IP addresses will now also be canonicalized and duplicate addresses
for each host will be removed.  (MAC addresses are however at the
moment *not* canonicalized, although that may be added in the future.)

Words in the IP address part of a line that are not valid numerical
IP addresses or symbolic names within square brackets, will now cause
an error to be raised.
parent 045144ad
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment