]>
Commit | Line | Data |
---|---|---|
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> | |
4 | * Copyright (c) 2014, 2015, 2016, 2017 Nicira, Inc. | |
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 | ||
24 | #include "connmgr.h" | |
25 | #include "ofproto-provider.h" | |
26 | #include "openvswitch/ofp-msgs.h" | |
27 | #include "util.h" | |
28 | ||
29 | #ifdef __cplusplus | |
30 | extern "C" { | |
31 | #endif | |
32 | ||
33 | struct ofp_bundle_entry { | |
34 | struct ovs_list node; | |
35 | enum ofptype type; /* OFPTYPE_FLOW_MOD, OFPTYPE_PORT_MOD, | |
36 | * OFPTYPE_GROUP_MOD, OFPTYPE_PACKET_OUT. */ | |
37 | struct ofp_header *msg; /* Original request, for error reporting. */ | |
38 | union { | |
39 | struct ofproto_flow_mod ofm; | |
40 | struct ofproto_port_mod opm; | |
41 | struct ofproto_group_mod ogm; | |
42 | struct ofproto_packet_out opo; | |
43 | }; | |
44 | }; | |
45 | ||
46 | enum bundle_state { | |
47 | BS_OPEN, | |
48 | BS_CLOSED | |
49 | }; | |
50 | ||
51 | struct ofp_bundle { | |
52 | struct hmap_node node; /* In struct ofconn's "bundles" hmap. */ | |
53 | long long int used; /* Last time bundle was used. */ | |
54 | uint32_t id; | |
55 | uint16_t flags; | |
56 | enum bundle_state state; | |
57 | struct ofp_header *msg; /* Original request, for error reporting. */ | |
58 | struct ovs_list msg_list; /* List of 'struct bundle_message's */ | |
59 | }; | |
60 | ||
61 | static inline void ofp_bundle_entry_free(struct ofp_bundle_entry *); | |
62 | ||
63 | enum ofperr ofp_bundle_open(struct ofconn *, uint32_t id, uint16_t flags, | |
64 | const struct ofp_header *); | |
65 | enum ofperr ofp_bundle_close(struct ofconn *, uint32_t id, uint16_t flags); | |
66 | enum ofperr ofp_bundle_discard(struct ofconn *, uint32_t id); | |
67 | enum ofperr ofp_bundle_add_message(struct ofconn *, uint32_t id, | |
68 | uint16_t flags, struct ofp_bundle_entry *, | |
69 | const struct ofp_header *); | |
70 | ||
71 | void ofp_bundle_remove__(struct ofconn *, struct ofp_bundle *); | |
72 | \f | |
73 | static inline void | |
74 | ofp_bundle_entry_free(struct ofp_bundle_entry *entry) | |
75 | { | |
76 | if (entry) { | |
77 | if (entry->type == OFPTYPE_FLOW_MOD) { | |
78 | ofproto_flow_mod_uninit(&entry->ofm); | |
79 | } else if (entry->type == OFPTYPE_GROUP_MOD) { | |
80 | ofputil_uninit_group_mod(&entry->ogm.gm); | |
81 | } else if (entry->type == OFPTYPE_PACKET_OUT) { | |
82 | ofproto_packet_out_uninit(&entry->opo); | |
83 | } | |
84 | free(entry->msg); | |
85 | free(entry); | |
86 | } | |
87 | } | |
88 | ||
89 | #ifdef __cplusplus | |
90 | } | |
91 | #endif | |
92 | ||
93 | #endif |