// 抓包回调
// pcap_loop方式: void pcap_handler(u_char *param, const struct pcap_pkthdr *pkt_hdr, const u_char *pkt_data) { struct tm *ltime; char strTime[16]; time_t local_tv_time; local_tv_time = pkt_hdr->ts.tv_sec; ltime=localtime(&local_tv_time); strftime(strTime,sizeof(strTime),"%H:%M:%S",ltime); printf("Time:%s,\t Second:%.6d,\tMicro Second:%.5d,\t%d\n",strTime,local_tv_time,pkt_hdr->len); }