return !wc->masks.metadata;
case MFF_IN_PORT:
case MFF_IN_PORT_OXM:
- return !wc->masks.in_port;
+ return !wc->masks.in_port.ofp_port;
case MFF_SKB_PRIORITY:
return !wc->masks.skb_priority;
case MFF_SKB_MARK:
return true;
case MFF_IN_PORT_OXM: {
- uint16_t port;
+ ofp_port_t port;
return !ofputil_port_from_ofp11(value->be32, &port);
}
break;
case MFF_IN_PORT:
- value->be16 = htons(flow->in_port);
+ value->be16 = htons(ofp_to_u16(flow->in_port.ofp_port));
break;
-
case MFF_IN_PORT_OXM:
- value->be32 = ofputil_port_to_ofp11(flow->in_port);
+ value->be32 = ofputil_port_to_ofp11(flow->in_port.ofp_port);
break;
case MFF_SKB_PRIORITY:
break;
case MFF_IN_PORT:
- match_set_in_port(match, ntohs(value->be16));
+ match_set_in_port(match, u16_to_ofp(ntohs(value->be16)));
break;
case MFF_IN_PORT_OXM: {
- uint16_t port;
+ ofp_port_t port;
ofputil_port_from_ofp11(value->be32, &port);
match_set_in_port(match, port);
break;
}
}
-/* Makes 'match' match field 'mf' exactly, with the value matched taken from
- * 'value'. The caller is responsible for ensuring that 'match' meets 'mf''s
- * prerequisites. */
+/* Sets 'flow' member field described by 'mf' to 'value'. The caller is
+ * responsible for ensuring that 'flow' meets 'mf''s prerequisites.*/
void
mf_set_flow_value(const struct mf_field *mf,
const union mf_value *value, struct flow *flow)
break;
case MFF_IN_PORT:
- flow->in_port = ntohs(value->be16);
+ flow->in_port.ofp_port = u16_to_ofp(ntohs(value->be16));
break;
case MFF_IN_PORT_OXM: {
- uint16_t port;
+ ofp_port_t port;
ofputil_port_from_ofp11(value->be32, &port);
- flow->in_port = port;
+ flow->in_port.ofp_port = port;
break;
}
case MFF_IN_PORT:
case MFF_IN_PORT_OXM:
- match->flow.in_port = 0;
- match->wc.masks.in_port = 0;
+ match->flow.in_port.ofp_port = 0;
+ match->wc.masks.in_port.ofp_port = 0;
break;
case MFF_SKB_PRIORITY:
break;
case MFF_IN_PORT_OXM:
- value->be32 = ofputil_port_to_ofp11(ntohs(value->be16));
+ value->be32 = ofputil_port_to_ofp11(u16_to_ofp(ntohs(value->be16)));
break;
case MFF_IPV6_LABEL:
mf_from_ofp_port_string(const struct mf_field *mf, const char *s,
ovs_be16 *valuep, ovs_be16 *maskp)
{
- uint16_t port;
+ ofp_port_t port;
ovs_assert(mf->n_bytes == sizeof(ovs_be16));
if (ofputil_port_from_string(s, &port)) {
- *valuep = htons(port);
+ *valuep = htons(ofp_to_u16(port));
*maskp = htons(UINT16_MAX);
return NULL;
}
mf_from_ofp_port_string32(const struct mf_field *mf, const char *s,
ovs_be32 *valuep, ovs_be32 *maskp)
{
- uint16_t port;
+ ofp_port_t port;
ovs_assert(mf->n_bytes == sizeof(ovs_be32));
if (ofputil_port_from_string(s, &port)) {
switch (mf->string) {
case MFS_OFP_PORT_OXM:
if (!mask) {
- uint16_t port;
+ ofp_port_t port;
ofputil_port_from_ofp11(value->be32, &port);
ofputil_format_port(port, s);
break;
/* fall through */
case MFS_OFP_PORT:
if (!mask) {
- ofputil_format_port(ntohs(value->be16), s);
+ ofputil_format_port(u16_to_ofp(ntohs(value->be16)), s);
break;
}
/* fall through */
* bit indexes. "..end" may be omitted to indicate a single bit. "start..end"
* may both be omitted (the [] are still required) to indicate an entire
* field. */
-char *
+char * WARN_UNUSED_RESULT
mf_parse_subfield__(struct mf_subfield *sf, const char **sp)
{
const struct mf_field *field;
return NULL;
}
-/* Parses a subfield from the beginning of 's' into 'sf'. Returns the first
- * byte in 's' following the parsed string.
- *
- * Exits with an error message if 's' has incorrect syntax.
+/* Parses a subfield from the entirety of 's' into 'sf'. Returns NULL if
+ * successful, otherwise a malloc()'d string describing the error. The caller
+ * is responsible for freeing the returned string.
*
* The syntax parsed from 's' takes the form "header[start..end]" where
* 'header' is the name of an NXM field and 'start' and 'end' are (inclusive)
* bit indexes. "..end" may be omitted to indicate a single bit. "start..end"
* may both be omitted (the [] are still required) to indicate an entire
* field. */
-const char *
+char * WARN_UNUSED_RESULT
mf_parse_subfield(struct mf_subfield *sf, const char *s)
{
- char *msg = mf_parse_subfield__(sf, &s);
- if (msg) {
- ovs_fatal(0, "%s", msg);
+ char *error = mf_parse_subfield__(sf, &s);
+ if (!error && s[0]) {
+ error = xstrdup("unexpected input following field syntax");
}
- return s;
+ return error;
}
void