求VC下WINPCAP抓包的代码

来源:百度知道 编辑:UC知道 时间:2024/05/31 21:43:59
发到我邮箱,附上你的百度账号
xixueguimengmo@126.com
我要的是workspace,抓IP的,smtp的等等都行
要能运行的哈,WINPCA

不知道你那个程序图表和流量怎么显示

发给你了。

#include "pcap.h"
#include <stdio.h>
#include <string.h>

/* packet handler 函数原型 */
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);

main()
{
pcap_if_t *alldevs;
pcap_if_t *d;
int inum;
int i=0;
pcap_t *adhandle;
char errbuf[PCAP_ERRBUF_SIZE];

/* 获取本机设备列表 */
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1)
{
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
exit(1);
}

/* 打印列表 */
for(d=alldevs; d; d=d->next)
{
printf("%d. %s", ++i, d->name);
if (d->description)
printf(" (%s)\n", d->description);
else
printf(" (No description available)\n");
}