void
match_init_exact(struct match *match, const struct flow *flow)
{
+ ovs_be64 tun_id = flow->tunnel.tun_id;
+
match->flow = *flow;
match->flow.skb_priority = 0;
+ memset(&match->flow.tunnel, 0, sizeof match->flow.tunnel);
+ match->flow.tunnel.tun_id = tun_id;
flow_wildcards_init_exact(&match->wc);
}
void
match_set_tun_id_masked(struct match *match, ovs_be64 tun_id, ovs_be64 mask)
{
- match->wc.masks.tun_id = mask;
- match->flow.tun_id = tun_id & mask;
+ match->wc.masks.tunnel.tun_id = mask;
+ match->flow.tunnel.tun_id = tun_id & mask;
}
void
break;
}
}
- switch (wc->masks.tun_id) {
+ switch (wc->masks.tunnel.tun_id) {
case 0:
break;
case CONSTANT_HTONLL(UINT64_MAX):
- ds_put_format(s, "tun_id=%#"PRIx64",", ntohll(f->tun_id));
+ ds_put_format(s, "tun_id=%#"PRIx64",", ntohll(f->tunnel.tun_id));
break;
default:
ds_put_format(s, "tun_id=%#"PRIx64"/%#"PRIx64",",
- ntohll(f->tun_id), ntohll(wc->masks.tun_id));
+ ntohll(f->tunnel.tun_id),
+ ntohll(wc->masks.tunnel.tun_id));
break;
}
switch (wc->masks.metadata) {
puts(s);
free(s);
}
+\f
+/* Initializes 'dst' as a copy of 'src'. The caller must eventually free 'dst'
+ * with minimatch_destroy(). */
+void
+minimatch_init(struct minimatch *dst, const struct match *src)
+{
+ miniflow_init(&dst->flow, &src->flow);
+ minimask_init(&dst->mask, &src->wc);
+}
+
+/* Initializes 'dst' as a copy of 'src'. The caller must eventually free 'dst'
+ * with minimatch_destroy(). */
+void
+minimatch_clone(struct minimatch *dst, const struct minimatch *src)
+{
+ miniflow_clone(&dst->flow, &src->flow);
+ minimask_clone(&dst->mask, &src->mask);
+}
+
+/* Frees any memory owned by 'match'. Does not free the storage in which
+ * 'match' itself resides; the caller is responsible for that. */
+void
+minimatch_destroy(struct minimatch *match)
+{
+ miniflow_destroy(&match->flow);
+ minimask_destroy(&match->mask);
+}
+
+/* Initializes 'dst' as a copy of 'src'. */
+void
+minimatch_expand(const struct minimatch *src, struct match *dst)
+{
+ miniflow_expand(&src->flow, &dst->flow);
+ minimask_expand(&src->mask, &dst->wc);
+}
+
+/* Returns true if 'a' and 'b' match the same packets, false otherwise. */
+bool
+minimatch_equal(const struct minimatch *a, const struct minimatch *b)
+{
+ return (miniflow_equal(&a->flow, &b->flow)
+ && minimask_equal(&a->mask, &b->mask));
+}
+
+/* Returns a hash value for 'match', given 'basis'. */
+uint32_t
+minimatch_hash(const struct minimatch *match, uint32_t basis)
+{
+ return miniflow_hash(&match->flow, minimask_hash(&match->mask, basis));
+}
+
+/* Appends a string representation of 'match' to 's'. If 'priority' is
+ * different from OFP_DEFAULT_PRIORITY, includes it in 's'. */
+void
+minimatch_format(const struct minimatch *match, struct ds *s,
+ unsigned int priority)
+{
+ struct match megamatch;
+
+ minimatch_expand(match, &megamatch);
+ match_format(&megamatch, s, priority);
+}
+
+/* Converts 'match' to a string and returns the string. If 'priority' is
+ * different from OFP_DEFAULT_PRIORITY, includes it in the string. The caller
+ * must free the string (with free()). */
+char *
+minimatch_to_string(const struct minimatch *match, unsigned int priority)
+{
+ struct match megamatch;
+
+ minimatch_expand(match, &megamatch);
+ return match_to_string(&megamatch, priority);
+}