-/* $OpenBSD: switchd.c,v 1.3 2016/07/19 17:34:13 reyk Exp $ */
+/* $OpenBSD: switchd.c,v 1.4 2016/07/20 11:43:31 jsg Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
usage(void)
{
extern const char *__progname;
- fprintf(stderr, "usage: %s [-dv] [-D macro=value] [-f file] "
+ fprintf(stderr, "usage: %s [-dnv] [-D macro=value] [-f file] "
"[-c mac-cache-size] [-t cache-timeout]\n",
__progname);
exit(1);
const char *errstr = NULL;
int c;
int debug = 0, verbose = 0;
+ uint32_t opts = 0;
unsigned int cache = SWITCHD_CACHE_MAX;
unsigned int timeout = SWITCHD_CACHE_TIMEOUT;
const char *conffile = SWITCHD_CONFIG;
log_init(1, LOG_DAEMON);
- while ((c = getopt(argc, argv, "c:dD:f:ht:v")) != -1) {
+ while ((c = getopt(argc, argv, "c:dD:f:hnt:v")) != -1) {
switch (c) {
case 'c':
cache = strtonum(optarg, 1, UINT32_MAX, &errstr);
case 'f':
conffile = optarg;
break;
+ case 'n':
+ opts |= SWITCHD_OPT_NOACTION;
+ break;
case 't':
timeout = strtonum(optarg, 0, UINT32_MAX, &errstr);
if (errstr != NULL) {
break;
case 'v':
verbose++;
+ opts |= SWITCHD_OPT_VERBOSE;
break;
default:
usage();
sc->sc_cache_max = cache;
sc->sc_cache_timeout = timeout;
+ sc->sc_opts = opts;
srv = &sc->sc_server;
srv->srv_sc = sc;
exit(1);
}
+ if (opts & SWITCHD_OPT_NOACTION) {
+ fprintf(stderr, "configuration OK\n");
+ proc_kill(&sc->sc_ps);
+ exit(0);
+ }
+
/* check for root privileges */
if (geteuid())
fatalx("need root privileges");
-/* $OpenBSD: switchd.h,v 1.1 2016/07/19 16:54:26 reyk Exp $ */
+/* $OpenBSD: switchd.h,v 1.2 2016/07/20 11:43:31 jsg Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
unsigned int sc_cache_max;
unsigned int sc_cache_timeout;
char sc_conffile[PATH_MAX];
+ uint8_t sc_opts;
TAILQ_HEAD(, switch_device)
sc_conns;
};
struct ibuf *);
};
+#define SWITCHD_OPT_VERBOSE 0x01
+#define SWITCHD_OPT_NOACTION 0x04
+
/* switchd.c */
int switchd_socket(struct sockaddr *, int);
int switchd_listen(struct sockaddr *);