1 /* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
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.
16 #ifndef OVSDB_IDL_PROVIDER_H
17 #define OVSDB_IDL_PROVIDER_H 1
19 #include "openvswitch/hmap.h"
20 #include "openvswitch/list.h"
21 #include "ovsdb-idl.h"
22 #include "ovsdb-map-op.h"
23 #include "ovsdb-set-op.h"
24 #include "ovsdb-types.h"
25 #include "openvswitch/shash.h"
28 struct ovsdb_idl_row
{
29 struct hmap_node hmap_node
; /* In struct ovsdb_idl_table's 'rows'. */
30 struct uuid uuid
; /* Row "_uuid" field. */
31 struct ovs_list src_arcs
; /* Forward arcs (ovsdb_idl_arc.src_node). */
32 struct ovs_list dst_arcs
; /* Backward arcs (ovsdb_idl_arc.dst_node). */
33 struct ovsdb_idl_table
*table
; /* Containing table. */
34 struct ovsdb_datum
*old
; /* Committed data (null if orphaned). */
36 /* Transactional data. */
37 struct ovsdb_datum
*new; /* Modified data (null to delete row). */
38 unsigned long int *prereqs
; /* Bitmap of columns to verify in "old". */
39 unsigned long int *written
; /* Bitmap of columns from "new" to write. */
40 struct hmap_node txn_node
; /* Node in ovsdb_idl_txn's list. */
41 unsigned long int *map_op_written
; /* Bitmap of columns pending map ops. */
42 struct map_op_list
**map_op_lists
; /* Per-column map operations. */
43 unsigned long int *set_op_written
; /* Bitmap of columns pending set ops. */
44 struct set_op_list
**set_op_lists
; /* Per-column set operations. */
47 unsigned int change_seqno
[OVSDB_IDL_CHANGE_MAX
];
48 struct ovs_list track_node
; /* Rows modified/added/deleted by IDL */
49 unsigned long int *updated
; /* Bitmap of columns updated by IDL */
52 struct ovsdb_idl_column
{
54 struct ovsdb_type type
;
56 void (*parse
)(struct ovsdb_idl_row
*, const struct ovsdb_datum
*);
57 void (*unparse
)(struct ovsdb_idl_row
*);
60 struct ovsdb_idl_table_class
{
63 const struct ovsdb_idl_column
*columns
;
65 size_t allocation_size
;
66 void (*row_init
)(struct ovsdb_idl_row
*);
69 struct ovsdb_idl_table
{
70 const struct ovsdb_idl_table_class
*class;
71 unsigned char *modes
; /* OVSDB_IDL_* bitmasks, indexed by column. */
72 bool need_table
; /* Monitor table even if no columns are selected
74 struct shash columns
; /* Contains "const struct ovsdb_idl_column *"s. */
75 struct hmap rows
; /* Contains "struct ovsdb_idl_row"s. */
76 struct ovsdb_idl
*idl
; /* Containing idl. */
77 unsigned int change_seqno
[OVSDB_IDL_CHANGE_MAX
];
78 struct ovs_list track_list
; /* Tracked rows (ovsdb_idl_row.track_node). */
79 struct ovsdb_idl_condition condition
;
83 struct ovsdb_idl_class
{
84 const char *database
; /* <db-name> for this database. */
85 const struct ovsdb_idl_table_class
*tables
;
89 struct ovsdb_idl_row
*ovsdb_idl_get_row_arc(
90 struct ovsdb_idl_row
*src
,
91 struct ovsdb_idl_table_class
*dst_table
,
92 const struct uuid
*dst_uuid
);
94 void ovsdb_idl_txn_verify(const struct ovsdb_idl_row
*,
95 const struct ovsdb_idl_column
*);
97 struct ovsdb_idl_txn
*ovsdb_idl_txn_get(const struct ovsdb_idl_row
*);
99 #endif /* ovsdb-idl-provider.h */