/*
* Copyright (c) 2013, 2014 Alexandru Copot <alex.mihai.c@gmail.com>, with support from IXIA.
* Copyright (c) 2013, 2014 Daniel Baluta <dbaluta@ixiacom.com>
- * Copyright (c) 2014, 2015 Nicira, Inc.
+ * Copyright (c) 2014, 2015, 2016, 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.
#include <sys/types.h>
#include "connmgr.h"
-#include "list.h"
-#include "ofp-msgs.h"
-#include "ofp-util.h"
+#include "ofproto-provider.h"
+#include "openvswitch/ofp-msgs.h"
+#include "util.h"
#ifdef __cplusplus
extern "C" {
struct ofp_bundle_entry {
struct ovs_list node;
- ovs_be32 xid; /* For error returns. */
- enum ofptype type; /* OFPTYPE_FLOW_MOD or OFPTYPE_PORT_MOD. */
+ enum ofptype type; /* OFPTYPE_FLOW_MOD, OFPTYPE_PORT_MOD,
+ * OFPTYPE_GROUP_MOD, OFPTYPE_PACKET_OUT. */
+ struct ofp_header *msg; /* Original request, for error reporting. */
union {
- struct ofputil_flow_mod fm; /* 'fm.ofpacts' must be malloced. */
- struct ofputil_port_mod pm;
+ struct ofproto_flow_mod ofm;
+ struct ofproto_port_mod opm;
+ struct ofproto_group_mod ogm;
+ struct ofproto_packet_out opo;
};
};
-static inline struct ofp_bundle_entry *ofp_bundle_entry_alloc(
- enum ofptype type, ovs_be32 xid);
+enum bundle_state {
+ BS_OPEN,
+ BS_CLOSED
+};
+
+struct ofp_bundle {
+ struct hmap_node node; /* In struct ofconn's "bundles" hmap. */
+ long long int used; /* Last time bundle was used. */
+ uint32_t id;
+ uint16_t flags;
+ enum bundle_state state;
+ struct ofp_header *msg; /* Original request, for error reporting. */
+ struct ovs_list msg_list; /* List of 'struct bundle_message's */
+};
+
static inline void ofp_bundle_entry_free(struct ofp_bundle_entry *);
-enum ofperr ofp_bundle_open(struct ofconn *, uint32_t id, uint16_t flags);
+enum ofperr ofp_bundle_open(struct ofconn *, uint32_t id, uint16_t flags,
+ const struct ofp_header *);
enum ofperr ofp_bundle_close(struct ofconn *, uint32_t id, uint16_t flags);
-enum ofperr ofp_bundle_commit(struct ofconn *, uint32_t id, uint16_t flags);
enum ofperr ofp_bundle_discard(struct ofconn *, uint32_t id);
enum ofperr ofp_bundle_add_message(struct ofconn *, uint32_t id,
- uint16_t flags, struct ofp_bundle_entry *);
-void ofp_bundle_remove_all(struct ofconn *);
-\f
-static inline struct ofp_bundle_entry *
-ofp_bundle_entry_alloc(enum ofptype type, ovs_be32 xid)
-{
- struct ofp_bundle_entry *entry = xmalloc(sizeof *entry);
-
- entry->xid = xid;
- entry->type = type;
+ uint16_t flags, struct ofp_bundle_entry *,
+ const struct ofp_header *);
- return entry;
-}
-
-static inline void ofp_bundle_entry_free(struct ofp_bundle_entry *entry)
+void ofp_bundle_remove__(struct ofconn *, struct ofp_bundle *);
+\f
+static inline void
+ofp_bundle_entry_free(struct ofp_bundle_entry *entry)
{
if (entry) {
if (entry->type == OFPTYPE_FLOW_MOD) {
- free(entry->fm.ofpacts);
+ ofproto_flow_mod_uninit(&entry->ofm);
+ } else if (entry->type == OFPTYPE_GROUP_MOD) {
+ ofputil_uninit_group_mod(&entry->ogm.gm);
+ } else if (entry->type == OFPTYPE_PACKET_OUT) {
+ ofproto_packet_out_uninit(&entry->opo);
}
+ free(entry->msg);
free(entry);
}
}