*数据包捕获线程*/
UINT do_capture(LPVOID pParam)
{
char errbuf[PCAP_ERRBUF_SIZE];
pcap_t *fp;
int res;
struct pcap_pkthdr *header;
const u_char *pkt_data;
CString str;
unsigned int i;
struct packetstru *cur_pack,*new_pack;
char s[100];
CStatic *static1,*static2;
int found;
static1=(CStatic *)AfxGetMainWnd()->GetDlgItem(IDC_STATIC1);
static2=(CStatic *)AfxGetMainWnd()->GetDlgItem(IDC_STATIC2);
fp = pcap_open_live(*devicename,65536,1,-1,errbuf); //打开网络设备
while(1)
{
if(captureflag==0)
break;
res = pcap_next_ex( fp, &header, &pkt_data); //读数据包
if(res==0) //超时返回
{
Sleep(1);
continue;
}
if(res<0) //发生错误
{
break;
|