netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / ovsdb / condition.h
1 /* Copyright (c) 2009, 2010 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 OVSDB_CONDITION_H
17 #define OVSDB_CONDITION_H 1
18
19 #include <stddef.h>
20 #include "compiler.h"
21 #include "ovsdb-data.h"
22
23 struct json;
24 struct ovsdb_table_schema;
25 struct ovsdb_row;
26
27 /* These list is ordered in ascending order of the fraction of tables row that
28  * they are (heuristically) expected to leave in query results. */
29 #define OVSDB_FUNCTIONS                         \
30     OVSDB_FUNCTION(OVSDB_F_EQ, "==")                  \
31     OVSDB_FUNCTION(OVSDB_F_INCLUDES, "includes")      \
32     OVSDB_FUNCTION(OVSDB_F_LE, "<=")                  \
33     OVSDB_FUNCTION(OVSDB_F_LT, "<")                   \
34     OVSDB_FUNCTION(OVSDB_F_GE, ">=")                  \
35     OVSDB_FUNCTION(OVSDB_F_GT, ">")                   \
36     OVSDB_FUNCTION(OVSDB_F_EXCLUDES, "excludes")      \
37     OVSDB_FUNCTION(OVSDB_F_NE, "!=")
38
39 enum ovsdb_function {
40 #define OVSDB_FUNCTION(ENUM, NAME) ENUM,
41     OVSDB_FUNCTIONS
42 #undef OVSDB_FUNCTION
43 };
44
45 struct ovsdb_error *ovsdb_function_from_string(const char *,
46                                                enum ovsdb_function *)
47     OVS_WARN_UNUSED_RESULT;
48 const char *ovsdb_function_to_string(enum ovsdb_function);
49
50 struct ovsdb_clause {
51     enum ovsdb_function function;
52     const struct ovsdb_column *column;
53     struct ovsdb_datum arg;
54 };
55
56 struct ovsdb_condition {
57     struct ovsdb_clause *clauses;
58     size_t n_clauses;
59 };
60
61 #define OVSDB_CONDITION_INITIALIZER { NULL, 0 }
62
63 struct ovsdb_error *ovsdb_condition_from_json(
64     const struct ovsdb_table_schema *,
65     const struct json *, struct ovsdb_symbol_table *,
66     struct ovsdb_condition *) OVS_WARN_UNUSED_RESULT;
67 struct json *ovsdb_condition_to_json(const struct ovsdb_condition *);
68 void ovsdb_condition_destroy(struct ovsdb_condition *);
69 bool ovsdb_condition_evaluate(const struct ovsdb_row *,
70                               const struct ovsdb_condition *);
71
72 #endif /* ovsdb/condition.h */