]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/bundles.h
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / ofproto / bundles.h
CommitLineData
777af88d
AC
1/*
2 * Copyright (c) 2013, 2014 Alexandru Copot <alex.mihai.c@gmail.com>, with support from IXIA.
3 * Copyright (c) 2013, 2014 Daniel Baluta <dbaluta@ixiacom.com>
1620b7ea 4 * Copyright (c) 2014, 2015, 2016, 2017 Nicira, Inc.
777af88d
AC
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef BUNDLES_H
20#define BUNDLES_H 1
21
22#include <sys/types.h>
23
777af88d 24#include "connmgr.h"
1f42be1c 25#include "ofproto-provider.h"
d271907f 26#include "openvswitch/ofp-msgs.h"
1f42be1c 27#include "util.h"
777af88d
AC
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
7ac27a04
JR
33struct ofp_bundle_entry {
34 struct ovs_list node;
6dd3c787
JR
35 enum ofptype type; /* OFPTYPE_FLOW_MOD, OFPTYPE_PORT_MOD,
36 * OFPTYPE_GROUP_MOD, OFPTYPE_PACKET_OUT. */
52c57cbb 37 struct ofp_header *msg; /* Original request, for error reporting. */
7ac27a04 38 union {
5bacd5cd 39 struct ofproto_flow_mod ofm;
8be00367 40 struct ofproto_port_mod opm;
25070e04 41 struct ofproto_group_mod ogm;
6dd3c787 42 struct ofproto_packet_out opo;
7ac27a04
JR
43 };
44};
777af88d 45
1620b7ea 46enum bundle_state {
ff09bc08
JR
47 BS_OPEN,
48 BS_CLOSED
49};
50
51struct ofp_bundle {
52 struct hmap_node node; /* In struct ofconn's "bundles" hmap. */
51bb26fa 53 long long int used; /* Last time bundle was used. */
ff09bc08
JR
54 uint32_t id;
55 uint16_t flags;
56 enum bundle_state state;
52c57cbb
BP
57 struct ofp_header *msg; /* Original request, for error reporting. */
58 struct ovs_list msg_list; /* List of 'struct bundle_message's */
ff09bc08
JR
59};
60
7ac27a04 61static inline void ofp_bundle_entry_free(struct ofp_bundle_entry *);
777af88d 62
51bb26fa
JR
63enum ofperr ofp_bundle_open(struct ofconn *, uint32_t id, uint16_t flags,
64 const struct ofp_header *);
7ac27a04 65enum ofperr ofp_bundle_close(struct ofconn *, uint32_t id, uint16_t flags);
7ac27a04
JR
66enum ofperr ofp_bundle_discard(struct ofconn *, uint32_t id);
67enum ofperr ofp_bundle_add_message(struct ofconn *, uint32_t id,
51bb26fa
JR
68 uint16_t flags, struct ofp_bundle_entry *,
69 const struct ofp_header *);
ff09bc08 70
0c78eebe 71void ofp_bundle_remove__(struct ofconn *, struct ofp_bundle *);
7ac27a04 72\f
1f42be1c
JR
73static inline void
74ofp_bundle_entry_free(struct ofp_bundle_entry *entry)
7ac27a04
JR
75{
76 if (entry) {
77 if (entry->type == OFPTYPE_FLOW_MOD) {
5bacd5cd 78 ofproto_flow_mod_uninit(&entry->ofm);
25070e04
JR
79 } else if (entry->type == OFPTYPE_GROUP_MOD) {
80 ofputil_uninit_group_mod(&entry->ogm.gm);
6dd3c787
JR
81 } else if (entry->type == OFPTYPE_PACKET_OUT) {
82 ofproto_packet_out_uninit(&entry->opo);
7ac27a04 83 }
52c57cbb 84 free(entry->msg);
7ac27a04
JR
85 free(entry);
86 }
87}
777af88d
AC
88
89#ifdef __cplusplus
90}
91#endif
92
93#endif