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

Varuna De Silva varunax at gmail.com
Sat Sep 15 03:38:21 GMT 2007

Thanks GV, Ill try it out

Best Regards,


---------- Forwarded message ----------
From: Gianluca Varenni <gianluca.varenni at cacetech.com>
Date: Sep 15, 2007 7:32 AM
Subject: Re: I plead you Please Help me!!!!!!!!!!!!!!!
To: Varuna De Silva <varunax at gmail.com>

----- Original Message -----
*From:* Varuna De Silva <varunax at gmail.com>
*To:* gianluca.varenni at cacetech.com
*Sent:* Friday, September 14, 2007 5:39 AM
*Subject:* I plead you Please Help me!!!!!!!!!!!!!!!

Hello GV,

I posted this on the winpcap mailing list without any reply, I know you people
are busy with the new release of libpcap, but whenever you get a chance please
reply me, I am simply lost, without you peoples' help.

I usually answer (some of) the mails on winpcap-users in my spare time at
work, sometimes it happens that I answer every 3-4 days. Usually sending
private mails to me doesn't help much, I usually just forward them to the
winpcap-users or winpcap-bugs mailing list. The reason is that a private
answer to you helps you, only. It doesn't help other people that in the
future might have the same problem.

In any case, below you can find some hints on how to solve your problem,
please forward my answer on the the winpcap mailing lists :-)

Have a nice day

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

I think the problem is that you are not using the right version of wpcap.dll.
As a matter of facts, the compilation of wpcap generates two files,
wpcap.lib and wpcap.dll. Since from my understanding you didn't add new
exported functions to wpcap.dll, wpcap.lib is always the same. The important
thing is that you need to copy the newly compiled wpcap.dll from
Debug_REMOTE to either the system folder (c:\windows\system32) or to the run
folder of your test application.

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

No. That file is a temp file that should have not been released in the
official winpcap sources. It comes from the fact that we automatically patch
some of the original libpcap files to add remote support. The .orig file
comes from that patching procedure.

since that is not is the project tree.

Please Help me out with this....

I have no way out from here!

I think it is a linking problem associated with me trying to compile a VC++

project on Visual Studio. But I cant figure it out at all.

Thank you all

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20070915/0a0fbcf5/attachment.htm

More information about the Winpcap-users mailing list