]>
Commit | Line | Data |
---|---|---|
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> | |
7ac27a04 | 4 | * Copyright (c) 2014, 2015 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" |
7ac27a04 JR |
25 | #include "list.h" |
26 | #include "ofp-msgs.h" | |
777af88d AC |
27 | #include "ofp-util.h" |
28 | ||
29 | #ifdef __cplusplus | |
30 | extern "C" { | |
31 | #endif | |
32 | ||
7ac27a04 JR |
33 | struct ofp_bundle_entry { |
34 | struct ovs_list node; | |
35 | ovs_be32 xid; /* For error returns. */ | |
36 | enum ofptype type; /* OFPTYPE_FLOW_MOD or OFPTYPE_PORT_MOD. */ | |
37 | union { | |
38 | struct ofputil_flow_mod fm; /* 'fm.ofpacts' must be malloced. */ | |
39 | struct ofputil_port_mod pm; | |
40 | }; | |
41 | }; | |
777af88d | 42 | |
7ac27a04 JR |
43 | static inline struct ofp_bundle_entry *ofp_bundle_entry_alloc( |
44 | enum ofptype type, ovs_be32 xid); | |
45 | static inline void ofp_bundle_entry_free(struct ofp_bundle_entry *); | |
777af88d | 46 | |
7ac27a04 JR |
47 | enum ofperr ofp_bundle_open(struct ofconn *, uint32_t id, uint16_t flags); |
48 | enum ofperr ofp_bundle_close(struct ofconn *, uint32_t id, uint16_t flags); | |
49 | enum ofperr ofp_bundle_commit(struct ofconn *, uint32_t id, uint16_t flags); | |
50 | enum ofperr ofp_bundle_discard(struct ofconn *, uint32_t id); | |
51 | enum ofperr ofp_bundle_add_message(struct ofconn *, uint32_t id, | |
52 | uint16_t flags, struct ofp_bundle_entry *); | |
53 | void ofp_bundle_remove_all(struct ofconn *); | |
54 | \f | |
55 | static inline struct ofp_bundle_entry * | |
56 | ofp_bundle_entry_alloc(enum ofptype type, ovs_be32 xid) | |
57 | { | |
58 | struct ofp_bundle_entry *entry = xmalloc(sizeof *entry); | |
777af88d | 59 | |
7ac27a04 JR |
60 | entry->xid = xid; |
61 | entry->type = type; | |
777af88d | 62 | |
7ac27a04 JR |
63 | return entry; |
64 | } | |
777af88d | 65 | |
7ac27a04 JR |
66 | static inline void ofp_bundle_entry_free(struct ofp_bundle_entry *entry) |
67 | { | |
68 | if (entry) { | |
69 | if (entry->type == OFPTYPE_FLOW_MOD) { | |
70 | free(entry->fm.ofpacts); | |
71 | } | |
72 | free(entry); | |
73 | } | |
74 | } | |
777af88d AC |
75 | |
76 | #ifdef __cplusplus | |
77 | } | |
78 | #endif | |
79 | ||
80 | #endif |