2014-05-02 09:54:27 +03:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013, 2014 Alexandru Copot <alex.mihai.c@gmail.com>, with support from IXIA.
|
|
|
|
|
* Copyright (c) 2013, 2014 Daniel Baluta <dbaluta@ixiacom.com>
|
2015-06-01 18:07:39 -07:00
|
|
|
|
* Copyright (c) 2014, 2015 Nicira, Inc.
|
2014-05-02 09:54:27 +03:00
|
|
|
|
*
|
|
|
|
|
* 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 BUNDLES_H
|
|
|
|
|
#define BUNDLES_H 1
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
|
#include "connmgr.h"
|
2015-06-01 18:07:39 -07:00
|
|
|
|
#include "ofp-msgs.h"
|
2014-05-02 09:54:27 +03:00
|
|
|
|
#include "ofp-util.h"
|
2015-06-01 15:47:58 -07:00
|
|
|
|
#include "ofproto-provider.h"
|
|
|
|
|
#include "util.h"
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-06-01 18:07:39 -07:00
|
|
|
|
struct ofp_bundle_entry {
|
|
|
|
|
struct ovs_list node;
|
|
|
|
|
enum ofptype type; /* OFPTYPE_FLOW_MOD or OFPTYPE_PORT_MOD. */
|
2015-06-12 16:12:56 -07:00
|
|
|
|
long long version; /* Version in which the changes take
|
|
|
|
|
* effect. */
|
2015-06-01 18:07:39 -07:00
|
|
|
|
union {
|
|
|
|
|
struct ofputil_flow_mod fm; /* 'fm.ofpacts' must be malloced. */
|
|
|
|
|
struct ofputil_port_mod pm;
|
|
|
|
|
};
|
2015-06-01 15:47:58 -07:00
|
|
|
|
|
|
|
|
|
/* Used during commit. */
|
2015-06-12 16:12:56 -07:00
|
|
|
|
struct ofport *port; /* Affected port. */
|
2015-06-11 15:53:43 -07:00
|
|
|
|
struct rule_collection old_rules; /* Affected rules. */
|
2015-06-12 16:12:56 -07:00
|
|
|
|
struct rule_collection new_rules; /* Replacement rules. */
|
2015-06-01 15:47:58 -07:00
|
|
|
|
|
|
|
|
|
/* OpenFlow header and some of the message contents for error reporting. */
|
|
|
|
|
struct ofp_header ofp_msg[DIV_ROUND_UP(64, sizeof(struct ofp_header))];
|
2015-06-01 18:07:39 -07:00
|
|
|
|
};
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
2015-05-29 11:28:38 -07:00
|
|
|
|
enum bundle_state {
|
|
|
|
|
BS_OPEN,
|
|
|
|
|
BS_CLOSED
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ofp_bundle {
|
|
|
|
|
struct hmap_node node; /* In struct ofconn's "bundles" hmap. */
|
|
|
|
|
uint32_t id;
|
|
|
|
|
uint16_t flags;
|
|
|
|
|
enum bundle_state state;
|
|
|
|
|
|
|
|
|
|
/* List of 'struct bundle_message's */
|
|
|
|
|
struct ovs_list msg_list;
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-01 18:07:39 -07:00
|
|
|
|
static inline struct ofp_bundle_entry *ofp_bundle_entry_alloc(
|
2015-06-01 15:47:58 -07:00
|
|
|
|
enum ofptype type, const struct ofp_header *oh);
|
2015-06-01 18:07:39 -07:00
|
|
|
|
static inline void ofp_bundle_entry_free(struct ofp_bundle_entry *);
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
2015-06-01 18:07:39 -07:00
|
|
|
|
enum ofperr ofp_bundle_open(struct ofconn *, uint32_t id, uint16_t flags);
|
|
|
|
|
enum ofperr ofp_bundle_close(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 *);
|
2015-05-29 11:28:38 -07:00
|
|
|
|
|
2015-06-01 15:47:58 -07:00
|
|
|
|
void ofp_bundle_remove__(struct ofconn *, struct ofp_bundle *, bool success);
|
2015-06-01 18:07:39 -07:00
|
|
|
|
|
|
|
|
|
static inline struct ofp_bundle_entry *
|
2015-06-01 15:47:58 -07:00
|
|
|
|
ofp_bundle_entry_alloc(enum ofptype type, const struct ofp_header *oh)
|
2015-06-01 18:07:39 -07:00
|
|
|
|
{
|
|
|
|
|
struct ofp_bundle_entry *entry = xmalloc(sizeof *entry);
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
2015-06-01 18:07:39 -07:00
|
|
|
|
entry->type = type;
|
2015-06-12 16:12:56 -07:00
|
|
|
|
entry->version = 0;
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
2015-06-01 15:47:58 -07:00
|
|
|
|
/* Max 64 bytes for error reporting. */
|
|
|
|
|
memcpy(entry->ofp_msg, oh, MIN(ntohs(oh->length), sizeof entry->ofp_msg));
|
|
|
|
|
|
2015-06-01 18:07:39 -07:00
|
|
|
|
return entry;
|
|
|
|
|
}
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
2015-06-01 15:47:58 -07:00
|
|
|
|
static inline void
|
|
|
|
|
ofp_bundle_entry_free(struct ofp_bundle_entry *entry)
|
2015-06-01 18:07:39 -07:00
|
|
|
|
{
|
|
|
|
|
if (entry) {
|
|
|
|
|
if (entry->type == OFPTYPE_FLOW_MOD) {
|
|
|
|
|
free(entry->fm.ofpacts);
|
|
|
|
|
}
|
|
|
|
|
free(entry);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-02 09:54:27 +03:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|