现在的位置: 首页 > 综合 > 正文

winpcap学习(五)

2018年01月29日 ⁄ 综合 ⁄ 共 364字 ⁄ 字号 评论关闭

// 抓包回调

// 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);
    }

抱歉!评论已关闭.