diff options
author | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2005-05-27 21:41:05 +0000 |
---|---|---|
committer | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2005-05-27 21:41:05 +0000 |
commit | 12b4f3ecbccd072a14200bcfeb9c132391e84c44 (patch) | |
tree | 331f65d86407a09e55782f3539ac2cda5b243425 /sbin | |
parent | a94fa507f29b407b8c1ac89197a8be450abe1193 (diff) |
Calculate an MD5 checksum over the main pf ruleset.
This is the basis for further pfsync improvements,
to ensure that pf rules are in sync with the master.
"get it in" mcbride@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/pfctl/pfctl_parser.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 29b991788c4..c74ac1647bf 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.c,v 1.215 2005/05/27 18:52:42 dhartmei Exp $ */ +/* $OpenBSD: pfctl_parser.c,v 1.216 2005/05/27 21:41:04 mpf Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -479,9 +479,11 @@ const char *pf_scounters[FCNT_MAX+1] = FCNT_NAMES; void print_status(struct pf_status *s, int opts) { - char statline[80], *running; - time_t runtime; - int i; + char statline[80], *running; + time_t runtime; + int i; + char buf[MD5_DIGEST_LENGTH * 2 + 1]; + static const char hex[] = "0123456789abcdef"; runtime = time(NULL) - s->since; running = s->running ? "Enabled" : "Disabled"; @@ -515,7 +517,15 @@ print_status(struct pf_status *s, int opts) printf("%15s\n\n", "Debug: Loud"); break; } - printf("Hostid: 0x%08x\n\n", ntohl(s->hostid)); + printf("Hostid: 0x%08x\n", ntohl(s->hostid)); + + for (i = 0; i < MD5_DIGEST_LENGTH; i++) { + buf[i + i] = hex[s->pf_chksum[i] >> 4]; + buf[i + i + 1] = hex[s->pf_chksum[i] & 0x0f]; + } + buf[i + i] = '\0'; + printf("Checksum: 0x%s\n\n", buf); + if (s->ifname[0] != 0) { printf("Interface Stats for %-16s %5s %16s\n", s->ifname, "IPv4", "IPv6"); |