(WinPcap 3.1 beta 4+VC++.net2003)
在WinPcap中的Handling offline dump files中的最后一个例子:“Writing packets to a dump file with pcap_live_dump”
编译后运行(输入sample6_4 test.cap 0 30)老是提示“Unable to start the dump, Error setting dump mode”,无法解决,望高手指点。
在WinPcap中的Handling offline dump files中的最后一个例子:“Writing packets to a dump file with pcap_live_dump”
编译后运行(输入sample6_4 test.cap 0 30)老是提示“Unable to start the dump, Error setting dump mode”,无法解决,望高手指点。
解决方案 »
- [请教]怎么在工具栏上实现菜单按钮?万分感谢!
- c++primer plus上的一个示例,我不明其中的两个地方,发上来,大家帮我讲讲 1.为什么要包含 string 和 cstring 两个头文件呢?
- 请问如何利用XmlTextReader读取XML文件中指定内容
- edit控件文本全选问题
- 请指高点...(没分啦)
- 哪里有id3或c4.5或c5.0算法的程序或软件???在线等待,立即给分
- 请问:哪儿有VC++6.0的下载?我的机子没光驱...
- 可不可以用程序获取当前CallStack的详细信息(象VC CallStack中给出的类似的)
- 怎样才能修改http 报头的内容,控制只提交部分字段?
- 帮忙看下这段代码!
- 发送用户名密码到一个网站,大家有可用的代码么,谢谢
- 请教一个关于串口的问题?
// sample6_4.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <pcap.h>
#define error At the moment the kernel dump feature is not supported in the driver
int _tmain(int argc, _TCHAR* argv[])
{
pcap_if_t *alldevs, *d;
pcap_t *fp;
u_int inum, i=0;
char errbuf[PCAP_ERRBUF_SIZE];
printf("kdump: saves the network traffic to file using WinPcap kernel-level dump faeature.\n");
printf("\t Usage: %s [adapter] | dump_file_name max_size max_packs\n", argv[0]);
printf("\t Where: max_size is the maximum size that the dump file will reach (0 means no limit)\n");
printf("\t Where: max_packs is the maximum number of packets that will be saved (0 means no limit)\n\n");
if(argc < 5)
{
if (pcap_findalldevs(&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");
}
if(i==0)
{
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
return -1;
}
printf("Enter the interface number (1-%d):",i);
scanf("%d", &inum);
if(inum < 1 || inum > i)
{
printf("\nInterface number out of range.\n");
return -1;
}
for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);
if ( (fp = pcap_open_live(d->name, 100, PCAP_OPENFLAG_PROMISCUOUS, 20, errbuf) ) == NULL)
{
fprintf(stderr,"\nError opening adapter\n");
return -1;
}
pcap_freealldevs(alldevs);
if(pcap_live_dump(fp, argv[1], atoi(argv[2]), atoi(argv[3]))==-1){
printf("Unable to start the dump, %s\n", pcap_geterr(fp));
return -1;
}
}
else{
if ( (fp= pcap_open_live(argv[1], 100, 1, 20, errbuf) ) == NULL)
{
fprintf(stderr,"\nError opening adapter\n");
return -1;
}
if(pcap_live_dump(fp, argv[0], atoi(argv[1]), atoi(argv[2]))==-1){
printf("Unable to start the dump, %s\n", pcap_geterr(fp));
return -1;
}
}
pcap_live_dump_ended(fp, TRUE);
pcap_close(fp);
return 0;
}