1 /* Copyright (c) 2009 Nicira Networks
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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #define OVSDB_OVSDB_H 1
29 /* Database schema. */
33 struct shash tables; /* Contains "struct ovsdb_table_schema *"s. */
36 struct ovsdb_schema *ovsdb_schema_create(const char *name,
38 void ovsdb_schema_destroy(struct ovsdb_schema *);
40 struct ovsdb_error *ovsdb_schema_from_file(const char *file_name,
41 struct ovsdb_schema **)
43 struct ovsdb_error *ovsdb_schema_from_json(struct json *,
44 struct ovsdb_schema **)
46 struct json *ovsdb_schema_to_json(const struct ovsdb_schema *);
50 struct ovsdb_schema *schema;
51 struct list replicas; /* Contains "struct ovsdb_replica"s. */
52 struct shash tables; /* Contains "struct ovsdb_table *"s. */
55 struct list triggers; /* Contains "struct ovsdb_trigger"s. */
59 struct ovsdb *ovsdb_create(struct ovsdb_schema *);
60 void ovsdb_destroy(struct ovsdb *);
62 struct ovsdb_error *ovsdb_from_json(const struct json *, struct ovsdb **)
64 struct json *ovsdb_to_json(const struct ovsdb *);
66 struct ovsdb_table *ovsdb_get_table(const struct ovsdb *, const char *);
68 struct json *ovsdb_execute(struct ovsdb *, const struct json *params,
69 long long int elapsed_msec,
70 long long int *timeout_msec);
72 /* Database replication. */
74 struct ovsdb_replica {
75 struct list node; /* Element in "struct ovsdb" replicas list. */
76 const struct ovsdb_replica_class *class;
79 struct ovsdb_replica_class {
80 struct ovsdb_error *(*commit)(struct ovsdb_replica *,
81 const struct ovsdb_txn *, bool durable);
82 void (*destroy)(struct ovsdb_replica *);
85 void ovsdb_replica_init(struct ovsdb_replica *,
86 const struct ovsdb_replica_class *);
88 void ovsdb_add_replica(struct ovsdb *, struct ovsdb_replica *);
89 void ovsdb_remove_replica(struct ovsdb *, struct ovsdb_replica *);
91 #endif /* ovsdb/ovsdb.h */