mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
Allow general masking of IPv4 addresses rather than just CIDR masks.
OF1.1 and later make these fields fully maskable so we might as well also. Reviewed-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -246,12 +246,13 @@ eth_addr_bitand(const uint8_t src[ETH_ADDR_LEN],
|
||||
}
|
||||
|
||||
/* Given the IP netmask 'netmask', returns the number of bits of the IP address
|
||||
* that it specifies, that is, the number of 1-bits in 'netmask'. 'netmask'
|
||||
* must be a CIDR netmask (see ip_is_cidr()). */
|
||||
* that it specifies, that is, the number of 1-bits in 'netmask'.
|
||||
*
|
||||
* If 'netmask' is not a CIDR netmask (see ip_is_cidr()), the return value will
|
||||
* still be in the valid range but isn't otherwise meaningful. */
|
||||
int
|
||||
ip_count_cidr_bits(ovs_be32 netmask)
|
||||
{
|
||||
assert(ip_is_cidr(netmask));
|
||||
return 32 - ctz(ntohl(netmask));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user