[Winpcap-users] Problems with modifying pcap-win32.c to support our device

Varuna De Silva varunax at gmail.com
Thu Sep 13 06:34:27 GMT 2007


We need to add support for our device in libpcap, it is a USB device with a
custom driver.

   - I am in the Windows platform & Working with VS2005 (C++)
   - I have downloaded WinPcap and compiled the packet.dll (Though not
   used) and then wpcap.dll from source successfully
   - The build configuration is Debug_REMOTE

As I was previously educated I wrote my own program with including
pcap.hand other
necessary headers for the driver. Within it I gave my device the name
And next I want to call the pcap_open_live() in libpcap.

What I did In my program
I wrote my own program usb.c in VS2005 in a new project.
This had the initialization of the device name and I called
I linked the wpcap.lib (and other necessary libraries for the driver) in
winpcap\wpcap\LIB which is refreshed every time I build wpcap entire

What I did to Pcap-win32.c

   - I changed the project properties to include my own preprocesser
   directive HAVE_USBSS7_API in project window
   - I changed the pcap_open_live() in this c file as below

pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char
    register pcap_t *p;
    NetType type;

    char host[PCAP_BUF_SIZE + 1];
    char port[PCAP_BUF_SIZE + 1];
    char name[PCAP_BUF_SIZE + 1];
    int srctype;

    printf("I am inside the Win32 \n");
    return NULL;


I added my piece of code inside the HAVE_REMOTE because I am using that
build configuration.
I just want to know when I call pcap_open_live to which program does it get
called which has that
routine (In windows)

I know that the routine gets called since I get an error message when I call
But I doubt if it is the routine in Pcap-win32.c

The error message
Error opening adapter: The system cannot find the device specified. (20)

In seeing this message I just changed the occurrence of this statement in

if (p->adapter == NULL)
        /* Adapter detected but we are not able to open it. Return failure.
        snprintf(ebuf, PCAP_ERRBUF_SIZE, "Error opening adapter ss7_usb:
%s", pcap_win32strerror());
        return NULL;

Just to see if it works .... Unfortunately not:-) the error message stays
the same

The error message is alright cause I have done nothing to open the device,
But I want to know from where I get this message. Is it not the
Pcap-win32.c in winpcap\libpcap

Does Pcap-win32.c.orig has anything to do with it ? I didnt mingled with it
since that is not is the project tree.

Please Help me out with this....

I have no way out from here!

Thank you all

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20070913/9fc53469/attachment.html

More information about the Winpcap-users mailing list