Global replace of Nicira Networks.
[sliver-openvswitch.git] / lib / bundle.h
1 /* Copyright (c) 2011 Nicira, Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef BUNDLE_H
17 #define BUNDLE_H 1
18
19 #include <arpa/inet.h>
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include <stdint.h>
23
24 #include "ofp-errors.h"
25 #include "openflow/nicira-ext.h"
26 #include "openvswitch/types.h"
27
28 struct ds;
29 struct flow;
30 struct ofpbuf;
31
32 /* NXAST_BUNDLE helper functions.
33  *
34  * See include/openflow/nicira-ext.h for NXAST_BUNDLE specification. */
35
36 uint16_t bundle_execute(const struct nx_action_bundle *, const struct flow *,
37                         bool (*slave_enabled)(uint16_t ofp_port, void *aux),
38                         void *aux);
39 void bundle_execute_load(const struct nx_action_bundle *, struct flow *,
40                          bool (*slave_enabled)(uint16_t ofp_port, void *aux),
41                          void *aux);
42 enum ofperr bundle_check(const struct nx_action_bundle *, int max_ports,
43                          const struct flow *);
44 void bundle_parse(struct ofpbuf *, const char *);
45 void bundle_parse_load(struct ofpbuf *b, const char *);
46 void bundle_format(const struct nx_action_bundle *, struct ds *);
47
48 /* Returns the 'i'th slave in 'nab'. */
49 static inline uint16_t
50 bundle_get_slave(const struct nx_action_bundle *nab, size_t i)
51 {
52     return ntohs(((ovs_be16 *)(nab + 1))[i]);
53 }
54
55 #endif /* bundle.h */