uint64_t ntohll(ovs_be64);
#endif
-static inline void
-hton128(const ovs_u128 *src, ovs_be128 *dst)
+static inline ovs_be128
+hton128(const ovs_u128 src)
{
- dst->be64.hi = htonll(src->u64.hi);
- dst->be64.lo = htonll(src->u64.lo);
+ ovs_be128 dst;
+
+ dst.be64.hi = htonll(src.u64.hi);
+ dst.be64.lo = htonll(src.u64.lo);
+ return dst;
}
-static inline void
-ntoh128(const ovs_be128 *src, ovs_u128 *dst)
+static inline ovs_u128
+ntoh128(const ovs_be128 src)
{
- dst->u64.hi = ntohll(src->be64.hi);
- dst->u64.lo = ntohll(src->be64.lo);
+ ovs_u128 dst;
+
+ dst.u64.hi = ntohll(src.be64.hi);
+ dst.u64.lo = ntohll(src.be64.lo);
+ return dst;
}
static inline uint32_t
format_ct_label_masked(struct ds *s, const ovs_u128 *key, const ovs_u128 *mask)
{
if (!ovs_u128_is_zero(mask)) {
- ovs_be128 value;
-
- hton128(key, &value);
+ ovs_be128 value = hton128(*key);
ds_put_format(s, "ct_label=");
ds_put_hex(s, &value, sizeof value);
if (!is_all_ones(mask, sizeof(*mask))) {
- hton128(mask, &value);
+ value = hton128(*mask);
ds_put_char(s, '/');
ds_put_hex(s, &value, sizeof value);
}
break;
case MFF_CT_LABEL:
- hton128(&flow->ct_label, &value->be128);
+ value->be128 = hton128(flow->ct_label);
break;
CASE_MFF_REGS:
match_set_ct_mark(match, ntohl(value->be32));
break;
- case MFF_CT_LABEL: {
- ovs_u128 label;
-
- ntoh128(&value->be128, &label);
- match_set_ct_label(match, label);
+ case MFF_CT_LABEL:
+ match_set_ct_label(match, ntoh128(value->be128));
break;
- }
CASE_MFF_REGS:
match_set_reg(match, mf->id - MFF_REG0, ntohl(value->be32));
break;
case MFF_CT_LABEL:
- ntoh128(&value->be128, &flow->ct_label);
+ flow->ct_label = ntoh128(value->be128);
break;
CASE_MFF_REGS:
match_set_ct_mark_masked(match, ntohl(value->be32), ntohl(mask->be32));
break;
- case MFF_CT_LABEL: {
- ovs_u128 hlabel, hmask;
-
- ntoh128(&value->be128, &hlabel);
- if (mask) {
- ntoh128(&mask->be128, &hmask);
- } else {
- hmask.u64.lo = hmask.u64.hi = UINT64_MAX;
- }
- match_set_ct_label_masked(match, hlabel, hmask);
+ case MFF_CT_LABEL:
+ match_set_ct_label_masked(match, ntoh128(value->be128),
+ mask ? ntoh128(mask->be128) : OVS_U128_MAX);
break;
- }
case MFF_ETH_DST:
match_set_dl_dst_masked(match, value->mac, mask->mac);
enum mf_field_id field, enum ofp_version version,
const ovs_u128 value, const ovs_u128 mask)
{
- ovs_be128 bevalue, bemask;
-
- hton128(&value, &bevalue);
- hton128(&mask, &bemask);
+ ovs_be128 bevalue = hton128(value);
+ ovs_be128 bemask = hton128(mask);
nxm_put(b, field, version, &bevalue, &bemask, sizeof(bevalue));
}
if (verbose || (mask && !ovs_u128_is_zero(mask))) {
ovs_be128 value;
- hton128(key, &value);
+ value = hton128(*key);
ds_put_hex(ds, &value, sizeof value);
if (mask && !(ovs_u128_is_ones(mask))) {
- hton128(mask, &value);
+ value = hton128(*mask);
ds_put_char(ds, '/');
ds_put_hex(ds, &value, sizeof value);
}
ovs_be128 be_mask;
if (!parse_int_string(s, (uint8_t *)&be_value, sizeof be_value, &s)) {
- ntoh128(&be_value, value);
+ *value = ntoh128(be_value);
if (mask) {
int n;
if (error) {
return error;
}
- ntoh128(&be_mask, mask);
+ *mask = ntoh128(be_mask);
} else {
*mask = OVS_U128_MAX;
}