gmt2local.c:
int32_t
gmt2local(time_t t)
{
register int dt, dir;
register struct tm *gmt, *loc;
struct tm sgmt;
if (t == 0)
t = time(NULL);
gmt = &sgmt;
*gmt = *gmtime(&t);
loc = localtime(&t);
dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
(loc->tm_min - gmt->tm_min) * 60;
/*
* If the year or julian day is different, we span 00:00 GMT
* and must add or subtract a day. Check the year first to
* avoid problems when the julian day wraps.
*/
dir = loc->tm_year - gmt->tm_year;
if (dir == 0)
dir = loc->tm_yday - gmt->tm_yday;
dt += dir * 24 * 60 * 60;
return (dt);
}
tcpdump.c
int tflag=1;
cast 't' //如果在参数中有指定
--tflag;
break;
if (tflag > 0)
thiszone = gmt2local(0);
util.c
void
ts_print(register const struct timeval *tvp)
{
register int s;
struct tm *tm;
time_t Time;
static unsigned b_sec;
static unsigned b_usec;
switch(tflag) {
case 1: /* Default */
s = (tvp->tv_sec + thiszone) % 86400;
(void)printf("%02d:%02d:%02d.%06u ",
s / 3600, (s % 3600) / 60, s % 60,
(unsigned)tvp->tv_usec);
break;
case -1: /* Unix timeval style */
(void)printf("%u.%06u ",
(unsigned)tvp->tv_sec,
(unsigned)tvp->tv_usec);
break;
case -2:
if (b_sec == 0) {
printf("000000 ");
} else {
int d_usec = tvp->tv_usec - b_usec;
int d_sec = tvp->tv_sec - b_sec;
while (d_usec < 0) {
d_usec += 1000000;
d_sec--;
}
if (d_sec)
printf("%d. ", d_sec);
printf("%06d ", d_usec);
}
b_sec = tvp->tv_sec;
b_usec = tvp->tv_usec;
break;
case -3: /* Default + Date*/
s = (tvp->tv_sec + thiszone) % 86400;
Time = (tvp->tv_sec + thiszone) - s;
tm = gmtime (&Time);
if (!tm)
printf("Date fail ");
else
printf("%04d-%02d-%02d ",
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
printf("%02d:%02d:%02d.%06u ",
s / 3600, (s % 3600) / 60, s % 60, (unsigned)tvp->tv_usec);
break;
}
}
分享到:
相关推荐
tcpdump源码编译,需要多个部件的源码进行顺序编译而成。 m4-1.4.19.tar.gz flex-2.6.4.tar.gz bison-3.7.6.tar.gz libpcap-1.10.4.tar.gz tcpdump-4.99.4.tar.gz tar xvf *.tar解压后,分别执行./configure 和make ...
tcpdump源码分享,4.0和3.9版本
tcpdump4.9.2.tar版本源码和libpcap-1.9.0.tar.gz,非常好的学习资料。
tcpdump最新版本源码,包含tcpdump-4.5.1.tar.gz和libpcap-1.5.3.tar.gz两个包,非常好的学习资料。
tcpdump是一个很有用的网络抓包分析工具
libpcap源码和tcpdump源码文件,用于编译tcpdump
NULL 博文链接:https://taijuk.iteye.com/blog/1583901
抓包软件 example: tcpdump -i eth0 -s 0 -w abc.pcap
Tcpdump 4.5.1版本,解压后是一个二进制可执行文件,不需要任何编译和安装,可以直接执行,上传Linux环境解压即可使用: root@admin:/tmp# ./tcpdump -help tcpdump version 4.5.1 libpcap version 1.5.3 Usage: ...
tcpdump 数据包 tcpdump 数据包 tcpdump 数据包 http://www.tcpdump.org/
大家看看,一个工具的源码,不怎么看得懂,大家研究下
资源分为:1,Android下运行的tcpdump可执行文件;2,Android下tcpdump抓包步骤说明。 实现:Android下用tcpdump抓取手机网络数据包,进而分析出手机app流量消耗原因,优化app流量消耗。
tcpdump抓包工具,提供个下载不了的小伙伴 需要获得tcpdump软件,官方获取地址(http://www.strazzere.com/android/tcpdump)
利用tcpdump分析RTMP推流网络包:握手、连接、推流
TcpdumpTCPDUMP 4.xy 要报告安全问题,请发送电子... 但是,本机软件包有时会落后几个版本,并尝试使用最新快照以从源代码编译tcpdump。 tcpdump至少可以在以下平台上编译和运行: 艾克斯 蜻蜓BSD FreeBSD的 HP-UX
tcpdump 运用libpcap进行网络报文信息处理,linux下经典又优秀的工具。强烈推荐源代码共享!
tcpdump
tcpdump-tcpdump-4.9.2.zip
tcpdump [ -DenNqvX ] [ -c count ] [ -F file ] [ -i interface ] [ -r file ] [ -s snaplen ] [ -w file ] [ expression ] 抓包选项: -c:指定要抓取的包数量。注意,是最终要获取这么多个包。例如,指定"-c 10...