X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fclassifier.c;h=cdad9c9e1bc8caf44d32c48ec4680caabe2ff027;hb=1e86ae6f51bcc91d2fa36e4154bc6e540251eaf8;hp=02cb02302c91b3082a6e0de56686a5bbbe6d9cff;hpb=49bdc010dfc9f396eec608148ca0f4ea71a0c4dd;p=openvswitch diff --git a/lib/classifier.c b/lib/classifier.c index 02cb0230..cdad9c9e 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -19,6 +19,7 @@ #include #include #include +#include "dynamic-string.h" #include "flow.h" #include "hash.h" @@ -57,6 +58,7 @@ void cls_rule_from_flow(struct cls_rule *rule, const flow_t *flow, uint32_t wildcards, unsigned int priority) { + assert(!flow->reserved[0] && !flow->reserved[1] && !flow->reserved[2]); rule->flow = *flow; flow_wildcards_init(&rule->wc, wildcards); rule->priority = priority; @@ -76,6 +78,18 @@ cls_rule_from_match(struct cls_rule *rule, const struct ofp_match *match, rule->table_idx = table_idx_from_wildcards(rule->wc.wildcards); } +/* Converts 'rule' to a string and returns the string. The caller must free + * the string (with free()). */ +char * +cls_rule_to_string(const struct cls_rule *rule) +{ + struct ds s = DS_EMPTY_INITIALIZER; + ds_put_format(&s, "wildcards=%x priority=%u ", + rule->wc.wildcards, rule->priority); + flow_format(&s, &rule->flow); + return ds_cstr(&s); +} + /* Prints cls_rule 'rule', for debugging. * * (The output could be improved and expanded, but this was good enough to