+static void
+monitor_print(struct json *table_updates,
+ const struct monitored_table *mts, size_t n_mts,
+ bool initial)
+{
+ size_t i;
+
+ if (table_updates->type != JSON_OBJECT) {
+ ovs_error(0, "<table-updates> is not object");
+ return;
+ }
+
+ for (i = 0; i < n_mts; i++) {
+ const struct monitored_table *mt = &mts[i];
+ struct json *table_update = shash_find_data(json_object(table_updates),
+ mt->table->name);
+ if (table_update) {
+ monitor_print_table(table_update, mt,
+ n_mts > 1 ? xstrdup(mt->table->name) : NULL,
+ initial);
+ }
+ }
+}
+
+static void
+monitor2_print_row(struct json *row, const char *type, const char *uuid,
+ const struct ovsdb_column_set *columns, struct table *t)
+{
+ if (!strcmp(type, "delete")) {
+ if (row->type != JSON_NULL) {
+ ovs_error(0, "delete method does not expect <row>");
+ return;
+ }
+
+ table_add_row(t);
+ table_add_cell(t)->text = xstrdup(uuid);
+ table_add_cell(t)->text = xstrdup(type);
+ } else {
+ if (!row || row->type != JSON_OBJECT) {
+ ovs_error(0, "<row> is not object");
+ return;
+ }
+ monitor_print_row(row, type, uuid, columns, t);
+ }
+}
+
+static void
+monitor2_print_table(struct json *table_update2,
+ const struct monitored_table *mt, char *caption)
+{
+ const struct ovsdb_table_schema *table = mt->table;
+ const struct ovsdb_column_set *columns = &mt->columns;
+ struct shash_node *node;
+ struct table t;
+ size_t i;
+
+ if (table_update2->type != JSON_OBJECT) {
+ ovs_error(0, "<table-update> for table %s is not object", table->name);
+ return;
+ }
+
+ table_init(&t);
+ table_set_timestamp(&t, timestamp);
+ table_set_caption(&t, caption);
+
+ table_add_column(&t, "row");
+ table_add_column(&t, "action");
+ for (i = 0; i < columns->n_columns; i++) {
+ table_add_column(&t, "%s", columns->columns[i]->name);
+ }
+ SHASH_FOR_EACH (node, json_object(table_update2)) {
+ struct json *row_update2 = node->data;
+ const char *operation;
+ struct json *row;
+ const char *ops[] = {"delete", "initial", "modify", "insert"};
+
+ if (row_update2->type != JSON_OBJECT) {
+ ovs_error(0, "<row-update2> is not object");
+ continue;
+ }
+
+ /* row_update2 contains one of objects indexed by ops[] */
+ for (int i = 0; i < ARRAY_SIZE(ops); i++) {
+ operation = ops[i];
+ row = shash_find_data(json_object(row_update2), operation);
+
+ if (row) {
+ monitor2_print_row(row, operation, node->name, columns, &t);
+ break;
+ }
+ }
+ }
+ table_print(&t, &table_style);
+ table_destroy(&t);
+}
+
+static void
+monitor2_print(struct json *table_updates2,
+ const struct monitored_table *mts, size_t n_mts)
+{
+ size_t i;
+
+ if (table_updates2->type != JSON_OBJECT) {
+ ovs_error(0, "<table-updates2> is not object");
+ return;
+ }
+
+ for (i = 0; i < n_mts; i++) {
+ const struct monitored_table *mt = &mts[i];
+ struct json *table_update = shash_find_data(
+ json_object(table_updates2),
+ mt->table->name);
+ if (table_update) {
+ monitor2_print_table(table_update, mt,
+ n_mts > 1 ? xstrdup(mt->table->name) : NULL);
+ }
+ }
+}
+