/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "compiler.h"
#include "dirs.h"
#include "dynamic-string.h"
+#include "fatal-signal.h"
#include "hash.h"
#include "json.h"
#include "ovsdb-data.h"
/* Format for table output. */
static struct table_style table_style = TABLE_STYLE_DEFAULT;
-/* All supported commands. */
-static const struct vtep_ctl_command_syntax all_commands[];
-
/* The IDL we're using and the current transaction, if any.
* This is for use by vtep_ctl_exit() only, to allow it to clean up.
* Other code should use its context arguments. */
static struct ovsdb_idl *the_idl;
static struct ovsdb_idl_txn *the_idl_txn;
-static void vtep_ctl_exit(int status) NO_RETURN;
-static void vtep_ctl_fatal(const char *, ...) PRINTF_FORMAT(1, 2) NO_RETURN;
+NO_RETURN static void vtep_ctl_exit(int status);
+NO_RETURN static void vtep_ctl_fatal(const char *, ...) PRINTF_FORMAT(1, 2);
static char *default_db(void);
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[], struct shash *local_options);
static bool might_write_to_db(char **argv);
static struct vtep_ctl_lswitch *find_lswitch(struct vtep_ctl_context *,
const char *name,
bool must_exist);
+static const struct vtep_ctl_command_syntax *get_all_commands(void);
int
main(int argc, char *argv[])
char *args;
set_program_name(argv[0]);
- signal(SIGPIPE, SIG_IGN);
+ fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_WARN);
vteprec_init();
options = xmemdup(global_long_options, sizeof global_long_options);
allocated_options = ARRAY_SIZE(global_long_options);
n_options = n_global_long_options;
- for (p = all_commands; p->name; p++) {
+ for (p = get_all_commands(); p->name; p++) {
if (p->options[0]) {
char *save_ptr = NULL;
char *name;
case 'V':
ovs_print_version(0, 0);
+ printf("DB Schema %s\n", vteprec_get_db_version());
exit(EXIT_SUCCESS);
case 't':
if (shash_is_empty(&commands)) {
const struct vtep_ctl_command_syntax *p;
- for (p = all_commands; p->name; p++) {
+ for (p = get_all_commands(); p->name; p++) {
shash_add_assert(&commands, p->name, p);
}
}
error = ovsdb_datum_from_string(&rm, &rm_type,
ctx->argv[i], ctx->symtab);
if (error && ovsdb_type_is_map(&rm_type)) {
- free(error);
rm_type.value.type = OVSDB_TYPE_VOID;
die_if_error(ovsdb_datum_from_string(&rm, &rm_type,
ctx->argv[i], ctx->symtab));
}
+ free(error);
ovsdb_datum_subtract(&old, type, &rm, &rm_type);
ovsdb_datum_destroy(&rm, &rm_type);
}
struct uuid dummy;
if (!uuid_from_string(&dummy, ds_cstr(&ctx->output))) {
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
real = ovsdb_idl_txn_get_insert_uuid(ctx->txn, &dummy);
if (real) {
return ovsdb_datum_includes_all(b, a, type);
default:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
}
switch (status) {
case TXN_UNCOMMITTED:
case TXN_INCOMPLETE:
- NOT_REACHED();
+ OVS_NOT_REACHED();
case TXN_ABORTED:
/* Should not happen--we never call ovsdb_idl_txn_abort(). */
vtep_ctl_fatal("database not locked");
default:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
free(error);
{NULL, 0, 0, NULL, NULL, NULL, NULL, RO},
};
+static const struct vtep_ctl_command_syntax *
+get_all_commands(void)
+{
+ return all_commands;
+}