ovn-nbctl: Update basic router commands.
[cascardo/ovs.git] / ovn / controller / lport.h
1 /* Copyright (c) 2015, 2016 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 OVN_LPORT_H
17 #define OVN_LPORT_H 1
18
19 #include <stdint.h>
20 #include "hmap.h"
21
22 struct ovsdb_idl;
23 struct sbrec_datapath_binding;
24
25 /* Logical port and multicast group indexes
26  * ========================================
27  *
28  * This data structure holds multiple indexes over logical ports, to allow for
29  * efficient searching for logical ports by name or number.
30  */
31
32 struct lport_index {
33     struct hmap by_name;
34     struct hmap by_key;
35 };
36
37 void lport_index_init(struct lport_index *, struct ovsdb_idl *);
38 void lport_index_destroy(struct lport_index *);
39
40 const struct sbrec_port_binding *lport_lookup_by_name(
41     const struct lport_index *, const char *name);
42 const struct sbrec_port_binding *lport_lookup_by_key(
43     const struct lport_index *, uint32_t dp_key, uint16_t port_key);
44 \f
45 /* Multicast group index
46  * =====================
47  *
48  * This is separate from the logical port index because of namespace issues:
49  * logical port names are globally unique, but multicast group names are only
50  * unique within the scope of a logical datapath.
51  *
52  * Multicast groups could be indexed by number also, but so far the clients do
53  * not need this index. */
54
55 struct mcgroup_index {
56     struct hmap by_dp_name;
57 };
58
59 void mcgroup_index_init(struct mcgroup_index *, struct ovsdb_idl *);
60 void mcgroup_index_destroy(struct mcgroup_index *);
61
62 const struct sbrec_multicast_group *mcgroup_lookup_by_dp_name(
63     const struct mcgroup_index *,
64     const struct sbrec_datapath_binding *,
65     const char *name);
66
67 #endif /* ovn/lport.h */