networkd: address - add hash helpers for Address objects
authorTom Gundersen <teg@jklm.no>
Tue, 22 Sep 2015 15:54:27 +0000 (17:54 +0200)
committerTom Gundersen <teg@jklm.no>
Sun, 11 Oct 2015 13:03:04 +0000 (15:03 +0200)
commit3ac8e5433f20bfb5e12b918252643106a2de52af
tree1114150ee49b728395a2669e79db5ef0e6335d64
parent7d20d3759e375367c36471906ba898c6909d5132
networkd: address - add hash helpers for Address objects

Add compare_func and hash_func for the Address object. The notion of
address equality is the same as in the kernel, and hashing preserves
preserves equality.

Two addresses are considered equal if:
   - they have the same address family, and
     - they are neither IPv4 nor IPv6 addresses, or
     - the local addresses are identical, and
       - they are IPv6 addresses, or
         - they have the same prefixlength, and
         - their peer prefixes are identical

This fixes a bug in the old equality check, which got the local address
and the peer prefix mixed up.
src/network/networkd-address.c
src/network/test-network.c