diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-02 20:31:51 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-11-02 20:31:51 +0000 |
commit | ed31761bb62c868fc5ed347842ab1a928609ce9c (patch) | |
tree | 6d411297920f6e9d0636e9e5209c0855ea24d0fa /usr.sbin/dvmrpd | |
parent | 0b0b1baf26e53c033ac0be651cf6100e3ed7b97a (diff) |
Yet another implementation of IMSG_CTL_LOG_VERBOSE. Similar to the one in
ripd, ospfd and friends. OK michele, henning, sthen
Diffstat (limited to 'usr.sbin/dvmrpd')
-rw-r--r-- | usr.sbin/dvmrpd/control.c | 17 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpd.c | 9 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/log.c | 12 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/log.h | 3 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/rde.c | 9 |
6 files changed, 45 insertions, 8 deletions
diff --git a/usr.sbin/dvmrpd/control.c b/usr.sbin/dvmrpd/control.c index a99e46be4b4..27c04a7040a 100644 --- a/usr.sbin/dvmrpd/control.c +++ b/usr.sbin/dvmrpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.8 2009/06/06 07:52:04 pyr Exp $ */ +/* $OpenBSD: control.c,v 1.9 2009/11/02 20:31:50 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -193,6 +193,7 @@ control_dispatch_imsg(int fd, short event, void *bula) struct imsg imsg; int n; unsigned int ifidx; + int verbose; if ((c = control_connbyfd(fd)) == NULL) { log_warn("control_dispatch_imsg: fd %d: not found", fd); @@ -255,6 +256,20 @@ control_dispatch_imsg(int fd, short event, void *bula) dvmrpe_imsg_compose_rde(imsg.hdr.type, 0, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; + case IMSG_CTL_LOG_VERBOSE: + if (imsg.hdr.len != IMSG_HEADER_SIZE + + sizeof(verbose)) + break; + + /* forward to other porcesses */ + dvmrpe_imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, + imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); + dvmrpe_imsg_compose_rde(imsg.hdr.type, 0, imsg.hdr.pid, + imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); + + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("control_dispatch_imsg: " "error handling imsg %d", imsg.hdr.type); diff --git a/usr.sbin/dvmrpd/dvmrpd.c b/usr.sbin/dvmrpd/dvmrpd.c index 901f0e6462b..99812975535 100644 --- a/usr.sbin/dvmrpd/dvmrpd.c +++ b/usr.sbin/dvmrpd/dvmrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.c,v 1.10 2009/06/06 07:52:04 pyr Exp $ */ +/* $OpenBSD: dvmrpd.c,v 1.11 2009/11/02 20:31:50 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -145,6 +145,7 @@ main(int argc, char *argv[]) if (opts & DVMRPD_OPT_VERBOSE) opts |= DVMRPD_OPT_VERBOSE2; opts |= DVMRPD_OPT_VERBOSE; + log_verbose(1); break; default: usage(); @@ -354,6 +355,7 @@ main_dispatch_dvmrpe(int fd, short event, void *bula) struct imsgbuf *ibuf = &iev->ibuf; struct imsg imsg; ssize_t n; + int verbose; if (event & EV_READ) { if ((n = imsg_read(ibuf)) == -1) @@ -384,6 +386,11 @@ main_dispatch_dvmrpe(int fd, short event, void *bula) case IMSG_CTL_MFC_DECOUPLE: kmr_mfc_decouple(); break; + case IMSG_CTL_LOG_VERBOSE: + /* already checked by dvmrpe */ + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("main_dispatch_dvmrpe: error handling " "imsg %d", imsg.hdr.type); diff --git a/usr.sbin/dvmrpd/dvmrpd.h b/usr.sbin/dvmrpd/dvmrpd.h index 5f99058f5c0..c326eafaff5 100644 --- a/usr.sbin/dvmrpd/dvmrpd.h +++ b/usr.sbin/dvmrpd/dvmrpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.h,v 1.19 2009/06/06 18:31:42 pyr Exp $ */ +/* $OpenBSD: dvmrpd.h,v 1.20 2009/11/02 20:31:50 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -75,6 +75,7 @@ enum imsg_type { IMSG_CTL_IFINFO, IMSG_CTL_SHOW_SUM, IMSG_CTL_END, + IMSG_CTL_LOG_VERBOSE, IMSG_IFINFO, IMSG_ROUTE_REPORT, IMSG_FULL_ROUTE_REPORT, diff --git a/usr.sbin/dvmrpd/log.c b/usr.sbin/dvmrpd/log.c index f10d9e044c9..5dff3890030 100644 --- a/usr.sbin/dvmrpd/log.c +++ b/usr.sbin/dvmrpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.1 2006/06/01 14:12:20 norby Exp $ */ +/* $OpenBSD: log.c,v 1.2 2009/11/02 20:31:50 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -35,6 +35,7 @@ static const char * const procnames[] = { }; int debug; +int verbose; void logit(int, const char *, ...); @@ -44,6 +45,7 @@ log_init(int n_debug) extern char *__progname; debug = n_debug; + verbose = n_debug; if (!debug) openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON); @@ -52,6 +54,12 @@ log_init(int n_debug) } void +log_verbose(int v) +{ + verbose = v; +} + +void logit(int pri, const char *fmt, ...) { va_list ap; @@ -129,7 +137,7 @@ log_debug(const char *emsg, ...) { va_list ap; - if (debug) { + if (verbose) { va_start(ap, emsg); vlog(LOG_DEBUG, emsg, ap); va_end(ap); diff --git a/usr.sbin/dvmrpd/log.h b/usr.sbin/dvmrpd/log.h index 9fbc18e29b6..33e4dbf60d8 100644 --- a/usr.sbin/dvmrpd/log.h +++ b/usr.sbin/dvmrpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.1 2006/06/01 14:12:20 norby Exp $ */ +/* $OpenBSD: log.h,v 1.2 2009/11/02 20:31:50 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -22,6 +22,7 @@ #include <stdarg.h> void log_init(int); +void log_verbose(int); void vlog(int, const char *, va_list); void log_warn(const char *, ...); void log_warnx(const char *, ...); diff --git a/usr.sbin/dvmrpd/rde.c b/usr.sbin/dvmrpd/rde.c index 301bb443410..6701cf557f6 100644 --- a/usr.sbin/dvmrpd/rde.c +++ b/usr.sbin/dvmrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.21 2009/09/06 09:52:14 michele Exp $ */ +/* $OpenBSD: rde.c,v 1.22 2009/11/02 20:31:50 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -198,7 +198,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) struct imsg imsg; struct route_report rr; struct nbr_msg nm; - int i, connected = 0; + int i, connected = 0, verbose; ssize_t n; struct iface *iface; @@ -313,6 +313,11 @@ rde_dispatch_imsg(int fd, short event, void *bula) mfc_recv_prune(&p); break; + case IMSG_CTL_LOG_VERBOSE: + /* already checked by dvmrpe */ + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("rde_dispatch_msg: unexpected imsg %d", imsg.hdr.type); |