#include "openflow/nicira-ext.h"
#include "openvswitch/types.h"
#include "type-props.h"
+#include "uuid.h"
struct ofpbuf;
union ofp_action;
struct ofpact_set_field;
+struct pktbuf;
/* Port numbers. */
enum ofperr ofputil_port_from_ofp11(ovs_be32 ofp11_port,
struct ofpbuf *ofputil_encode_flow_removed(const struct ofputil_flow_removed *,
enum ofputil_protocol);
-/* Abstract packet-in message. */
+/* Abstract packet-in message.
+ *
+ * This omits the 'total_len' and 'buffer_id' fields, which we handle
+ * differently for encoding and decoding.*/
struct ofputil_packet_in {
/* Packet data and metadata.
*
- * To save bandwidth, in some cases a switch may send only the first
- * several bytes of a packet, indicated by 'packet_len < total_len'. When
- * the full packet is included, 'packet_len == total_len'. */
- const void *packet;
- size_t packet_len; /* Number of bytes in 'packet'. */
- size_t total_len; /* Size of packet, pre-truncation. */
- struct match flow_metadata;
-
- /* Identifies a buffer in the switch that contains the full packet, to
- * allow the controller to reference it later without having to send the
- * entire packet back to the switch.
+ * On encoding, the full packet should be supplied, but depending on its
+ * other parameters ofputil_encode_packet_in() might send only the first
+ * part of the packet.
*
- * UINT32_MAX indicates that the packet is not buffered in the switch. A
- * switch should only use UINT32_MAX when it sends the entire packet. */
- uint32_t buffer_id;
+ * 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. */
+ void *packet; /* The packet. */
+ size_t packet_len; /* Length of 'packet' in bytes. */
+
+ /* Input port and other metadata for packet. */
+ struct match flow_metadata;
/* Reason that the packet-in is being sent. */
enum ofp_packet_in_reason reason; /* One of OFPR_*. */
* 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;
};
-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);
+void ofputil_packet_in_destroy(struct ofputil_packet_in *);
+
+enum ofperr ofputil_decode_packet_in(const struct ofp_header *, bool loose,
+ struct ofputil_packet_in *,
+ 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,
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
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,