summaryrefslogtreecommitdiffstats
path: root/usr.sbin/relayd/log.c
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2007-02-07 15:17:46 +0000
committerreyk <reyk@openbsd.org>2007-02-07 15:17:46 +0000
commit609cf3a7b269e88f4de6e5ec06e33e968197e4ca (patch)
tree29a95ba0dbe4bb80df3e7345c16fabf1e7a8717e /usr.sbin/relayd/log.c
parentinclude the host name in log_debug() messages used by check_tcp read (diff)
downloadwireguard-openbsd-609cf3a7b269e88f4de6e5ec06e33e968197e4ca.tar.xz
wireguard-openbsd-609cf3a7b269e88f4de6e5ec06e33e968197e4ca.zip
add new "log (updates|all)" configuration option to log state
notifications after completed host checks. either only log the "updates" to new states or log "all" state notifications, even if the state didn't change. the log messages will be reported to syslog or to stderr if the daemon is running in foreground mode. ok claudio@ pyr@
Diffstat (limited to 'usr.sbin/relayd/log.c')
-rw-r--r--usr.sbin/relayd/log.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/usr.sbin/relayd/log.c b/usr.sbin/relayd/log.c
index 990f0fcde62..4fc3f35fb8c 100644
--- a/usr.sbin/relayd/log.c
+++ b/usr.sbin/relayd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.2 2006/12/16 17:48:27 deraadt Exp $ */
+/* $OpenBSD: log.c,v 1.3 2007/02/07 15:17:46 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -16,25 +16,31 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/socket.h>
+
+#include <netinet/in_systm.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <net/if.h>
+
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
+#include <event.h>
+
+#include <openssl/ssl.h>
-/* prototypes */
-void log_init(int);
-void vlog(int, const char *, va_list);
-void log_warn(const char *, ...);
-void log_warnx(const char *, ...);
-void log_info(const char *, ...);
-void log_debug(const char *, ...);
-void fatal(const char *);
-void fatalx(const char *);
+#include "hoststated.h"
int debug;
+void vlog(int, const char *, va_list);
void logit(int, const char *, ...);
void
@@ -157,3 +163,39 @@ fatalx(const char *emsg)
errno = 0;
fatal(emsg);
}
+
+const char *
+host_status(enum host_status status)
+{
+ switch (status) {
+ case HOST_DOWN:
+ return ("down");
+ case HOST_UNKNOWN:
+ return ("unknown");
+ case HOST_UP:
+ return ("up");
+ };
+ /* NOTREACHED */
+ return ("invalid");
+}
+
+const char *
+table_check(enum table_check check)
+{
+ switch (check) {
+ case CHECK_NOCHECK:
+ return ("none");
+ case CHECK_ICMP:
+ return ("icmp");
+ case CHECK_TCP:
+ return ("tcp");
+ case CHECK_HTTP_CODE:
+ return ("http code");
+ case CHECK_HTTP_DIGEST:
+ return ("http digest");
+ case CHECK_SEND_EXPECT:
+ return ("send expect");
+ };
+ /* NOTREACHED */
+ return ("invalid");
+}