OPT_PEER_CA_CERT
};
static struct option long_options[] = {
- {"detach", no_argument, 0, 'D'},
- {"pidfile", optional_argument, 0, 'P'},
- {"force", no_argument, 0, 'f'},
{"hub", no_argument, 0, 'H'},
{"noflow", no_argument, 0, 'n'},
{"max-idle", required_argument, 0, OPT_MAX_IDLE},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
+ DAEMON_LONG_OPTIONS,
#ifdef HAVE_OPENSSL
VCONN_SSL_LONG_OPTIONS
{"peer-ca-cert", required_argument, 0, OPT_PEER_CA_CERT},
}
switch (c) {
- case 'D':
- set_detach();
- break;
-
- case 'P':
- set_pidfile(optarg);
- break;
-
- case 'f':
- ignore_existing_pidfile();
- break;
-
case 'H':
learn_macs = false;
break;
vlog_set_verbosity(optarg);
break;
+ DAEMON_OPTION_HANDLERS
+
#ifdef HAVE_OPENSSL
VCONN_SSL_OPTION_HANDLERS
"where METHOD is any OpenFlow connection method.\n",
program_name, program_name);
vconn_usage(true, true, false);
+ daemon_usage();
printf("\nOther options:\n"
- " -D, --detach run in background as daemon\n"
- " -P, --pidfile[=FILE] create pidfile (default: %s/controller.pid)\n"
- " -f, --force with -P, start even if already running\n"
" -H, --hub act as hub instead of learning switch\n"
" -n, --noflow pass traffic, but don't add flows\n"
" --max-idle=SECS max idle time for new flows\n"
" -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n"
" -v, --verbose set maximum verbosity level\n"
" -h, --help display this help message\n"
- " -V, --version display version information\n",
- RUNDIR);
+ " -V, --version display version information\n");
exit(EXIT_SUCCESS);
}
#include <stdbool.h>
+#define DAEMON_LONG_OPTIONS \
+ {"detach", no_argument, 0, 'D'}, \
+ {"force", no_argument, 0, 'f'}, \
+ {"pidfile", optional_argument, 0, 'P'}
+
+#define DAEMON_OPTION_HANDLERS \
+ case 'D': \
+ set_detach(); \
+ break; \
+ \
+ case 'P': \
+ set_pidfile(optarg); \
+ break; \
+ \
+ case 'f': \
+ ignore_existing_pidfile(); \
+ break;
+
char *make_pidfile_name(const char *name);
void set_pidfile(const char *name);
const char *get_pidfile(void);
void daemonize(void);
void die_if_already_running(void);
void ignore_existing_pidfile(void);
+void daemon_usage(void);
#endif /* daemon.h */
}
}
+void
+daemon_usage(void)
+{
+ printf(
+ "\nDaemon options:\n"
+ " -D, --detach run in background as daemon\n"
+ " -P, --pidfile[=FILE] create pidfile (default: %s/%s.pid)\n"
+ " -f, --force with -P, start even if already running\n",
+ RUNDIR, program_name);
+}
{"no-stp", no_argument, 0, OPT_NO_STP},
{"out-of-band", no_argument, 0, OPT_OUT_OF_BAND},
{"in-band", no_argument, 0, OPT_IN_BAND},
- {"detach", no_argument, 0, 'D'},
- {"force", no_argument, 0, 'f'},
- {"pidfile", optional_argument, 0, 'P'},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
+ DAEMON_LONG_OPTIONS,
#ifdef HAVE_OPENSSL
VCONN_SSL_LONG_OPTIONS
{"bootstrap-ca-cert", required_argument, 0, OPT_BOOTSTRAP_CA_CERT},
s->in_band = true;
break;
- case 'D':
- set_detach();
- break;
-
- case 'P':
- set_pidfile(optarg);
- break;
-
- case 'f':
- ignore_existing_pidfile();
- break;
-
case 'l':
if (s->n_listeners >= MAX_MGMT) {
ofp_fatal(0,
vlog_set_verbosity(optarg);
break;
+ DAEMON_OPTION_HANDLERS
+
#ifdef HAVE_OPENSSL
VCONN_SSL_OPTION_HANDLERS
" --no-stp disable 802.1D Spanning Tree Protocol\n"
"\nRate-limiting of \"packet-in\" messages to the controller:\n"
" --rate-limit[=PACKETS] max rate, in packets/s (default: 1000)\n"
- " --burst-limit=BURST limit on packet credit for idle time\n"
- "\nOther options:\n"
- " -D, --detach run in background as daemon\n"
- " -P, --pidfile[=FILE] create pidfile (default: %s/secchan.pid)\n"
- " -f, --force with -P, start even if already running\n"
+ " --burst-limit=BURST limit on packet credit for idle time\n");
+ daemon_usage();
+ printf("\nOther options:\n"
" -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n"
" -v, --verbose set maximum verbosity level\n"
" -h, --help display this help message\n"
- " -V, --version display version information\n",
- RUNDIR);
+ " -V, --version display version information\n");
exit(EXIT_SUCCESS);
}
{"datapath-id", required_argument, 0, 'd'},
{"max-backoff", required_argument, 0, OPT_MAX_BACKOFF},
{"listen", required_argument, 0, 'l'},
- {"detach", no_argument, 0, 'D'},
- {"pidfile", optional_argument, 0, 'P'},
- {"force", no_argument, 0, 'f'},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"hw-desc", required_argument, 0, OPT_HW_DESC},
{"sw-desc", required_argument, 0, OPT_SW_DESC},
{"serial_num", required_argument, 0, OPT_SERIAL_NUM},
+ DAEMON_LONG_OPTIONS,
#ifdef HAVE_OPENSSL
VCONN_SSL_LONG_OPTIONS
{"bootstrap-ca-cert", required_argument, 0, OPT_BOOTSTRAP_CA_CERT},
printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]);
exit(EXIT_SUCCESS);
- case 'D':
- set_detach();
- break;
-
- case 'P':
- set_pidfile(optarg);
- break;
-
- case 'f':
- ignore_existing_pidfile();
- break;
-
case 'v':
vlog_set_verbosity(optarg);
break;
listen_pvconn_name = optarg;
break;
+ DAEMON_OPTION_HANDLERS
+
#ifdef HAVE_OPENSSL
VCONN_SSL_OPTION_HANDLERS
" --max-backoff=SECS max time between controller connection\n"
" attempts (default: 15 seconds)\n"
" -l, --listen=METHOD allow management connections on METHOD\n"
- " (a passive OpenFlow connection method)\n"
- "\nOther options:\n"
- " -D, --detach run in background as daemon\n"
- " -P, --pidfile[=FILE] create pidfile (default: %s/switch.pid)\n"
- " -f, --force with -P, start even if already running\n"
+ " (a passive OpenFlow connection method)\n");
+ daemon_usage();
+ printf("\nOther options:\n"
" -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n"
" -v, --verbose set maximum verbosity level\n"
" -h, --help display this help message\n"
- " -V, --version display version information\n",
- RUNDIR);
+ " -V, --version display version information\n");
exit(EXIT_SUCCESS);
}