18,356
社区成员
发帖
与我相关
我的任务
分享
pcap_open(d->name,65536,0,1000, 0,errbuf);
if (p == NULL)
{
strTemp.Format ("pcap_open failed:%s",errbuf);
goto error;
}
/* get the subnet mask of the interface */
if (pcap_lookupnet(device, &local_net, &netmask, errbuf) == -1)
{
strTemp.Format ("get the subnet mask of the interface failed:%s",errbuf);
goto error;
}
/* compile the BPF filter code */
if (pcap_compile(p, &filter_code, GNIP_FILTER, 1, netmask) == -1)
{
strTemp.Format ("compile the BPF filter code failed");
goto error;
}
/* apply the filter to the interface */
if (pcap_setfilter(p, &filter_code) == -1)
{
strTemp.Format ("apply the filter to the interface failed");
goto error;
}
pcap_fd = pcap_fileno(p);
TRACE1 ("pcap_fd=%d\n",pcap_fd);
while(1)
{
FD_ZERO(&rfd_set);
FD_SET(pcap_fd, &rfd_set);
ret =select(pcap_fd+1, &rfd_set, NULL, NULL,NULL);
if(ret < 0)
{
strTemp.Format ("select error:%d",WSAGetLastError ());
goto error;
}
}
FILE* fp = stdin;
fd_set rset;
FD_ZERO(&rset);
FD_SET(fileno(fp),&rset);