X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fmeta-flow.c;h=fd33726e71bf0245563e8e4a87992572952fa139;hb=9bab681f33e09882e8f652c8e96a2b998b3ef9b3;hp=0de9b4557b2551aec35b2c72b19a327e65c1706b;hpb=beffe87554210fb43be20eb23251c87e5eb4b529;p=sliver-openvswitch.git diff --git a/lib/meta-flow.c b/lib/meta-flow.c index 0de9b4557..fd33726e7 100644 --- a/lib/meta-flow.c +++ b/lib/meta-flow.c @@ -2153,6 +2153,22 @@ mf_format(const struct mf_field *mf, } } +/* Makes subfield 'sf' within 'flow' exactly match the 'sf->n_bits' + * least-significant bits in 'x'. + */ +void +mf_write_subfield_flow(const struct mf_subfield *sf, + const union mf_subvalue *x, struct flow *flow) +{ + const struct mf_field *field = sf->field; + union mf_value value; + + mf_get_value(field, flow, &value); + bitwise_copy(x, sizeof *x, sf->ofs, &value, field->n_bytes, + sf->ofs, sf->n_bits); + mf_set_flow_value(field, &value, flow); +} + /* Makes subfield 'sf' within 'match' exactly match the 'sf->n_bits' * least-significant bits in 'x'. */ @@ -2335,3 +2351,20 @@ mf_parse_subfield(struct mf_subfield *sf, const char *s) } return s; } + +void +mf_format_subvalue(const union mf_subvalue *subvalue, struct ds *s) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(subvalue->u8); i++) { + if (subvalue->u8[i]) { + ds_put_format(s, "0x%"PRIx8, subvalue->u8[i]); + for (i++; i < ARRAY_SIZE(subvalue->u8); i++) { + ds_put_format(s, "%02"PRIx8, subvalue->u8[i]); + } + return; + } + } + ds_put_char(s, '0'); +}