ipfw2 timestamp patch
Jacob S. Barrett
jbarrett at amduat.net
Mon Jun 16 06:55:26 PDT 2003
I have a need for the raw timestamp and have written a patch against
ipfw2.c to have it return it. It adds an option 'T' which will display
the time stamp value without converting it via ctime. I use this for
scripting ipfw output where I need the timestamp. It was just becoming
a hassle to covert the string back into a usable value. So I just
modified ipfw2.c (I suppose the same can be done with ipfw.c) to not
convert it.
Anyway, I was hoping maybe this patch could find it's way into the ipfw
sources so I don't have to patch it all the time. I think it is pretty
useful. This patch was taken against RELENG_4_8.
--- ipfw2.c.orig Mon Jun 16 06:21:26 2003
+++ ipfw2.c Mon Jun 16 06:25:14 2003
@@ -58,6 +58,7 @@
do_resolv, /* Would try to resolve all */
do_acct, /* Show packet/byte count */
do_time, /* Show time stamps */
+ do_timestamp, /* Show time stamps in seconds*/
do_quiet, /* Be quiet in add and flush */
do_force, /* Don't ask for confirmation */
do_pipe, /* this cmd refers to a pipe */
@@ -824,6 +825,9 @@
if (do_acct)
printf("%10qu %10qu ", rule->pcnt, rule->bcnt);
+ if (do_timestamp)
+ printf("%10lu ", rule->timestamp);
+
if (do_time) {
char timestr[30];
@@ -3344,7 +3348,7 @@
do_force = !isatty(STDIN_FILENO);
optind = optreset = 1;
- while ((ch = getopt(ac, av, "hs:acdefNqStv")) != -1)
+ while ((ch = getopt(ac, av, "hs:acdefNqStTv")) != -1)
switch (ch) {
case 'h': /* help */
help();
@@ -3379,6 +3383,9 @@
break;
case 't':
do_time = 1;
+ break;
+ case 'T':
+ do_timestamp = 1;
break;
case 'v': /* verbose */
verbose++;
--
Jacob S. Barrett
jbarrett at amduat.net
www.amduat.net
"I don't suffer from insanity, I enjoy every minute of it."
More information about the freebsd-ipfw
mailing list