static void parse_options(int argc, char *argv[]);
static void usage(void) NO_RETURN;
-static struct vconn *listen_vconn = NULL;
+static const char *listen_vconn_name;
struct half {
struct rconn *rconn;
int
main(int argc, char *argv[])
{
+ struct vconn *listen_vconn;
const char *nl_name;
int retval;
fatal(0, "%s: argument is not of the form \"nl:DP_ID\"", nl_name);
}
+ if (listen_vconn_name) {
+ retval = vconn_open(listen_vconn_name, &listen_vconn);
+ if (retval && retval != EAGAIN) {
+ fatal(retval, "opening %s", listen_vconn_name);
+ }
+ if (!vconn_is_passive(listen_vconn)) {
+ fatal(0, "%s is not a passive vconn", listen_vconn_name);
+ }
+ } else {
+ listen_vconn = NULL;
+ }
+
retval = vlog_server_listen(NULL, NULL);
if (retval) {
fatal(retval, "Could not listen for vlog connections");
relay_run(r);
}
if (listen_vconn) {
- struct vconn *new_remote;
for (;;) {
+ struct vconn *new_remote;
retval = vconn_accept(listen_vconn, &new_remote);
if (retval) {
if (retval != EAGAIN) {
}
break;
}
-
new_management_connection(nl_name, new_remote);
}
}
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
-#ifdef HAVE_OPENSSL
- {"private-key", required_argument, 0, 'p'},
- {"certificate", required_argument, 0, 'c'},
- {"ca-cert", required_argument, 0, 'C'},
-#endif
+ VCONN_SSL_LONG_OPTIONS
{0, 0, 0, 0},
};
char *short_options = long_options_to_short_options(long_options);
for (;;) {
- int retval;
int c;
c = getopt_long(argc, argv, short_options, long_options, NULL);
switch (c) {
case 'l':
- if (listen_vconn) {
+ if (listen_vconn_name) {
fatal(0, "-l or --listen may be only specified once");
}
- retval = vconn_open(optarg, &listen_vconn);
- if (retval && retval != EAGAIN) {
- fatal(retval, "opening %s", optarg);
- }
- if (!vconn_is_passive(listen_vconn)) {
- fatal(0, "%s is not a passive vconn", optarg);
- }
+ listen_vconn_name = optarg;
break;
case 'h':
vlog_set_verbosity(optarg);
break;
-#ifdef HAVE_OPENSSL
- case 'p':
- vconn_ssl_set_private_key_file(optarg);
- break;
-
- case 'c':
- vconn_ssl_set_certificate_file(optarg);
- break;
-
- case 'C':
- vconn_ssl_set_ca_cert_file(optarg);
- break;
-#endif
+ VCONN_SSL_OPTION_HANDLERS
case '?':
exit(EXIT_FAILURE);
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");