Factor out printing the list of available vconns.
authorBen Pfaff <blp@nicira.com>
Thu, 3 Apr 2008 19:52:19 +0000 (12:52 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 4 Apr 2008 23:22:23 +0000 (16:22 -0700)
controller/controller.c
include/vconn.h
lib/vconn.c
secchan/secchan.c
switch/switch.c
utilities/dpctl.c

index 9355c02..770ee6a 100644 (file)
@@ -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"
index b5fddbd..46c43e5 100644 (file)
@@ -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 *);
index 84c3bbc..e251143 100644 (file)
@@ -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.
index 72cbd25..155dfa9 100644 (file)
@@ -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");
index 313c75f..d8ccc80 100644 (file)
@@ -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"
index a9c0d8b..8f1e772 100644 (file)
@@ -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"