mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
openvswitch/types.h: New macros OVS_BE16_MAX, OVS_BE32_MAX, OVS_BE64_MAX.
These seem slightly nicer than e.g. htons(UINT16_MAX). Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -2310,12 +2310,12 @@ mf_from_ipv4_string(const struct mf_field *mf, const char *s,
|
||||
return xasprintf("%s: network prefix bits not between 1 and "
|
||||
"32", s);
|
||||
} else if (prefix == 32) {
|
||||
*mask = htonl(UINT32_MAX);
|
||||
*mask = OVS_BE32_MAX;
|
||||
} else {
|
||||
*mask = htonl(((1u << prefix) - 1) << (32 - prefix));
|
||||
}
|
||||
} else if (sscanf(s, IP_SCAN_FMT, IP_SCAN_ARGS(ip)) == IP_SCAN_COUNT) {
|
||||
*mask = htonl(UINT32_MAX);
|
||||
*mask = OVS_BE32_MAX;
|
||||
} else {
|
||||
return xasprintf("%s: invalid IP address", s);
|
||||
}
|
||||
@@ -2373,7 +2373,7 @@ mf_from_ofp_port_string(const struct mf_field *mf, const char *s,
|
||||
|
||||
if (ofputil_port_from_string(s, &port)) {
|
||||
*valuep = htons(ofp_to_u16(port));
|
||||
*maskp = htons(UINT16_MAX);
|
||||
*maskp = OVS_BE16_MAX;
|
||||
return NULL;
|
||||
}
|
||||
return xasprintf("%s: port value out of range for %s", s, mf->name);
|
||||
@@ -2388,7 +2388,7 @@ mf_from_ofp_port_string32(const struct mf_field *mf, const char *s,
|
||||
ovs_assert(mf->n_bytes == sizeof(ovs_be32));
|
||||
if (ofputil_port_from_string(s, &port)) {
|
||||
*valuep = ofputil_port_to_ofp11(port);
|
||||
*maskp = htonl(UINT32_MAX);
|
||||
*maskp = OVS_BE32_MAX;
|
||||
return NULL;
|
||||
}
|
||||
return xasprintf("%s: port value out of range for %s", s, mf->name);
|
||||
@@ -2493,7 +2493,7 @@ static char *
|
||||
mf_from_tun_flags_string(const char *s, ovs_be16 *valuep, ovs_be16 *maskp)
|
||||
{
|
||||
if (!parse_flow_tun_flags(s, flow_tun_flag_to_string, valuep)) {
|
||||
*maskp = htons(UINT16_MAX);
|
||||
*maskp = OVS_BE16_MAX;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2661,8 +2661,7 @@ mf_format(const struct mf_field *mf,
|
||||
break;
|
||||
|
||||
case MFS_IPV4:
|
||||
ip_format_masked(value->be32, mask ? mask->be32 : htonl(UINT32_MAX),
|
||||
s);
|
||||
ip_format_masked(value->be32, mask ? mask->be32 : OVS_BE32_MAX, s);
|
||||
break;
|
||||
|
||||
case MFS_IPV6:
|
||||
|
Reference in New Issue
Block a user