//open the adapter
adapterhandle=pcap_open(adapter->name,65536,PCAP_OPENFLAG_PROMISCUOUS,1000,NULL,errorBuffer);
if (adapterhandle==NULL){
cout<<"Unable to open adapter "<<adapter->name<<"\n";
pcap_freealldevs(allAdapters);
return;
}
cout<<"Capture process started on adapter "<<adapter->name<<"\n";
//recieve packets, this part does not work.
while ((retValue=pcap_next_ex(adapterhandle,&packetHeader,&packetData))>=0){
if (retValue==0)
continue;
cout<<"Packet Length: "<<packetHeader->len<<"Received at :"<<packetHeader->ts.tv_sec<<"\n\n";
}
//clean up
pcap_freealldevs(allAdapters);
cout<<"Finished\n\n";
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.