ofp-util: Prepare Packet Out encoder for other Open Flow versions
[sliver-openvswitch.git] / lib / ofp-util.h
index 54bec75..51f0f5a 100644 (file)
@@ -82,8 +82,9 @@ enum ofputil_protocol {
 extern enum ofputil_protocol ofputil_flow_dump_protocols[];
 extern size_t ofputil_n_flow_dump_protocols;
 
-enum ofputil_protocol ofputil_protocol_from_ofp_version(int version);
-uint8_t ofputil_protocol_to_ofp_version(enum ofputil_protocol);
+enum ofputil_protocol
+ofputil_protocol_from_ofp_version(enum ofp_version version);
+enum ofp_version  ofputil_protocol_to_ofp_version(enum ofputil_protocol);
 
 bool ofputil_protocol_is_valid(enum ofputil_protocol);
 enum ofputil_protocol ofputil_protocol_set_tid(enum ofputil_protocol,
@@ -113,10 +114,14 @@ void ofputil_cls_rule_from_ofp10_match(const struct ofp10_match *,
                                        unsigned int priority,
                                        struct cls_rule *);
 void ofputil_normalize_rule(struct cls_rule *);
+void ofputil_normalize_rule_quiet(struct cls_rule *);
 void ofputil_cls_rule_to_ofp10_match(const struct cls_rule *,
                                      struct ofp10_match *);
 
 /* Work with ofp11_match. */
+enum ofperr ofputil_pull_ofp11_match(struct ofpbuf *, unsigned int priority,
+                                     struct cls_rule *,
+                                     uint16_t *padded_match_len);
 enum ofperr ofputil_cls_rule_from_ofp11_match(const struct ofp11_match *,
                                               unsigned int priority,
                                               struct cls_rule *);
@@ -272,6 +277,7 @@ struct ofputil_packet_in {
 enum ofperr ofputil_decode_packet_in(struct ofputil_packet_in *,
                                      const struct ofp_header *);
 struct ofpbuf *ofputil_encode_packet_in(const struct ofputil_packet_in *,
+                                        enum ofputil_protocol protocol,
                                         enum nx_packet_in_format);
 
 const char *ofputil_packet_in_reason_to_string(enum ofp_packet_in_reason);
@@ -294,7 +300,8 @@ struct ofputil_packet_out {
 enum ofperr ofputil_decode_packet_out(struct ofputil_packet_out *,
                                       const struct ofp_header *,
                                       struct ofpbuf *ofpacts);
-struct ofpbuf *ofputil_encode_packet_out(const struct ofputil_packet_out *);
+struct ofpbuf *ofputil_encode_packet_out(const struct ofputil_packet_out *,
+                                         enum ofputil_protocol protocol);
 
 enum ofputil_port_config {
     /* OpenFlow 1.0 and 1.1 share these values for these port config bits. */
@@ -343,19 +350,24 @@ struct ofputil_phy_port {
 };
 
 enum ofputil_capabilities {
-    /* OpenFlow 1.0 and 1.1 share these values for these capabilities. */
+    /* OpenFlow 1.0, 1.1 and 1.2 share these values for these capabilities. */
     OFPUTIL_C_FLOW_STATS     = 1 << 0,  /* Flow statistics. */
     OFPUTIL_C_TABLE_STATS    = 1 << 1,  /* Table statistics. */
     OFPUTIL_C_PORT_STATS     = 1 << 2,  /* Port statistics. */
     OFPUTIL_C_IP_REASM       = 1 << 5,  /* Can reassemble IP fragments. */
     OFPUTIL_C_QUEUE_STATS    = 1 << 6,  /* Queue statistics. */
+
+    /* OpenFlow 1.0 and 1.1 share this capability. */
     OFPUTIL_C_ARP_MATCH_IP   = 1 << 7,  /* Match IP addresses in ARP pkts. */
 
     /* OpenFlow 1.0 only. */
     OFPUTIL_C_STP            = 1 << 3,  /* 802.1d spanning tree. */
 
-    /* OpenFlow 1.1 only. */
+    /* OpenFlow 1.1 and 1.2 share this capability. */
     OFPUTIL_C_GROUP_STATS    = 1 << 4,  /* Group statistics. */
+
+    /* OpenFlow 1.2 only */
+    OFPUTIL_C_PORT_BLOCKED   = 1 << 8,  /* Switch will block looping ports */
 };
 
 enum ofputil_action_bitmap {
@@ -409,7 +421,7 @@ void ofputil_put_switch_features_port(const struct ofputil_phy_port *,
 bool ofputil_switch_features_ports_trunc(struct ofpbuf *b);
 
 /* phy_port helper functions. */
-int ofputil_pull_phy_port(uint8_t ofp_version, struct ofpbuf *,
+int ofputil_pull_phy_port(enum ofp_version ofp_version, struct ofpbuf *,
                           struct ofputil_phy_port *);
 size_t ofputil_count_phy_ports(uint8_t ofp_version, struct ofpbuf *);
 
@@ -481,15 +493,15 @@ uint32_t ofputil_decode_flow_monitor_cancel(const struct ofp_header *);
 struct ofpbuf *ofputil_encode_flow_monitor_cancel(uint32_t id);
 
 /* Encoding OpenFlow stats messages. */
-void ofputil_append_port_desc_stats_reply(uint8_t ofp_version,
+void ofputil_append_port_desc_stats_reply(enum ofp_version ofp_version,
                                           const struct ofputil_phy_port *pp,
                                           struct list *replies);
 
 /* Encoding simple OpenFlow messages. */
-struct ofpbuf *make_echo_request(void);
+struct ofpbuf *make_echo_request(enum ofp_version);
 struct ofpbuf *make_echo_reply(const struct ofp_header *rq);
 
-struct ofpbuf *ofputil_encode_barrier_request(void);
+struct ofpbuf *ofputil_encode_barrier_request(enum ofp_version);
 
 const char *ofputil_frag_handling_to_string(enum ofp_config_flags);
 bool ofputil_frag_handling_from_string(const char *, enum ofp_config_flags *);