Code:
souraddr.sin_addr.s_addr=192.168.68.8;sourceport:200
destaddr.sin_addr.s_addr=192.168.68.9;destport:300(Just for example)
when I use:
printf("src:%s: port%d--->dst:%s: port%d",
inet_ntoa(souraddr.sin_addr),ntohs(tcp->source),
inet_ntoa(destaddr.sin_addr),ntohs(tcp->dest));
It output like this:
src:192.168.68.8: port200--->dst:192.168.68.8: port200(why the same?)
but when I use:
printf("src:%s: port%d--->",
inet_ntoa(souraddr.sin_addr),ntohs(tcp->source));
printf("dst:%s: port%d ",
inet_ntoa(destaddr.sin_addr),ntohs(tcp->dest));
It output like this:
src:192.168.68.8: port200--->dst:192.168.68.9: port300(It's right!!!)
got any ideas???
and how can I catch the time when I capture the packet???
Btw,I didn't use libpcap,I use socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)),the packet it capture contain no timestamp,how should I do?