Implement OFPT_TABLE_STATUS Message.
[cascardo/ovs.git] / lib / ofp-util.h
index cf77d8a..31cbe2d 100644 (file)
@@ -31,6 +31,7 @@
 #include "openflow/nicira-ext.h"
 #include "openvswitch/types.h"
 #include "type-props.h"
+#include "uuid.h"
 
 struct ofpbuf;
 union ofp_action;
@@ -426,8 +427,8 @@ struct ofputil_packet_in {
      * On decoding, the 'len' bytes in 'packet' might only be the first part of
      * the original packet.  ofputil_decode_packet_in() reports the full
      * original length of the packet using its 'total_len' output parameter. */
-    const void *packet;         /* The packet. */
-    size_t len;                 /* Length of 'packet' in bytes. */
+    void *packet;               /* The packet. */
+    size_t packet_len;          /* Length of 'packet' in bytes. */
 
     /* Input port and other metadata for packet. */
     struct match flow_metadata;
@@ -441,16 +442,22 @@ struct ofputil_packet_in {
      * that case, 'cookie' is UINT64_MAX. */
     uint8_t table_id;                    /* OpenFlow table ID. */
     ovs_be64 cookie;                     /* Flow's cookie. */
+
+    /* Arbitrary user-provided data. */
+    uint8_t *userdata;
+    size_t userdata_len;
 };
 
-struct ofpbuf *ofputil_encode_packet_in(const struct ofputil_packet_in *,
-                                        enum ofputil_protocol protocol,
-                                        enum nx_packet_in_format,
-                                        uint16_t max_len, struct pktbuf *);
+void ofputil_packet_in_destroy(struct ofputil_packet_in *);
 
-enum ofperr ofputil_decode_packet_in(const struct ofp_header *,
+enum ofperr ofputil_decode_packet_in(const struct ofp_header *, bool loose,
                                      struct ofputil_packet_in *,
-                                     size_t *total_len, uint32_t *buffer_id);
+                                     size_t *total_len, uint32_t *buffer_id,
+                                     struct ofpbuf *continuation);
+
+struct ofpbuf *ofputil_encode_resume(const struct ofputil_packet_in *pin,
+                                     const struct ofpbuf *continuation,
+                                     enum ofputil_protocol);
 
 enum { OFPUTIL_PACKET_IN_REASON_BUFSIZE = INT_STRLEN(int) + 1 };
 const char *ofputil_packet_in_reason_to_string(enum ofp_packet_in_reason,
@@ -459,6 +466,48 @@ const char *ofputil_packet_in_reason_to_string(enum ofp_packet_in_reason,
 bool ofputil_packet_in_reason_from_string(const char *,
                                           enum ofp_packet_in_reason *);
 
+/* A packet-in message, including continuation data.  The format of
+ * continuation data is subject to change and thus it is supposed to be opaque
+ * to any process other than ovs-vswitchd.  Therefore, only ovs-vswitchd should
+ * use ofputil_packet_in_private and the functions that operate on it. */
+struct ofputil_packet_in_private {
+    struct ofputil_packet_in public;
+
+    /* NXCPT_BRIDGE. */
+    struct uuid bridge;
+
+    /* NXCPT_STACK. */
+    union mf_subvalue *stack;
+    size_t n_stack;
+
+    /* NXCPT_MIRRORS. */
+    uint32_t mirrors;
+
+    /* NXCPT_CONNTRACKED. */
+    bool conntracked;
+
+    /* NXCPT_ACTIONS. */
+    struct ofpact *actions;
+    size_t actions_len;
+
+    /* NXCPT_ACTION_SET. */
+    struct ofpact *action_set;
+    size_t action_set_len;
+};
+
+struct ofpbuf *ofputil_encode_packet_in_private(
+    const struct ofputil_packet_in_private *,
+    enum ofputil_protocol protocol,
+    enum nx_packet_in_format,
+    uint16_t max_len, struct pktbuf *);
+
+enum ofperr ofputil_decode_packet_in_private(
+    const struct ofp_header *, bool loose,
+    struct ofputil_packet_in_private *,
+    size_t *total_len, uint32_t *buffer_id);
+
+void ofputil_packet_in_private_destroy(struct ofputil_packet_in_private *);
+
 /* Abstract packet-out message.
  *
  * ofputil_decode_packet_out() will ensure that 'in_port' is a physical port
@@ -590,9 +639,8 @@ struct ofputil_switch_features {
     uint64_t ofpacts;           /* Bitmap of OFPACT_* bits. */
 };
 
-enum ofperr ofputil_decode_switch_features(const struct ofp_header *,
-                                           struct ofputil_switch_features *,
-                                           struct ofpbuf *);
+enum ofperr ofputil_pull_switch_features(struct ofpbuf *,
+                                         struct ofputil_switch_features *);
 
 struct ofpbuf *ofputil_encode_switch_features(
     const struct ofputil_switch_features *, enum ofputil_protocol,
@@ -1357,4 +1405,16 @@ enum ofperr ofputil_decode_requestforward(const struct ofp_header *,
                                           struct ofputil_requestforward *);
 void ofputil_destroy_requestforward(struct ofputil_requestforward *);
 
+/* Abstract ofp14_table_status. */
+struct ofputil_table_status {
+    enum ofp14_table_reason reason;     /* One of OFPTR_*. */
+    struct ofputil_table_desc desc;   /* New table config. */
+};
+
+enum ofperr ofputil_decode_table_status(const struct ofp_header *oh,
+                                        struct ofputil_table_status *ts);
+
+struct ofpbuf *
+ofputil_encode_table_status(const struct ofputil_table_status *ts,
+                            enum ofputil_protocol protocol);
 #endif /* ofp-util.h */