X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fclassifier.c;h=cdad9c9e1bc8caf44d32c48ec4680caabe2ff027;hb=02dd3123a0e312f1d33403e744af52dd6096f12d;hp=036c372bd5437a69ceb7842113c6af849a332833;hpb=ed951f15779df008e43012d99cdb51f3c5a57229;p=sliver-openvswitch.git diff --git a/lib/classifier.c b/lib/classifier.c index 036c372bd..cdad9c9e1 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" @@ -77,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