static unsigned int epoch;
static void
-coverage_unixctl_log(struct unixctl_conn *conn, const char *args UNUSED)
+coverage_unixctl_log(struct unixctl_conn *conn, const char *args UNUSED,
+ void *aux UNUSED)
{
coverage_log(VLL_WARN, false);
unixctl_command_reply(conn, 200, NULL);
void
coverage_init(void)
{
- unixctl_command_register("coverage/log", coverage_unixctl_log);
+ unixctl_command_register("coverage/log", coverage_unixctl_log, NULL);
}
/* Sorts coverage counters in descending order by count, within equal counts
#include "vlog.h"
\f
struct unixctl_command {
- void (*cb)(struct unixctl_conn *, const char *args);
+ unixctl_cb_func *cb;
+ void *aux;
};
struct unixctl_conn {
static struct shash commands = SHASH_INITIALIZER(&commands);
static void
-unixctl_help(struct unixctl_conn *conn, const char *args UNUSED)
+unixctl_help(struct unixctl_conn *conn, const char *args UNUSED,
+ void *aux UNUSED)
{
struct ds ds = DS_EMPTY_INITIALIZER;
struct shash_node *node;
}
void
-unixctl_command_register(const char *name,
- void (*cb)(struct unixctl_conn *, const char *args))
+unixctl_command_register(const char *name, unixctl_cb_func *cb, void *aux)
{
struct unixctl_command *command;
|| shash_find_data(&commands, name) == cb);
command = xmalloc(sizeof *command);
command->cb = cb;
+ command->aux = aux;
shash_add(&commands, name, command);
}
struct unixctl_server *server;
int error;
- unixctl_command_register("help", unixctl_help);
+ unixctl_command_register("help", unixctl_help, NULL);
server = xmalloc(sizeof *server);
list_init(&server->conns);
command = shash_find_data(&commands, name);
if (command) {
- command->cb(conn, args);
+ command->cb(conn, args, command->aux);
} else {
char *msg = xasprintf("\"%s\" is not a valid command", name);
unixctl_command_reply(conn, 400, msg);
/* Command registration. */
struct unixctl_conn;
+typedef void unixctl_cb_func(struct unixctl_conn *,
+ const char *args, void *aux);
void unixctl_command_register(const char *name,
- void (*cb)(struct unixctl_conn *,
- const char *args));
+ unixctl_cb_func *cb, void *aux);
void unixctl_command_reply(struct unixctl_conn *, int code,
const char *body);
}
static void
-vlog_unixctl_set(struct unixctl_conn *conn, const char *args)
+vlog_unixctl_set(struct unixctl_conn *conn, const char *args, void *aux UNUSED)
{
char *msg = vlog_set_levels_from_string(args);
unixctl_command_reply(conn, msg ? 501 : 202, msg);
}
static void
-vlog_unixctl_list(struct unixctl_conn *conn, const char *args UNUSED)
+vlog_unixctl_list(struct unixctl_conn *conn,
+ const char *args UNUSED, void *aux UNUSED)
{
char *msg = vlog_get_levels();
unixctl_command_reply(conn, 200, msg);
}
static void
-vlog_unixctl_reopen(struct unixctl_conn *conn, const char *args UNUSED)
+vlog_unixctl_reopen(struct unixctl_conn *conn,
+ const char *args UNUSED, void *aux UNUSED)
{
if (log_file_name) {
int error = vlog_reopen_log_file();
VLOG_ERR("current time is negative: %s (%ld)", s, (long int) now);
}
- unixctl_command_register("vlog/set", vlog_unixctl_set);
- unixctl_command_register("vlog/list", vlog_unixctl_list);
- unixctl_command_register("vlog/reopen", vlog_unixctl_reopen);
+ unixctl_command_register("vlog/set", vlog_unixctl_set, NULL);
+ unixctl_command_register("vlog/list", vlog_unixctl_list, NULL);
+ unixctl_command_register("vlog/reopen", vlog_unixctl_reopen, NULL);
}
/* Closes the logging subsystem. */
static struct bridge *bridge_create(const char *name);
static void bridge_destroy(struct bridge *);
static struct bridge *bridge_lookup(const char *name);
-static void bridge_unixctl_dump_flows(struct unixctl_conn *, const char *);
+static unixctl_cb_func bridge_unixctl_dump_flows;
static int bridge_run_one(struct bridge *);
static void bridge_reconfigure_one(struct bridge *);
static void bridge_reconfigure_controller(struct bridge *);
static struct iface *bridge_get_local_iface(struct bridge *);
static uint64_t dpid_from_hash(const void *, size_t nbytes);
-static void bridge_unixctl_fdb_show(struct unixctl_conn *, const char *args);
+static unixctl_cb_func bridge_unixctl_fdb_show;
static void bond_init(void);
static void bond_run(struct bridge *);
struct svec dpif_names;
size_t i;
- unixctl_command_register("fdb/show", bridge_unixctl_fdb_show);
+ unixctl_command_register("fdb/show", bridge_unixctl_fdb_show, NULL);
svec_init(&dpif_names);
dp_enumerate(&dpif_names);
}
svec_destroy(&dpif_names);
- unixctl_command_register("bridge/dump-flows", bridge_unixctl_dump_flows);
+ unixctl_command_register("bridge/dump-flows", bridge_unixctl_dump_flows,
+ NULL);
bond_init();
bridge_reconfigure();
\f
/* Bridge unixctl user interface functions. */
static void
-bridge_unixctl_fdb_show(struct unixctl_conn *conn, const char *args)
+bridge_unixctl_fdb_show(struct unixctl_conn *conn,
+ const char *args, void *aux UNUSED)
{
struct ds ds = DS_EMPTY_INITIALIZER;
const struct bridge *br;
/* Handle requests for a listing of all flows known by the OpenFlow
* stack, including those normally hidden. */
static void
-bridge_unixctl_dump_flows(struct unixctl_conn *conn, const char *args)
+bridge_unixctl_dump_flows(struct unixctl_conn *conn,
+ const char *args, void *aux UNUSED)
{
struct bridge *br;
struct ds results;
/* Bonding unixctl user interface functions. */
static void
-bond_unixctl_list(struct unixctl_conn *conn, const char *args UNUSED)
+bond_unixctl_list(struct unixctl_conn *conn,
+ const char *args UNUSED, void *aux UNUSED)
{
struct ds ds = DS_EMPTY_INITIALIZER;
const struct bridge *br;
}
static void
-bond_unixctl_show(struct unixctl_conn *conn, const char *args)
+bond_unixctl_show(struct unixctl_conn *conn,
+ const char *args, void *aux UNUSED)
{
struct ds ds = DS_EMPTY_INITIALIZER;
const struct port *port;
}
static void
-bond_unixctl_migrate(struct unixctl_conn *conn, const char *args_)
+bond_unixctl_migrate(struct unixctl_conn *conn, const char *args_,
+ void *aux UNUSED)
{
char *args = (char *) args_;
char *save_ptr = NULL;
}
static void
-bond_unixctl_set_active_slave(struct unixctl_conn *conn, const char *args_)
+bond_unixctl_set_active_slave(struct unixctl_conn *conn, const char *args_,
+ void *aux UNUSED)
{
char *args = (char *) args_;
char *save_ptr = NULL;
}
static void
-bond_unixctl_enable_slave(struct unixctl_conn *conn, const char *args)
+bond_unixctl_enable_slave(struct unixctl_conn *conn, const char *args,
+ void *aux UNUSED)
{
enable_slave(conn, args, true);
}
static void
-bond_unixctl_disable_slave(struct unixctl_conn *conn, const char *args)
+bond_unixctl_disable_slave(struct unixctl_conn *conn, const char *args,
+ void *aux UNUSED)
{
enable_slave(conn, args, false);
}
static void
-bond_unixctl_hash(struct unixctl_conn *conn, const char *args)
+bond_unixctl_hash(struct unixctl_conn *conn, const char *args,
+ void *aux UNUSED)
{
uint8_t mac[ETH_ADDR_LEN];
uint8_t hash;
static void
bond_init(void)
{
- unixctl_command_register("bond/list", bond_unixctl_list);
- unixctl_command_register("bond/show", bond_unixctl_show);
- unixctl_command_register("bond/migrate", bond_unixctl_migrate);
+ unixctl_command_register("bond/list", bond_unixctl_list, NULL);
+ unixctl_command_register("bond/show", bond_unixctl_show, NULL);
+ unixctl_command_register("bond/migrate", bond_unixctl_migrate, NULL);
unixctl_command_register("bond/set-active-slave",
- bond_unixctl_set_active_slave);
- unixctl_command_register("bond/enable-slave", bond_unixctl_enable_slave);
- unixctl_command_register("bond/disable-slave", bond_unixctl_disable_slave);
- unixctl_command_register("bond/hash", bond_unixctl_hash);
+ bond_unixctl_set_active_slave, NULL);
+ unixctl_command_register("bond/enable-slave", bond_unixctl_enable_slave,
+ NULL);
+ unixctl_command_register("bond/disable-slave", bond_unixctl_disable_slave,
+ NULL);
+ unixctl_command_register("bond/hash", bond_unixctl_hash, NULL);
}
\f
/* Port functions. */
static void parse_options(int argc, char *argv[]);
static void usage(void) NO_RETURN;
-static void reload(struct unixctl_conn *, const char *args);
+static unixctl_cb_func reload;
static bool need_reconfigure;
static struct unixctl_conn **conns;
if (retval) {
ovs_fatal(retval, "could not listen for control connections");
}
- unixctl_command_register("vswitchd/reload", reload);
+ unixctl_command_register("vswitchd/reload", reload, NULL);
retval = cfg_read();
if (retval) {
}
static void
-reload(struct unixctl_conn *conn, const char *args UNUSED)
+reload(struct unixctl_conn *conn, const char *args UNUSED, void *aux UNUSED)
{
need_reconfigure = true;
conns = xrealloc(conns, sizeof *conns * (n_conns + 1));