diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2001-10-05 08:18:38 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2001-10-05 08:18:38 +0000 |
commit | e295e5839812a0c428df0c35c0e63ce2cdf753c2 (patch) | |
tree | bd94b254d2a30d3d6b8e98dbf96b80230adb2287 /sbin/isakmpd | |
parent | a15db65009f5aaad718205fb07878e79e6534bd9 (diff) |
Extend the FIFO ui with the 'D A <level>' (to set all debug levels) and
'D T' (to toggle all logging on and off) commands. niklas@ ok.
Diffstat (limited to 'sbin/isakmpd')
-rw-r--r-- | sbin/isakmpd/log.c | 21 | ||||
-rw-r--r-- | sbin/isakmpd/log.h | 3 | ||||
-rw-r--r-- | sbin/isakmpd/ui.c | 30 |
3 files changed, 48 insertions, 6 deletions
diff --git a/sbin/isakmpd/log.c b/sbin/isakmpd/log.c index badacb1b7e8..9c6ada9dc3b 100644 --- a/sbin/isakmpd/log.c +++ b/sbin/isakmpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.23 2001/10/02 18:04:35 deraadt Exp $ */ +/* $OpenBSD: log.c,v 1.24 2001/10/05 08:18:37 ho Exp $ */ /* $EOM: log.c,v 1.30 2000/09/29 08:19:23 niklas Exp $ */ /* @@ -291,6 +291,25 @@ log_debug_cmd (int cls, int level) log_level[cls] = level; } } + +void +log_debug_toggle (void) +{ + static int log_level_copy[LOG_ENDCLASS], toggle = 0; + + if (!toggle) + { + LOG_DBG ((LOG_MISC, 50, "log_debug_toggle: debug levels cleared")); + memcpy (&log_level_copy, &log_level, sizeof log_level); + memset (&log_level, 0, sizeof log_level); + } + else + { + memcpy (&log_level, &log_level_copy, sizeof log_level); + LOG_DBG ((LOG_MISC, 50, "log_debug_toggle: debug levels restored")); + } + toggle = !toggle; +} #endif /* USE_DEBUG */ void diff --git a/sbin/isakmpd/log.h b/sbin/isakmpd/log.h index cdfbdcacb1c..91bcf68ffb0 100644 --- a/sbin/isakmpd/log.h +++ b/sbin/isakmpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.10 2001/04/09 21:21:57 ho Exp $ */ +/* $OpenBSD: log.h,v 1.11 2001/10/05 08:18:37 ho Exp $ */ /* $EOM: log.h,v 1.19 2000/03/30 14:27:23 ho Exp $ */ /* @@ -71,6 +71,7 @@ enum log_classes { extern void log_debug (int, int, const char *, ...); extern void log_debug_buf (int, int, const char *, const u_int8_t *, size_t); extern void log_debug_cmd (int, int); +extern void log_debug_toggle (void); #define PCAP_FILE_DEFAULT "/var/run/isakmpd.pcap" extern void log_packet_init (char *); diff --git a/sbin/isakmpd/ui.c b/sbin/isakmpd/ui.c index 3b3ae1e99a7..73656fee5cc 100644 --- a/sbin/isakmpd/ui.c +++ b/sbin/isakmpd/ui.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui.c,v 1.21 2001/08/24 13:53:02 ho Exp $ */ +/* $OpenBSD: ui.c,v 1.22 2001/10/05 08:18:37 ho Exp $ */ /* $EOM: ui.c,v 1.43 2000/10/05 09:25:12 niklas Exp $ */ /* @@ -224,13 +224,35 @@ static void ui_debug (char *cmd) { int cls, level; + char subcmd[3]; - if (sscanf (cmd, "D %d %d", &cls, &level) != 2) + if (sscanf (cmd, "D %d %d", &cls, &level) == 2) { - log_print ("ui_debug: command \"%s\" malformed", cmd); + log_debug_cmd (cls, level); return; } - log_debug_cmd (cls, level); + else if (sscanf (cmd, "D %2s %d", subcmd, &level) == 2) + { + switch (subcmd[0]) + { + case 'A': + for (cls = 0; cls < LOG_ENDCLASS; cls++) + log_debug_cmd (cls, level); + return; + } + } + else if (sscanf (cmd, "D %2s", subcmd) == 1) + { + switch (subcmd[0]) + { + case 'T': + log_debug_toggle (); + return; + } + } + + log_print ("ui_debug: command \"%s\" malformed", cmd); + return; } static void |