summaryrefslogtreecommitdiff
path: root/include/openvswitch/ofp-match.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-02-09 10:04:26 -0800
committerBen Pfaff <blp@ovn.org>2018-02-13 10:43:13 -0800
commit0d71302e36c4ad290cb3b36363b48756fb438c59 (patch)
tree2b2095496fb8d2c94d891e57047deea4c9f4712a /include/openvswitch/ofp-match.h
parent31292693fc3a845a5f40102fcbf500cfe3167290 (diff)
downloadopenvswitch-0d71302e36c4ad290cb3b36363b48756fb438c59.tar.gz
ofp-util, ofp-parse: Break up into many separate modules.
ofp-util had been far too large and monolithic for a long time. This commit breaks it up into units that make some logical sense. It also moves the pieces of ofp-parse that were specific to each unit into the relevant unit. Most of this commit is just moving code around. Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Diffstat (limited to 'include/openvswitch/ofp-match.h')
-rw-r--r--include/openvswitch/ofp-match.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/include/openvswitch/ofp-match.h b/include/openvswitch/ofp-match.h
new file mode 100644
index 000000000..f2d4a0df9
--- /dev/null
+++ b/include/openvswitch/ofp-match.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2008-2017 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPENVSWITCH_OFP_MATCH_H
+#define OPENVSWITCH_OFP_MATCH_H 1
+
+#include "openflow/openflow.h"
+#include "openvswitch/list.h"
+#include "openvswitch/ofp-protocol.h"
+
+struct vl_mff_map;
+struct flow_wildcards;
+struct match;
+struct tun_table;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Converting OFPFW10_NW_SRC_MASK and OFPFW10_NW_DST_MASK wildcard bit counts
+ * to and from IP bitmasks. */
+ovs_be32 ofputil_wcbits_to_netmask(int wcbits);
+int ofputil_netmask_to_wcbits(ovs_be32 netmask);
+
+/* Work with ofp10_match. */
+void ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *);
+void ofputil_match_from_ofp10_match(const struct ofp10_match *,
+ struct match *);
+void ofputil_normalize_match(struct match *);
+void ofputil_normalize_match_quiet(struct match *);
+void ofputil_match_to_ofp10_match(const struct match *, struct ofp10_match *);
+
+/* Work with ofp11_match. */
+enum ofperr ofputil_pull_ofp11_match(struct ofpbuf *, const struct tun_table *,
+ const struct vl_mff_map *, struct match *,
+ uint16_t *padded_match_len);
+enum ofperr ofputil_match_from_ofp11_match(const struct ofp11_match *,
+ struct match *);
+int ofputil_put_ofp11_match(struct ofpbuf *, const struct match *,
+ enum ofputil_protocol);
+void ofputil_match_to_ofp11_match(const struct match *, struct ofp11_match *);
+int ofputil_match_typical_len(enum ofputil_protocol);
+
+/* dl_type translation between OpenFlow and 'struct flow' format. */
+ovs_be16 ofputil_dl_type_to_openflow(ovs_be16 flow_dl_type);
+ovs_be16 ofputil_dl_type_from_openflow(ovs_be16 ofp_dl_type);
+
+struct ofputil_tlv_map {
+ struct ovs_list list_node;
+
+ uint16_t option_class;
+ uint8_t option_type;
+ uint8_t option_len;
+ uint16_t index;
+};
+
+struct ofputil_tlv_table_mod {
+ uint16_t command;
+ struct ovs_list mappings; /* Contains "struct ofputil_tlv_map"s. */
+};
+
+struct ofputil_tlv_table_reply {
+ uint32_t max_option_space;
+ uint16_t max_fields;
+ struct ovs_list mappings; /* Contains "struct ofputil_tlv_map"s. */
+};
+
+struct ofpbuf *ofputil_encode_tlv_table_mod(enum ofp_version ofp_version,
+ struct ofputil_tlv_table_mod *);
+enum ofperr ofputil_decode_tlv_table_mod(const struct ofp_header *,
+ struct ofputil_tlv_table_mod *);
+struct ofpbuf *ofputil_encode_tlv_table_reply(
+ const struct ofp_header *, struct ofputil_tlv_table_reply *);
+enum ofperr ofputil_decode_tlv_table_reply(
+ const struct ofp_header *, struct ofputil_tlv_table_reply *);
+char *parse_ofp_tlv_table_mod_str(struct ofputil_tlv_table_mod *,
+ uint16_t command, const char *string,
+ enum ofputil_protocol *usable_protocols)
+ OVS_WARN_UNUSED_RESULT;
+
+void ofputil_uninit_tlv_table(struct ovs_list *mappings);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ofp-match.h */