hwaddr_matches
Description:
Generalized hardware address comparison function.
Tests if hwaddr1
and hwaddr2
"equal" (or more precisely, "equivalent"), with several advantages over a simple
cmp:
- If
hwaddr1_len
orhwaddr2_len
is -1, then the corresponding address is assumed to be ASCII rather than binary, and will be converted to binary before being compared. - If
hwaddr1
orhwaddr2
is null, it is treated instead as though it was a zero-filled bufferhwaddr1_len
orhwaddr2_len
bytes long. - If
hwaddr1
andhwaddr2
are InfiniBand hardware addresses (that is, if they are <literal>INFINIBAND_ALEN< /literal> bytes long in binary form) then only the last 8 bytes are compared, since those are the only bytes that actually identify the hardware. (The other 12 bytes will change depending on the configuration of the InfiniBand fabric that the device is connected to.)
If a passed-in ASCII hardware address cannot be parsed, or would parse to an address larger than nm_utils_hwaddr_len_max, then it will silently fail to match. (This means that externally-provided address strings do not need to be sanity-checked before comparing them against known good addresses; they are guaranteed to not match if they are invalid.)
Parameters:
hwaddr1 |
pointer to a binary or ASCII hardware address, or null |
hwaddr1_len |
size of |
hwaddr2 |
pointer to a binary or ASCII hardware address, or null |
hwaddr2_len |
size of |
Returns:
true if |