]> git.proxmox.com Git - ovs.git/blame - ovsdb/ovsdb.h
ovsdb: Refactor jsonrpc-server to make the concept of a session public.
[ovs.git] / ovsdb / ovsdb.h
CommitLineData
6aa09313 1/* Copyright (c) 2009, 2010, 2011 Nicira Networks
f85f8ebb
BP
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_OVSDB_H
17#define OVSDB_OVSDB_H 1
18
19#include "compiler.h"
20#include "hmap.h"
21#include "list.h"
22#include "shash.h"
23
24struct json;
bd06962a
BP
25struct ovsdb_log;
26struct ovsdb_txn;
f85f8ebb
BP
27struct uuid;
28
29/* Database schema. */
30struct ovsdb_schema {
31 char *name;
8159b984 32 char *version;
6aa09313 33 char *cksum;
f85f8ebb
BP
34 struct shash tables; /* Contains "struct ovsdb_table_schema *"s. */
35};
36
8159b984 37struct ovsdb_schema *ovsdb_schema_create(const char *name,
6aa09313
BP
38 const char *version,
39 const char *cksum);
58985e09 40struct ovsdb_schema *ovsdb_schema_clone(const struct ovsdb_schema *);
f85f8ebb
BP
41void ovsdb_schema_destroy(struct ovsdb_schema *);
42
43struct ovsdb_error *ovsdb_schema_from_file(const char *file_name,
44 struct ovsdb_schema **)
45 WARN_UNUSED_RESULT;
46struct ovsdb_error *ovsdb_schema_from_json(struct json *,
47 struct ovsdb_schema **)
48 WARN_UNUSED_RESULT;
49struct json *ovsdb_schema_to_json(const struct ovsdb_schema *);
403e3a25
BP
50
51bool ovsdb_schema_equal(const struct ovsdb_schema *,
52 const struct ovsdb_schema *);
f85f8ebb
BP
53\f
54/* Database. */
55struct ovsdb {
56 struct ovsdb_schema *schema;
bd06962a 57 struct list replicas; /* Contains "struct ovsdb_replica"s. */
f85f8ebb
BP
58 struct shash tables; /* Contains "struct ovsdb_table *"s. */
59
60 /* Triggers. */
61 struct list triggers; /* Contains "struct ovsdb_trigger"s. */
62 bool run_triggers;
63};
64
bd06962a 65struct ovsdb *ovsdb_create(struct ovsdb_schema *);
f85f8ebb
BP
66void ovsdb_destroy(struct ovsdb *);
67
68struct ovsdb_error *ovsdb_from_json(const struct json *, struct ovsdb **)
69 WARN_UNUSED_RESULT;
70struct json *ovsdb_to_json(const struct ovsdb *);
71
72struct ovsdb_table *ovsdb_get_table(const struct ovsdb *, const char *);
73
74struct json *ovsdb_execute(struct ovsdb *, const struct json *params,
75 long long int elapsed_msec,
76 long long int *timeout_msec);
bd06962a
BP
77\f
78/* Database replication. */
79
80struct ovsdb_replica {
81 struct list node; /* Element in "struct ovsdb" replicas list. */
82 const struct ovsdb_replica_class *class;
83};
84
85struct ovsdb_replica_class {
86 struct ovsdb_error *(*commit)(struct ovsdb_replica *,
87 const struct ovsdb_txn *, bool durable);
88 void (*destroy)(struct ovsdb_replica *);
89};
90
91void ovsdb_replica_init(struct ovsdb_replica *,
92 const struct ovsdb_replica_class *);
93
94void ovsdb_add_replica(struct ovsdb *, struct ovsdb_replica *);
95void ovsdb_remove_replica(struct ovsdb *, struct ovsdb_replica *);
f85f8ebb
BP
96
97#endif /* ovsdb/ovsdb.h */