I just getting use to using WinPCap and had it working with my old IDE. However I've upgraded and starting messing with it again and now I've run into a problem that's driving me nuts.

I seem to be getting this error:

error C2664: 'pcap_loop' : cannot convert parameter 3 from 'void (u_char *,const pcap_pkthdr *,const u_char *)' to 'pcap_handler'

I tried wrapping the packet_handler class is extern "C" {...} and still same thing.

my code is pretty much this...

//copied more or less from the examples.....

void TableState::listen(void)
   pcap_if_t *alldevs;
   pcap_if_t *d;
   int inum;
   int j=0;
   pcap_t *adhandle;
   char errbuf[PCAP_ERRBUF_SIZE];

if (pcap_findalldevs(&alldevs, errbuf) == -1)
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
/* Print the list */
//Just use the first adapter.... inum = 1;
/* Jump to the selected adapter */
for(d=alldevs, j=0; j< inum-1 ;d=d->next, j++);
/* Open the adapter */
if ( (adhandle= pcap_open_live(d->name, // name of the device
65536, // portion of the packet to capture.
// 65536 grants that the whole packet will be captured on all the MACs.
1, // promiscuous mode
1000, // read timeout
errbuf // error buffer
) ) == NULL)
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n");
/* Free the device list */
printf("\nlistening on %s...\n", d->description);
/* At this point, we don't need any more the device list. Free it */
/* start the capture */
pcap_loop(adhandle, 0,packet_handler, NULL);


void TableState::packet_handler(u_char * param, const struct pcap_pkthdr * header, const u_char * pkt_data)

//Just to show that I'm handling packets........

This is the WinPcap users list. It is archived at

To unsubscribe use mailto: [EMAIL PROTECTED]

Reply via email to