static void parse_field(const struct mf_field *mf, const char *s, struct match *match) { union mf_value value, mask; char *error; error = mf_parse(mf, s, &value, &mask); if (error) { ovs_fatal(0, "%s", error); } mf_set(mf, &value, &mask, match); }
/* Parses 's' as the (possibly masked) value of field 'mf', and updates * 'match' appropriately. Restricts the set of usable protocols to ones * supporting the parsed field. * * Returns NULL if successful, otherwise a malloc()'d string describing the * error. The caller is responsible for freeing the returned string. */ char * OVS_WARN_UNUSED_RESULT ofp_parse_field(const struct mf_field *mf, const char *s, const struct ofputil_port_map *port_map, struct match *match, enum ofputil_protocol *usable_protocols) { union mf_value value, mask; char *error; if (!*s) { /* If there's no string, we're just trying to match on the * existence of the field, so use a no-op value. */ s = "0/0"; } error = mf_parse(mf, s, port_map, &value, &mask); if (!error) { *usable_protocols &= mf_set(mf, &value, &mask, match, &error); match_add_ethernet_prereq(match, mf); } return error; }