]> git.proxmox.com Git - mirror_ovs.git/blame - lib/ovsdb-idl.h
netdev-offload-tc: Use single 'once' variable for probing tc features
[mirror_ovs.git] / lib / ovsdb-idl.h
CommitLineData
695e5403 1/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2019 Nicira, Inc.
93fe0264 2 * Copyright (C) 2016 Hewlett Packard Enterprise Development LP
c3bb4bd7
BP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef OVSDB_IDL_H
18#define OVSDB_IDL_H 1
19
2ce42c88
BP
20/* Open vSwitch Database Interface Definition Language (OVSDB IDL).
21 *
22 * The OVSDB IDL maintains an in-memory replica of a database. It issues RPC
23 * requests to an OVSDB database server and parses the responses, converting
24 * raw JSON into data structures that are easier for clients to digest. Most
25 * notably, references to rows via UUID become C pointers.
26 *
d322ffc8
BP
27 * The IDL always presents a consistent snapshot of the database to its client,
28 * that is, it won't present the effects of some part of a transaction applied
29 * at the database server without presenting all of its effects.
30 *
2ce42c88
BP
31 * The IDL also assists with issuing database transactions. The client creates
32 * a transaction, manipulates the IDL data structures, and commits or aborts
33 * the transaction. The IDL then composes and issues the necessary JSON-RPC
34 * requests and reports to the client whether the transaction completed
35 * successfully.
36 */
37
f3d64521 38#include <stdbool.h>
b54e22e9 39#include <stdint.h>
e1c0e2d1 40#include "compiler.h"
8c3c2f30 41#include "ovsdb-types.h"
16ebb90e
LS
42#include "ovsdb-data.h"
43#include "openvswitch/list.h"
44#include "ovsdb-condition.h"
93fe0264 45#include "skiplist.h"
b54e22e9 46
9131abe2
YHW
47#ifdef __cplusplus
48extern "C" {
49#endif
50
b54e22e9 51struct json;
979821c0 52struct ovsdb_datum;
c3bb4bd7 53struct ovsdb_idl_class;
932104f4 54struct ovsdb_idl_row;
979821c0
BP
55struct ovsdb_idl_column;
56struct ovsdb_idl_table_class;
57struct uuid;
c3bb4bd7
BP
58
59struct ovsdb_idl *ovsdb_idl_create(const char *remote,
ef73f86c 60 const struct ovsdb_idl_class *,
fba6bd1d
BP
61 bool monitor_everything_by_default,
62 bool retry);
5e07b8f9
BP
63struct ovsdb_idl *ovsdb_idl_create_unconnected(
64 const struct ovsdb_idl_class *, bool monitor_everything_by_default);
1b62572d 65void ovsdb_idl_set_remote(struct ovsdb_idl *, const char *, bool);
d5905055 66void ovsdb_idl_set_shuffle_remotes(struct ovsdb_idl *, bool);
89b522ae 67void ovsdb_idl_reset_min_index(struct ovsdb_idl *);
c3bb4bd7
BP
68void ovsdb_idl_destroy(struct ovsdb_idl *);
69
1b1d2e6d
BP
70void ovsdb_idl_set_leader_only(struct ovsdb_idl *, bool leader_only);
71
854a94d9 72void ovsdb_idl_run(struct ovsdb_idl *);
c3bb4bd7
BP
73void ovsdb_idl_wait(struct ovsdb_idl *);
74
06b6d651
BP
75void ovsdb_idl_set_lock(struct ovsdb_idl *, const char *lock_name);
76bool ovsdb_idl_has_lock(const struct ovsdb_idl *);
77bool ovsdb_idl_is_lock_contended(const struct ovsdb_idl *);
78
7152b6fa 79const struct uuid * ovsdb_idl_get_monitor_id(const struct ovsdb_idl *);
c3bb4bd7 80unsigned int ovsdb_idl_get_seqno(const struct ovsdb_idl *);
f3d64521 81bool ovsdb_idl_has_ever_connected(const struct ovsdb_idl *);
705d7a39 82void ovsdb_idl_enable_reconnect(struct ovsdb_idl *);
c3bb4bd7 83void ovsdb_idl_force_reconnect(struct ovsdb_idl *);
8cdec725 84void ovsdb_idl_verify_write_only(struct ovsdb_idl *);
fba6bd1d
BP
85
86bool ovsdb_idl_is_alive(const struct ovsdb_idl *);
82b261b9 87bool ovsdb_idl_is_connected(const struct ovsdb_idl *idl);
fba6bd1d 88int ovsdb_idl_get_last_error(const struct ovsdb_idl *);
a4927e36
HL
89
90void ovsdb_idl_set_probe_interval(const struct ovsdb_idl *, int probe_interval);
11990a52
BP
91
92void ovsdb_idl_check_consistency(const struct ovsdb_idl *);
a0b02897
BP
93
94const struct ovsdb_idl_class *ovsdb_idl_get_class(const struct ovsdb_idl *);
95const struct ovsdb_idl_table_class *ovsdb_idl_table_class_from_column(
96 const struct ovsdb_idl_class *, const struct ovsdb_idl_column *);
ef73f86c 97\f
695e5403
BP
98/* Choosing columns and tables to replicate.
99 *
100 * The client may choose any subset of the columns and tables to replicate,
101 * specifying it one of two ways:
102 *
8205fbc8 103 * - As a deny list (adding the columns or tables to replicate). To do so,
695e5403
BP
104 * the client passes false as 'monitor_everything_by_default' to
105 * ovsdb_idl_create() and then calls ovsdb_idl_add_column() and
106 * ovsdb_idl_add_table() for the desired columns and, if necessary, tables.
107 *
8205fbc8 108 * - As an allow list (replicating all columns and tables except those
695e5403
BP
109 * explicitly removed). To do so, the client passes true as
110 * 'monitor_everything_by_default' to ovsdb_idl_create() and then calls
111 * ovsdb_idl_omit() to remove columns.
112 *
113 * There are multiple modes a column may be replicated:
114 *
115 * - Read-only. This is the default. Whenever the column changes in any
116 * replicated row, the value returned by ovsdb_idl_get_seqno() will change,
117 * letting the client know to look at the replicated data again.
118 *
119 * - Write-only. This is for columns that the client sets and updates but
120 * does not want to be alerted about its own updates (which, at the OVSDB
121 * level, cannot be distinguished from updates made by any other client).
122 * The column will be replicated in the same way as for read-only columns,
123 * but the value returned by ovsdb_idl_get_seqno() will not change when the
124 * column changes, saving wasted CPU time.
125 *
126 * (A "write-only" client probably does read the column so that it can know
127 * whether it needs to update it, but it doesn't expect to react to changes
128 * by other clients.)
129 *
130 * To mark a replicated column as write-only, a client calls
131 * ovsdb_idl_omit_alert(). (The column must already be replicated one of
132 * the ways described in the previous list.)
133 *
134 * This is an optimization only and does not affect behavioral correctness
135 * of an otherwise well-written client.
136 *
137 * - Read/write. In theory, an OVSDB client might both read and write a
138 * column, although OVSDB schemas are usually designed so that any given
139 * client only does one or the other. This is actually the same as
140 * read/write columns; that is, the client need take no special action.
141 */
ef73f86c 142
695e5403
BP
143/* Modes with which the IDL can replicate a column. See above comment for
144 * overview.
ef73f86c 145 *
695e5403
BP
146 * If no bits are set, the IDL does not replicate the column at all. The
147 * client will always see it with the default value for its type.
ef73f86c 148 *
695e5403
BP
149 * If OVSDB_IDL_MONITOR is set, then the IDL replicates the column and sets it
150 * to to the value in the database. If OVSDB_IDL_ALERT is also set, then the
151 * IDL will change the value returned by ovsdb_idl_get_seqno() when the
152 * column's value changes in any row.
ef73f86c
BP
153 *
154 * The possible mode combinations are:
155 *
695e5403
BP
156 * - 0, for a column that a client doesn't care about. This is the default
157 * for every column in every table, if the client passes false for
158 * 'monitor_everything_by_default' to ovsdb_idl_create().
ef73f86c
BP
159 *
160 * - (OVSDB_IDL_MONITOR | OVSDB_IDL_ALERT), for a column that a client wants
695e5403
BP
161 * to track and possibly update. This is the default for every column in
162 * every table, if the client passes true for
163 * 'monitor_everything_by_default' to ovsdb_idl_create().
ef73f86c
BP
164 *
165 * - OVSDB_IDL_MONITOR, for columns that a client treats as "write-only",
166 * that is, it updates them but doesn't want to get alerted about its own
167 * updates. It also won't be alerted about other clients' updates, so this
168 * is suitable only for use by a client that "owns" a particular column.
695e5403
BP
169 * Use ovsdb_idl_omit_alert() to set a column that is already replicated to
170 * this mode.
ef73f86c
BP
171 *
172 * - OVDSB_IDL_ALERT without OVSDB_IDL_MONITOR is not valid.
932104f4
SA
173 *
174 * - (OVSDB_IDL_MONITOR | OVSDB_IDL_ALERT | OVSDB_IDL_TRACK), for a column
175 * that a client wants to track using the change tracking
176 * ovsdb_idl_track_get_*() functions.
ef73f86c 177 */
695e5403
BP
178#define OVSDB_IDL_MONITOR (1 << 0) /* Replicate this column? */
179#define OVSDB_IDL_ALERT (1 << 1) /* Alert client when column changes? */
932104f4 180#define OVSDB_IDL_TRACK (1 << 2)
ef73f86c
BP
181
182void ovsdb_idl_add_column(struct ovsdb_idl *, const struct ovsdb_idl_column *);
183void ovsdb_idl_add_table(struct ovsdb_idl *,
184 const struct ovsdb_idl_table_class *);
c3bb4bd7 185
c547535a 186void ovsdb_idl_omit(struct ovsdb_idl *, const struct ovsdb_idl_column *);
ef73f86c 187void ovsdb_idl_omit_alert(struct ovsdb_idl *, const struct ovsdb_idl_column *);
932104f4 188
104aec4e
RM
189/* Change tracking.
190 *
191 * In OVSDB, change tracking is applied at each client in the IDL layer. This
192 * means that when a client makes a request to track changes on a particular
193 * table, they are essentially requesting information about the incremental
194 * changes to that table from the point in time that the request is made. Once
195 * the client clears tracked changes, that information will no longer be
196 * available.
197 *
198 * The implication of the above is that if a client requires replaying
199 * untracked history, it faces the choice of either trying to remember changes
200 * itself (which translates into a memory leak) or of being structured with a
201 * path for processing the full untracked table as well as a path that
202 * processes incremental changes. */
932104f4
SA
203enum ovsdb_idl_change {
204 OVSDB_IDL_CHANGE_INSERT,
205 OVSDB_IDL_CHANGE_MODIFY,
206 OVSDB_IDL_CHANGE_DELETE,
207 OVSDB_IDL_CHANGE_MAX
208};
209
210/* Row, table sequence numbers */
211unsigned int ovsdb_idl_table_get_seqno(
212 const struct ovsdb_idl *idl,
213 const struct ovsdb_idl_table_class *table_class);
214unsigned int ovsdb_idl_row_get_seqno(
215 const struct ovsdb_idl_row *row,
216 enum ovsdb_idl_change change);
217
218void ovsdb_idl_track_add_column(struct ovsdb_idl *idl,
219 const struct ovsdb_idl_column *column);
220void ovsdb_idl_track_add_all(struct ovsdb_idl *idl);
221const struct ovsdb_idl_row *ovsdb_idl_track_get_first(
222 const struct ovsdb_idl *, const struct ovsdb_idl_table_class *);
223const struct ovsdb_idl_row *ovsdb_idl_track_get_next(const struct ovsdb_idl_row *);
32d37ce8
SA
224bool ovsdb_idl_track_is_updated(const struct ovsdb_idl_row *row,
225 const struct ovsdb_idl_column *column);
1456335d 226void ovsdb_idl_track_clear(struct ovsdb_idl *);
932104f4 227
ef73f86c
BP
228\f
229/* Reading the database replica. */
c547535a 230
979821c0
BP
231const struct ovsdb_idl_row *ovsdb_idl_get_row_for_uuid(
232 const struct ovsdb_idl *, const struct ovsdb_idl_table_class *,
233 const struct uuid *);
234const struct ovsdb_idl_row *ovsdb_idl_first_row(
235 const struct ovsdb_idl *, const struct ovsdb_idl_table_class *);
236const struct ovsdb_idl_row *ovsdb_idl_next_row(const struct ovsdb_idl_row *);
237
8c3c2f30
BP
238const struct ovsdb_datum *ovsdb_idl_read(const struct ovsdb_idl_row *,
239 const struct ovsdb_idl_column *);
240const struct ovsdb_datum *ovsdb_idl_get(const struct ovsdb_idl_row *,
241 const struct ovsdb_idl_column *,
242 enum ovsdb_atomic_type key_type,
243 enum ovsdb_atomic_type value_type);
ff495b63
BP
244bool ovsdb_idl_is_mutable(const struct ovsdb_idl_row *,
245 const struct ovsdb_idl_column *);
cfea354b
BP
246
247bool ovsdb_idl_row_is_synthetic(const struct ovsdb_idl_row *);
ef73f86c 248\f
2f926787
BP
249/* Transactions.
250 *
251 * A transaction may modify the contents of a database by modifying the values
252 * of columns, deleting rows, inserting rows, or adding checks that columns in
253 * the database have not changed ("verify" operations), through
254 * ovsdb_idl_txn_*() functions. (The OVSDB IDL code generator produces helper
255 * functions that internally call the ovsdb_idl_txn_*() functions. These are
256 * likely to be more convenient.)
257 *
258 * Reading and writing columns and inserting and deleting rows are all
259 * straightforward. The reasons to verify columns are less obvious.
260 * Verification is the key to maintaining transactional integrity. Because
261 * OVSDB handles multiple clients, it can happen that between the time that
262 * OVSDB client A reads a column and writes a new value, OVSDB client B has
263 * written that column. Client A's write should not ordinarily overwrite
264 * client B's, especially if the column in question is a "map" column that
265 * contains several more or less independent data items. If client A adds a
266 * "verify" operation before it writes the column, then the transaction fails
267 * in case client B modifies it first. Client A will then see the new value of
268 * the column and compose a new transaction based on the new contents written
269 * by client B.
270 *
271 * When a transaction is complete, which must be before the next call to
272 * ovsdb_idl_run() on 'idl', call ovsdb_idl_txn_commit() or
273 * ovsdb_idl_txn_abort().
274 *
275 * The life-cycle of a transaction looks like this:
276 *
277 * 1. Create the transaction and record the initial sequence number:
278 *
279 * seqno = ovsdb_idl_get_seqno(idl);
280 * txn = ovsdb_idl_txn_create(idl);
281 *
282 * 2. Modify the database with ovsdb_idl_txn_*() functions directly or
283 * indirectly.
284 *
285 * 3. Commit the transaction by calling ovsdb_idl_txn_commit(). The first call
286 * to this function probably returns TXN_INCOMPLETE. The client must keep
287 * calling again along as this remains true, calling ovsdb_idl_run() in
288 * between to let the IDL do protocol processing. (If the client doesn't
289 * have anything else to do in the meantime, it can use
290 * ovsdb_idl_txn_commit_block() to avoid having to loop itself.)
291 *
292 * 4. If the final status is TXN_TRY_AGAIN, wait for ovsdb_idl_get_seqno() to
293 * change from the saved 'seqno' (it's possible that it's already changed,
294 * in which case the client should not wait at all), then start over from
295 * step 1. Only a call to ovsdb_idl_run() will change the return value of
296 * ovsdb_idl_get_seqno(). (ovsdb_idl_txn_commit_block() calls
297 * ovsdb_idl_run().)
298 */
8c3c2f30 299
475281c0 300enum ovsdb_idl_txn_status {
2096903b 301 TXN_UNCOMMITTED, /* Not yet committed or aborted. */
b54e22e9 302 TXN_UNCHANGED, /* Transaction didn't include any changes. */
475281c0
BP
303 TXN_INCOMPLETE, /* Commit in progress, please wait. */
304 TXN_ABORTED, /* ovsdb_idl_txn_abort() called. */
305 TXN_SUCCESS, /* Commit successful. */
854a94d9 306 TXN_TRY_AGAIN, /* Commit failed because a "verify" operation
475281c0 307 * reported an inconsistency, due to a network
4fdfe5cc
BP
308 * problem, or other transient failure. Wait
309 * for a change, then try again. */
06b6d651 310 TXN_NOT_LOCKED, /* Server hasn't given us the lock yet. */
475281c0
BP
311 TXN_ERROR /* Commit failed due to a hard error. */
312};
313
314const char *ovsdb_idl_txn_status_to_string(enum ovsdb_idl_txn_status);
315
316struct ovsdb_idl_txn *ovsdb_idl_txn_create(struct ovsdb_idl *);
e1c0e2d1 317void ovsdb_idl_txn_add_comment(struct ovsdb_idl_txn *, const char *, ...)
cab50449 318 OVS_PRINTF_FORMAT (2, 3);
577aebdf 319void ovsdb_idl_txn_set_dry_run(struct ovsdb_idl_txn *);
94fbe1aa
BP
320void ovsdb_idl_txn_increment(struct ovsdb_idl_txn *,
321 const struct ovsdb_idl_row *,
de32cec7
BP
322 const struct ovsdb_idl_column *,
323 bool force);
475281c0 324void ovsdb_idl_txn_destroy(struct ovsdb_idl_txn *);
586bb84a 325void ovsdb_idl_txn_wait(const struct ovsdb_idl_txn *);
475281c0 326enum ovsdb_idl_txn_status ovsdb_idl_txn_commit(struct ovsdb_idl_txn *);
af96ccd2 327enum ovsdb_idl_txn_status ovsdb_idl_txn_commit_block(struct ovsdb_idl_txn *);
475281c0
BP
328void ovsdb_idl_txn_abort(struct ovsdb_idl_txn *);
329
91e310a5
BP
330const char *ovsdb_idl_txn_get_error(const struct ovsdb_idl_txn *);
331
69490970
BP
332int64_t ovsdb_idl_txn_get_increment_new_value(const struct ovsdb_idl_txn *);
333const struct uuid *ovsdb_idl_txn_get_insert_uuid(const struct ovsdb_idl_txn *,
334 const struct uuid *);
335
979821c0
BP
336void ovsdb_idl_txn_write(const struct ovsdb_idl_row *,
337 const struct ovsdb_idl_column *,
338 struct ovsdb_datum *);
fe19569a
BP
339void ovsdb_idl_txn_write_clone(const struct ovsdb_idl_row *,
340 const struct ovsdb_idl_column *,
341 const struct ovsdb_datum *);
f199df26
EA
342void ovsdb_idl_txn_write_partial_map(const struct ovsdb_idl_row *,
343 const struct ovsdb_idl_column *,
344 struct ovsdb_datum *);
345void ovsdb_idl_txn_delete_partial_map(const struct ovsdb_idl_row *,
346 const struct ovsdb_idl_column *,
347 struct ovsdb_datum *);
f1ab6e06
RM
348void ovsdb_idl_txn_write_partial_set(const struct ovsdb_idl_row *,
349 const struct ovsdb_idl_column *,
350 struct ovsdb_datum *);
351void ovsdb_idl_txn_delete_partial_set(const struct ovsdb_idl_row *,
352 const struct ovsdb_idl_column *,
353 struct ovsdb_datum *);
9e336f49
BP
354void ovsdb_idl_txn_delete(const struct ovsdb_idl_row *);
355const struct ovsdb_idl_row *ovsdb_idl_txn_insert(
ce5a3e38
BP
356 struct ovsdb_idl_txn *, const struct ovsdb_idl_table_class *,
357 const struct uuid *);
979821c0 358
1e86ae6f 359struct ovsdb_idl *ovsdb_idl_txn_get_idl (struct ovsdb_idl_txn *);
a660eac8 360void ovsdb_idl_get_initial_snapshot(struct ovsdb_idl *);
a548a764
AW
361\f
362
363/* ovsdb_idl_loop provides an easy way to manage the transactions related
364 * to 'idl' and to cope with different status during transaction. */
365struct ovsdb_idl_loop {
366 struct ovsdb_idl *idl;
367 unsigned int skip_seqno;
368
369 struct ovsdb_idl_txn *committing_txn;
370 unsigned int precommit_seqno;
371
372 struct ovsdb_idl_txn *open_txn;
fa183acc
BP
373
374 /* These members allow a client a simple, stateless way to keep track of
375 * transactions that commit: when a transaction commits successfully,
376 * ovsdb_idl_loop_commit_and_wait() copies 'next_cfg' to 'cur_cfg'. Thus,
377 * the client can set 'next_cfg' to a value that indicates a successful
378 * commit and check 'cur_cfg' on each iteration. */
379 int64_t cur_cfg;
380 int64_t next_cfg;
a548a764
AW
381};
382
383#define OVSDB_IDL_LOOP_INITIALIZER(IDL) { .idl = (IDL) }
384
385void ovsdb_idl_loop_destroy(struct ovsdb_idl_loop *);
386struct ovsdb_idl_txn *ovsdb_idl_loop_run(struct ovsdb_idl_loop *);
8ba0e38a 387int ovsdb_idl_loop_commit_and_wait(struct ovsdb_idl_loop *);
239fa5bb
BP
388\f
389/* Conditional Replication
390 * =======================
391 *
392 * By default, when the IDL replicates a particular table in the database, it
393 * replicates every row in the table. These functions allow the client to
394 * specify that only selected rows should be replicated, by constructing a
395 * per-table condition that specifies the rows to replicate.
0164e367
BP
396 *
397 * A condition is a disjunction of clauses. The condition is true, and thus a
398 * row is replicated, if any of the clauses evaluates to true for a given row.
399 * (Thus, a condition with no clauses is always false.)
239fa5bb 400 */
16ebb90e 401
0164e367
BP
402struct ovsdb_idl_condition {
403 struct hmap clauses; /* Contains "struct ovsdb_idl_clause"s. */
404 bool is_true; /* Is the condition unconditionally true? */
405};
406#define OVSDB_IDL_CONDITION_INIT(CONDITION) \
407 { HMAP_INITIALIZER(&(CONDITION)->clauses), false }
408
409void ovsdb_idl_condition_init(struct ovsdb_idl_condition *);
410void ovsdb_idl_condition_clear(struct ovsdb_idl_condition *);
411void ovsdb_idl_condition_destroy(struct ovsdb_idl_condition *);
412void ovsdb_idl_condition_add_clause(struct ovsdb_idl_condition *,
16ebb90e
LS
413 enum ovsdb_function function,
414 const struct ovsdb_idl_column *column,
239fa5bb 415 const struct ovsdb_datum *arg);
0164e367
BP
416void ovsdb_idl_condition_add_clause_true(struct ovsdb_idl_condition *);
417bool ovsdb_idl_condition_is_true(const struct ovsdb_idl_condition *);
418
46437c52
AZ
419unsigned int ovsdb_idl_set_condition(struct ovsdb_idl *,
420 const struct ovsdb_idl_table_class *,
421 const struct ovsdb_idl_condition *);
16ebb90e 422
46437c52 423unsigned int ovsdb_idl_get_condition_seqno(const struct ovsdb_idl *);
d14e007c
BP
424\f
425/* Indexes over one or more columns in the IDL, to retrieve rows matching
426 * particular search criteria and to iterate over a subset of rows in a defined
427 * order. */
93fe0264 428
d14e007c
BP
429enum ovsdb_index_order {
430 OVSDB_INDEX_ASC, /* 0, 1, 2, ... */
431 OVSDB_INDEX_DESC /* 2, 1, 0, ... */
432};
93fe0264 433
d14e007c 434typedef int column_comparator_func(const void *a, const void *b);
93fe0264 435
d14e007c
BP
436struct ovsdb_idl_index_column {
437 const struct ovsdb_idl_column *column;
438 column_comparator_func *comparer;
439 enum ovsdb_index_order order;
440};
93fe0264 441
d14e007c
BP
442/* Creating an index. */
443struct ovsdb_idl_index *ovsdb_idl_index_create(
444 struct ovsdb_idl *, const struct ovsdb_idl_index_column *, size_t n);
445struct ovsdb_idl_index *ovsdb_idl_index_create1(
446 struct ovsdb_idl *, const struct ovsdb_idl_column *);
447struct ovsdb_idl_index *ovsdb_idl_index_create2(
448 struct ovsdb_idl *, const struct ovsdb_idl_column *,
449 const struct ovsdb_idl_column *);
450
451/* Searching an index. */
452struct ovsdb_idl_row *ovsdb_idl_index_find(struct ovsdb_idl_index *,
453 const struct ovsdb_idl_row *);
454\f
455/* Iteration over an index.
456 *
457 * Usually these would be invoked through table-specific wrappers generated
458 * by the IDL. */
459
460struct ovsdb_idl_cursor {
461 struct ovsdb_idl_index *index; /* Index being iterated. */
462 struct skiplist_node *position; /* Current position in 'index'. */
93fe0264
LR
463};
464
d14e007c
BP
465struct ovsdb_idl_cursor ovsdb_idl_cursor_first(struct ovsdb_idl_index *);
466struct ovsdb_idl_cursor ovsdb_idl_cursor_first_eq(
467 struct ovsdb_idl_index *, const struct ovsdb_idl_row *);
468struct ovsdb_idl_cursor ovsdb_idl_cursor_first_ge(
469 struct ovsdb_idl_index *, const struct ovsdb_idl_row *);
470
471void ovsdb_idl_cursor_next(struct ovsdb_idl_cursor *);
472void ovsdb_idl_cursor_next_eq(struct ovsdb_idl_cursor *);
473
474struct ovsdb_idl_row *ovsdb_idl_cursor_data(struct ovsdb_idl_cursor *);
9131abe2
YHW
475
476#ifdef __cplusplus
477}
478#endif
479
c3bb4bd7 480#endif /* ovsdb-idl.h */