Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Oct 2004 13:04:36 +0200
From:      "Raphael R." <raphaelr@gmail.com>
To:        freebsd-current@freebsd.org
Cc:        bms@spc.org
Subject:   tcpdump -tttt option loses timezone
Message-ID:  <3f030e4204100304043ef4b8f@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
------=_Part_221_16269327.1096801476179
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

The -tttt option doesn't use timezone, the time is always GMT:

# tcpdump -n -tttt
06/13/2004 13:31:35.758527 192.168.2.1 > 192.168.2.254: icmp: echo request
06/13/2004 13:31:35.758684 192.168.2.254 > 192.168.2.1: icmp: echo reply

without time option, I have:
# tcpdump -n
15:31:30.808613 192.168.2.1 > 192.168.2.254: icmp: echo request
15:31:30.808769 192.168.2.254 > 192.168.2.1: icmp: echo reply

The reason is quite simple (based on 3.8.3 source code) in tcpdump.c:

....
int tflag = 1; /* print packet arrival
time */
....

....
case 't':
--tflag;
break;
....

....
if (tflag > 0)
thiszone = gmt2local(0);
....

if -tttt option is enabled gmt2local isn't called and
thiszone is alway equals to 0.

I've provided a patch:

--- tcpdump.c.orig Sun Jun 13 15:50:49 2004
+++ tcpdump.c Sun Jun 13 15:56:42 2004
@@ -615,7 +615,7 @@
/* NOTREACHED */
}

- if (tflag > 0)
+ if ((tflag > 0) || (tflag == -3))
thiszone = gmt2local(0);

if (RFileName != NULL) {


Another solution is to remove the "if (tflag > 0)" test. This bug was
discovered on FreeBSD 5.2.1 (tcpdump 3.7.2 + multidlt) with but apply
to all others platforms. This bug is now fixed on branch tcpdump_3_8
and HEAD on tcpdump CVS.

I hope that it can be fixed before the 5.3-RELEASE.


Raphael Raimbault.

------=_Part_221_16269327.1096801476179
Content-Type: application/octet-stream; name="tcpdump.c.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="tcpdump.c.patch"

LS0tIHRjcGR1bXAuYy5vcmlnCVN1biBKdW4gMTMgMTU6NTA6NDkgMjAwNAorKysgdGNwZHVtcC5j
CVN1biBKdW4gMTMgMTY6MDU6MzQgMjAwNApAQCAtNjE1LDcgKzYxNSw3IEBACiAJCQkvKiBOT1RS
RUFDSEVEICovCiAJCX0KIAotCWlmICh0ZmxhZyA+IDApCisJaWYgKCh0ZmxhZyA+IDApIHx8ICh0
ZmxhZyA9PSAtMykpCiAJCXRoaXN6b25lID0gZ210MmxvY2FsKDApOwogCiAJaWYgKFJGaWxlTmFt
ZSAhPSBOVUxMKSB7Cg==
------=_Part_221_16269327.1096801476179--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3f030e4204100304043ef4b8f>