--- ipfw.c.orig Sun Dec 23 19:22:49 2001 +++ ipfw.c Sat Sep 1 01:11:40 2001 @@ -62,6 +62,7 @@ do_resolv, /* Would try to resolve all */ do_acct, /* Show packet/byte count */ do_time, /* Show time stamps */ + do_log, /* Show highest log pkt */ do_quiet, /* Be quiet in add and flush */ do_force, /* Don't ask for confirmation */ do_pipe, /* this cmd refers to a pipe */ @@ -179,7 +180,7 @@ } static void -show_ipfw(struct ip_fw *chain, int pcwidth, int bcwidth) +show_ipfw(struct ip_fw *chain, int pcwidth, int bcwidth, int lgwidth) { char *comma; u_long adrt; @@ -197,6 +198,9 @@ if (do_acct) printf("%*qu %*qu ",pcwidth,chain->fw_pcnt,bcwidth,chain->fw_bcnt); + if (do_log) + printf("%*qu ",lgwidth,chain->fw_loghighest); + if (do_time) { if (chain->timestamp) @@ -603,6 +607,7 @@ void *data = NULL; int pcwidth = 0; int bcwidth = 0; + int lgwidth = 0; int n, num = 0; int nbytes; @@ -694,7 +699,7 @@ num++ ; num++ ; /* counting starts from 0 ... */ /* if showing stats, figure out column widths ahead of time */ - if (do_acct) { + if (do_acct||do_log) { for (n = 0; n < num; n++) { struct ip_fw *const r = &rules[n]; char temp[32]; @@ -709,6 +714,12 @@ width = sprintf(temp, "%qu", r->fw_bcnt); if (width > bcwidth) bcwidth = width; + + /* log counter */ + width = sprintf(temp, "%qu", r->fw_loghighest); + if (width > lgwidth) + lgwidth = width; + } } if (ac == 0) { @@ -716,7 +727,7 @@ for (n = 0; n < num; n++) { struct ip_fw *const r = &rules[n]; - show_ipfw(r, pcwidth, bcwidth); + show_ipfw(r, pcwidth, bcwidth, lgwidth); } } else { /* display specific rules requested on command line */ @@ -740,7 +751,7 @@ if (r->fw_number > rnum) break; if (r->fw_number == rnum) { - show_ipfw(r, pcwidth, bcwidth); + show_ipfw(r, pcwidth, bcwidth, lgwidth); seen = 1; } } @@ -1970,7 +1981,7 @@ if (getsockopt(s, IPPROTO_IP, IP_FW_ADD, &rule, &i) == -1) err(EX_UNAVAILABLE, "getsockopt(%s)", "IP_FW_ADD"); if (!do_quiet) - show_ipfw(&rule, 10, 10); + show_ipfw(&rule, 10, 10, 10); } static void @@ -2064,20 +2075,23 @@ } /* Initialize globals. */ - do_resolv = do_acct = do_time = do_quiet = + do_resolv = do_acct = do_time = do_quiet = do_log = do_pipe = do_sort = verbose = 0; /* Set the force flag for non-interactive processes */ do_force = !isatty(STDIN_FILENO); optind = optreset = 1; - while ((ch = getopt(ac, av, "s:afqtvN")) != -1) + while ((ch = getopt(ac, av, "s:aflqtvN")) != -1) switch(ch) { case 's': /* sort */ do_sort= atoi(optarg); break; case 'a': do_acct=1; + break; + case 'l': + do_log=1; break; case 'f': do_force=1;