外贸俄罗斯俄语网站制作,上海华东建设发展设计有限公司网站,企业注册公司,wordpress插件大全1.libpcap的模式
有线环境: 使用混杂模式promisous#xff0c;完成监听无线环境: 使用监听模式monitor#xff0c;完成监听
2.交叉编译libpcap
设置好交叉编译工具链后下载libpcap源码使用configure进行构建#xff1a;–disable-shared 构建静态库#xff0c;–host 、…1.libpcap的模式
有线环境: 使用混杂模式promisous完成监听无线环境: 使用监听模式monitor完成监听
2.交叉编译libpcap
设置好交叉编译工具链后下载libpcap源码使用configure进行构建–disable-shared 构建静态库–host 、–with-linux构建参考海思 tcpdump 移植开发详解
3.去掉pcap文件里每帧的fcs
利用libpcap库读入待处理的pcap文件然后去掉每帧尾部的4字节fcs再写入新的pcap文件
#include stdio.h
#include pcap.hint main() {char errbuf[PCAP_ERRBUF_SIZE];pcap_t *handle;pcap_t *handle2;const u_char *packet;struct pcap_pkthdr header;int i;pcap_dumper_t *dumper;// 打开pcap文件handle pcap_open_offline(1.pcap, errbuf);if (handle NULL) {printf(Error opening pcap file: %s\n, errbuf);return 1;}// 打开输出pcap文件handle2 pcap_open_dead(DLT_EN10MB, 65535);dumper pcap_dump_open(handle2, 2.pcap);if (dumper NULL) {printf(Error creating pcap file\n);return 1;}// 读取并打印每个数据包while ((packet pcap_next(handle, header)) ! NULL) {// 写入数据包header.len - 4;header.caplen - 4;pcap_dump((u_char *)dumper, header, packet);//printf(Packet length: %d\n, header.len);//for (i 0; i header.len; i) {// printf(%02x , packet[i]);//}//printf(\n);}// 关闭pcap文件pcap_dump_close(dumper);pcap_close(handle2);// 关闭pcap文件pcap_close(handle);return 0;
}