2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-17 14:28:02 +00:00

flow: Move functions for dealing with wildcard bit counts to ofp-util.

These functions are really OpenFlow-specific, and they will not be used
directly by the flow code soon, so move them to ofp-util.
This commit is contained in:
Ben Pfaff
2010-11-22 10:09:18 -08:00
parent 00561f415c
commit 0596e89755
6 changed files with 66 additions and 45 deletions

View File

@@ -23,6 +23,7 @@
#include <stdint.h>
#include <string.h>
#include "compiler.h"
#include "openvswitch/types.h"
#include "random.h"
#include "util.h"
@@ -246,6 +247,15 @@ BUILD_ASSERT_DECL(VLAN_ETH_HEADER_LEN == sizeof(struct vlan_eth_header));
((uint8_t *) ip)[2], \
((uint8_t *) ip)[3]
/* Returns true if 'netmask' is a CIDR netmask, that is, if it consists of N
* high-order 1-bits and 32-N low-order 0-bits. */
static inline bool
ip_is_cidr(ovs_be32 netmask)
{
uint32_t x = ~ntohl(netmask);
return !(x & (x + 1));
}
#define IP_VER(ip_ihl_ver) ((ip_ihl_ver) >> 4)
#define IP_IHL(ip_ihl_ver) ((ip_ihl_ver) & 15)
#define IP_IHL_VER(ihl, ver) (((ver) << 4) | (ihl))