void
bond_init(void)
{
- 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",
+ unixctl_command_register("bond/list", "", bond_unixctl_list, NULL);
+ unixctl_command_register("bond/show", "port", bond_unixctl_show, NULL);
+ unixctl_command_register("bond/migrate", "port hash slave",
+ bond_unixctl_migrate, NULL);
+ unixctl_command_register("bond/set-active-slave", "port slave",
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);
+ unixctl_command_register("bond/enable-slave", "port slave",
+ bond_unixctl_enable_slave, NULL);
+ unixctl_command_register("bond/disable-slave", "port slave",
+ bond_unixctl_disable_slave, NULL);
+ unixctl_command_register("bond/hash", "mac [vlan] [basis]",
+ bond_unixctl_hash, NULL);
}
\f
static void
void
cfm_init(void)
{
- unixctl_command_register("cfm/show", cfm_unixctl_show, NULL);
+ unixctl_command_register("cfm/show", "interface", cfm_unixctl_show, NULL);
}
/* Allocates a 'cfm' object called 'name'. 'cfm' should be initialized by
void
coverage_init(void)
{
- unixctl_command_register("coverage/log", coverage_unixctl_log, NULL);
+ unixctl_command_register("coverage/log", "", coverage_unixctl_log, NULL);
}
/* Sorts coverage counters in descending order by count, within equal counts
void
lacp_init(void)
{
- unixctl_command_register("lacp/show", lacp_unixctl_show, NULL);
+ unixctl_command_register("lacp/show", "port", lacp_unixctl_show, NULL);
}
/* Creates a LACP object. */
void
stress_init_command(void)
{
- unixctl_command_register("stress/list", stress_unixctl_list, NULL);
- unixctl_command_register("stress/set", stress_unixctl_set, NULL);
- unixctl_command_register("stress/enable", stress_unixctl_enable, NULL);
- unixctl_command_register("stress/disable", stress_unixctl_disable, NULL);
+ unixctl_command_register("stress/list", "", stress_unixctl_list, NULL);
+ unixctl_command_register("stress/set", "option period [random | periodic]",
+ stress_unixctl_set, NULL);
+ unixctl_command_register("stress/enable", "", stress_unixctl_enable, NULL);
+ unixctl_command_register("stress/disable", "",
+ stress_unixctl_disable, NULL);
}
COVERAGE_DEFINE(unixctl_replied);
\f
struct unixctl_command {
+ const char *args;
unixctl_cb_func *cb;
void *aux;
};
void *aux OVS_UNUSED)
{
struct ds ds = DS_EMPTY_INITIALIZER;
- struct shash_node *node;
- struct svec names;
- const char *name;
+ const struct shash_node **nodes = shash_sort(&commands);
size_t i;
ds_put_cstr(&ds, "The available commands are:\n");
- svec_init(&names);
- SHASH_FOR_EACH (node, &commands) {
- svec_add(&names, node->name);
+ for (i = 0; i < shash_count(&commands); i++) {
+ const struct shash_node *node = nodes[i];
+ const struct unixctl_command *command = node->data;
+
+ ds_put_format(&ds, " %-23s%s\n", node->name, command->args);
}
- svec_sort(&names);
-
- SVEC_FOR_EACH (i, name, &names) {
- ds_put_format(&ds, "\t%s\n", name);
- }
- svec_destroy(&names);
+ free(nodes);
unixctl_command_reply(conn, 214, ds_cstr(&ds));
ds_destroy(&ds);
}
void
-unixctl_command_register(const char *name, unixctl_cb_func *cb, void *aux)
+unixctl_command_register(const char *name, const char *args,
+ unixctl_cb_func *cb, void *aux)
{
struct unixctl_command *command;
assert(!shash_find_data(&commands, name)
|| shash_find_data(&commands, name) == cb);
command = xmalloc(sizeof *command);
+ command->args = args;
command->cb = cb;
command->aux = aux;
shash_add(&commands, name, command);
return 0;
}
- unixctl_command_register("help", unixctl_help, NULL);
- unixctl_command_register("version", unixctl_version, NULL);
+ unixctl_command_register("help", "", unixctl_help, NULL);
+ unixctl_command_register("version", "", unixctl_version, NULL);
server = xmalloc(sizeof *server);
list_init(&server->conns);
struct unixctl_conn;
typedef void unixctl_cb_func(struct unixctl_conn *,
const char *args, void *aux);
-void unixctl_command_register(const char *name,
+void unixctl_command_register(const char *name, const char *args,
unixctl_cb_func *cb, void *aux);
void unixctl_command_reply(struct unixctl_conn *, int code,
const char *body);
VLOG_ERR("current time is negative: %s (%ld)", s, (long int) now);
}
- 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);
+ unixctl_command_register("vlog/set",
+ "{module[:facility[:level]] | PATTERN:facility:pattern}",
+ 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. */
}
registered = true;
- unixctl_command_register("ofproto/trace", ofproto_unixctl_trace, NULL);
- unixctl_command_register("fdb/show", ofproto_unixctl_fdb_show, NULL);
-
- unixctl_command_register("ofproto/clog", ofproto_dpif_clog, NULL);
- unixctl_command_register("ofproto/unclog", ofproto_dpif_unclog, NULL);
+ unixctl_command_register("ofproto/trace",
+ "bridge {tun_id in_port packet | odp_flow [-generate]}",
+ ofproto_unixctl_trace, NULL);
+ unixctl_command_register("fdb/show", "bridge", ofproto_unixctl_fdb_show,
+ NULL);
+ unixctl_command_register("ofproto/clog", "", ofproto_dpif_clog, NULL);
+ unixctl_command_register("ofproto/unclog", "", ofproto_dpif_unclog, NULL);
}
\f
const struct ofproto_class ofproto_dpif_class = {
}
registered = true;
- unixctl_command_register("ofproto/list", ofproto_unixctl_list, NULL);
+ unixctl_command_register("ofproto/list", "", ofproto_unixctl_list, NULL);
}
daemonize_complete();
- unixctl_command_register("exit", ovsdb_server_exit, &exiting);
- unixctl_command_register("ovsdb-server/compact", ovsdb_server_compact,
- file);
- unixctl_command_register("ovsdb-server/reconnect", ovsdb_server_reconnect,
- jsonrpc);
+ unixctl_command_register("exit", "", ovsdb_server_exit, &exiting);
+ unixctl_command_register("ovsdb-server/compact", "",
+ ovsdb_server_compact, file);
+ unixctl_command_register("ovsdb-server/reconnect", "",
+ ovsdb_server_reconnect, jsonrpc);
exiting = false;
while (!exiting) {
exit(EXIT_FAILURE);
}
- unixctl_command_register("exit", test_openflowd_exit, &exiting);
+ unixctl_command_register("exit", "", test_openflowd_exit, &exiting);
VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
ovsdb_idl_omit(idl, &ovsrec_ssl_col_external_ids);
/* Register unixctl commands. */
- unixctl_command_register("qos/show", qos_unixctl_show, NULL);
- unixctl_command_register("bridge/dump-flows", bridge_unixctl_dump_flows,
- NULL);
- unixctl_command_register("bridge/reconnect", bridge_unixctl_reconnect,
- NULL);
+ unixctl_command_register("qos/show", "interface", qos_unixctl_show, NULL);
+ unixctl_command_register("bridge/dump-flows", "bridge",
+ bridge_unixctl_dump_flows, NULL);
+ unixctl_command_register("bridge/reconnect", "[bridge]",
+ bridge_unixctl_reconnect, NULL);
lacp_init();
bond_init();
cfm_init();
if (retval) {
exit(EXIT_FAILURE);
}
- unixctl_command_register("exit", ovs_vswitchd_exit, &exiting);
+ unixctl_command_register("exit", "", ovs_vswitchd_exit, &exiting);
bridge_init(remote);
free(remote);