From: Ben Pfaff Date: Thu, 3 Apr 2008 19:52:19 +0000 (-0700) Subject: Factor out printing the list of available vconns. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a14c841f32358e665b19b419c91c1f711e4b0431;p=openvswitch Factor out printing the list of available vconns. --- diff --git a/controller/controller.c b/controller/controller.c index 9355c02b..770ee6a6 100644 --- a/controller/controller.c +++ b/controller/controller.c @@ -630,21 +630,10 @@ static void usage(void) { printf("%s: OpenFlow controller\n" - "usage: %s [OPTIONS] VCONN\n" - "where VCONN is one of the following:\n" - " ptcp:[PORT] listen to TCP PORT (default: %d)\n", - program_name, program_name, OFP_TCP_PORT); -#ifdef HAVE_NETLINK - printf(" nl:DP_IDX via netlink to local datapath DP_IDX\n"); -#endif -#ifdef HAVE_OPENSSL - printf(" pssl:[PORT] listen for SSL on PORT (default: %d)\n" - "\nPKI configuration (required to use SSL):\n" - " -p, --private-key=FILE file with private key\n" - " -c, --certificate=FILE file with certificate for private key\n" - " -C, --ca-cert=FILE file with peer CA certificate\n", - OFP_SSL_PORT); -#endif + "usage: %s [OPTIONS] METHOD\n" + "where METHOD is any OpenFlow connection method.\n", + program_name, program_name); + vconn_usage(true, true); printf("\nOther options:\n" " -H, --hub act as hub instead of learning switch\n" " -n, --noflow pass traffic, but don't add flows\n" diff --git a/include/vconn.h b/include/vconn.h index b5fddbd3..46c43e56 100644 --- a/include/vconn.h +++ b/include/vconn.h @@ -49,6 +49,7 @@ struct vconn { int connect_status; }; +void vconn_usage(bool active, bool passive); int vconn_open(const char *name, struct vconn **); void vconn_close(struct vconn *); bool vconn_is_passive(const struct vconn *); diff --git a/lib/vconn.c b/lib/vconn.c index 84c3bbc6..e2511432 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -80,6 +80,50 @@ check_vconn_classes(void) #endif } +/* Prints information on active (if 'active') and passive (if 'passive') + * connection methods supported by the vconn. */ +void +vconn_usage(bool active, bool passive) +{ + /* Really this should be implemented via callbacks into the vconn + * providers, but that seems too heavy-weight to bother with at the + * moment. */ + + printf("\n"); + if (active) { + printf("Active OpenFlow connection methods:\n"); +#ifdef HAVE_NETLINK + printf(" nl:DP_IDX " + "local datapath DP_IDX\n"); +#endif + printf(" tcp:HOST[:PORT] " + "PORT (default: %d) on remote TCP HOST\n", OFP_TCP_PORT); +#ifdef HAVE_OPENSSL + printf(" ssl:HOST[:PORT] " + "SSL PORT (default: %d) on remote HOST\n", OFP_SSL_PORT); +#endif + } + + if (passive) { + printf("Passive OpenFlow connection methods:\n"); + printf(" ptcp:[PORT] " + "listen to TCP PORT (default: %d)\n", + OFP_TCP_PORT); +#ifdef HAVE_OPENSSL + printf(" pssl:[PORT] " + "listen for SSL on PORT (default: %d)\n", + OFP_SSL_PORT); +#endif + } + +#ifdef HAVE_OPENSSL + printf("PKI configuration (required to use SSL):\n" + " -p, --private-key=FILE file with private key\n" + " -c, --certificate=FILE file with certificate for private key\n" + " -C, --ca-cert=FILE file with peer CA certificate\n"); +#endif +} + /* Attempts to connect to an OpenFlow device. 'name' is a connection name in * the form "TYPE:ARGS", where TYPE is the vconn class's name and ARGS are * vconn class-specific. diff --git a/secchan/secchan.c b/secchan/secchan.c index 72cbd257..155dfa9e 100644 --- a/secchan/secchan.c +++ b/secchan/secchan.c @@ -337,32 +337,15 @@ parse_options(int argc, char *argv[]) static void usage(void) { - printf("%s: Secure Channel\n" + printf("%s: Secure Channel, a relay for OpenFlow messages.\n" "usage: %s [OPTIONS] LOCAL REMOTE\n" - "\nRelays OpenFlow message between LOCAL and REMOTE datapaths.\n" - "LOCAL and REMOTE must each be one of the following:\n" - " tcp:HOST[:PORT] PORT (default: %d) on remote TCP HOST\n", - program_name, program_name, OFP_TCP_PORT); -#ifdef HAVE_NETLINK - printf(" nl:DP_IDX local datapath DP_IDX\n"); -#endif -#ifdef HAVE_OPENSSL - printf(" ssl:HOST[:PORT] SSL PORT (default: %d) on remote HOST\n" - "\nPKI configuration (required to use SSL):\n" - " -p, --private-key=FILE file with private key\n" - " -c, --certificate=FILE file with certificate for private key\n" - " -C, --ca-cert=FILE file with peer CA certificate\n", - OFP_SSL_PORT); -#endif + "where LOCAL and REMOTE are active OpenFlow connection methods.\n", + program_name, program_name); + vconn_usage(true, true); printf("\nNetworking options:\n" - " -l, --listen=VCONN allow management connections on VCONN:\n" - " ptcp:[PORT] TCP PORT (default: %d)\n", - OFP_TCP_PORT); -#ifdef HAVE_OPENSSL - printf(" pssl:[PORT] SSL PORT (default: %d)\n", - OFP_SSL_PORT); -#endif - printf("\nOther options:\n" + " -l, --listen=METHOD allow management connections on METHOD\n" + " (a passive OpenFlow connection method)\n" + "\nOther options:\n" " -v, --verbose set maximum verbosity level\n" " -h, --help display this help message\n" " -V, --version display version information\n"); diff --git a/switch/switch.c b/switch/switch.c index 313c75f1..d8ccc80c 100644 --- a/switch/switch.c +++ b/switch/switch.c @@ -203,18 +203,10 @@ usage(void) { printf("%s: userspace OpenFlow switch\n" "usage: %s [OPTIONS] CONTROLLER\n" - "CONTROLLER must be one of the following:\n" - " tcp:HOST[:PORT] PORT (default: %d) on remote TCP HOST\n", - program_name, program_name, OFP_TCP_PORT); -#ifdef HAVE_OPENSSL - printf(" ssl:HOST[:PORT] SSL PORT (default: %d) on remote HOST\n" - "\nPKI configuration (required to use SSL):\n" - " -p, --private-key=FILE file with private key\n" - " -c, --certificate=FILE file with certificate for private key\n" - " -C, --ca-cert=FILE file with peer CA certificate\n", - OFP_SSL_PORT); -#endif - printf("Options:\n" + "where CONTROLLER is an active OpenFlow connection method.\n", + program_name, program_name); + vconn_usage(true, false); + printf("\nOptions:\n" " -i, --interfaces=NETDEV[,NETDEV]...\n" " add specified initial switch ports\n" " -d, --datapath-id=ID Use ID as the OpenFlow switch ID\n" diff --git a/utilities/dpctl.c b/utilities/dpctl.c index a9c0d8b6..8f1e7723 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -179,27 +179,16 @@ usage(void) " delif nl:DP_ID IFACE delete IFACE as a port on DP_ID\n" " benchmark-nl nl:DP_ID N SIZE send N packets of SIZE bytes\n" #endif - "\nCommands that also apply to remote switches:\n" - " show VCONN show information about VCONN\n" - " monitor VCONN print packets received on VCONN\n" - " dump-tables VCONN print table stats for VCONN\n" - " dump-flows VCONN T_ID print all flow entries in table T_ID of VCONN\n" - " dump-flows VCONN T_ID FLOW print matching FLOWs in table T_ID of VCONN\n" - " add-flows VCONN FILE add flows from FILE to VCONN\n" - "where each VCONN is one of the following:\n" - " tcp:HOST[:PORT] PORT (default: %d) on remote TCP HOST\n", - program_name, program_name, OFP_TCP_PORT); -#ifdef HAVE_NETLINK - printf(" nl:DP_IDX via netlink to local datapath DP_IDX\n"); -#endif -#ifdef HAVE_OPENSSL - printf(" ssl:HOST[:PORT] SSL PORT (default: %d) on remote HOST\n" - "\nPKI configuration (required to use SSL):\n" - " -p, --private-key=FILE file with private key\n" - " -c, --certificate=FILE file with certificate for private key\n" - " -C, --ca-cert=FILE file with peer CA certificate\n", - OFP_SSL_PORT); -#endif + "\nCommands that apply to local datapaths and remote switches:\n" + " show METHOD show information about METHOD\n" + " monitor METHOD print packets received on METHOD\n" + " dump-tables METHOD print table stats for METHOD\n" + " dump-flows METHOD T_ID print all flow entries in table T_ID of METHOD\n" + " dump-flows METHOD T_ID FLOW print matching FLOWs in table T_ID of METHOD\n" + " add-flows METHOD FILE add flows from FILE to METHOD\n" + "where each METHOD is an active OpenFlow connection method.\n", + program_name, program_name); + vconn_usage(true, false); printf("\nOptions:\n" " -v, --verbose set maximum verbosity level\n" " -h, --help display this help message\n"