[prev in list] [next in list] [prev in thread] [next in thread] 

List:       winpcap-users
Subject:    [Winpcap-users] Problems with modifying pcap-win32.c to support our
From:       "Varuna De Silva" <varunax () gmail ! com>
Date:       2007-09-13 6:46:27
Message-ID: cfaac9680709122334w65309fe1h3b311111be489579 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

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
"usb_ss7_if".
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
pcap_open_live().
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
solution

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
*ebuf)
{
    register pcap_t *p;
    NetType type;


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

#ifdef HAVE_USBSS7_API
    printf("I am inside the Win32 \n");
    return NULL;
#endif

..............................................continued....

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
pcap_open_live(),
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
pcap-win32.c

if (p->adapter == NULL)
    {
        free(p);
        /* 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

Xavier

[Attachment #5 (text/html)]

Hi,<br><br>We need to add support for our device in libpcap, it is a USB device with \
a custom driver.<br><br><ul><li>I am in the Windows platform &amp; Working with \
VS2005 (C++)</li><li>I have downloaded WinPcap and compiled the  packet.dll (Though \
not used) and then wpcap.dll from source successfully </li><li>The build \
configuration is Debug_REMOTE</li></ul><br>As I was previously educated I wrote my \
own program with including pcap.h and other <br>

necessary headers for the driver. Within it I gave my device the name \
&quot;usb_ss7_if&quot;. <br>And next I want to call the pcap_open_live() in \
libpcap.<br><br><span style="font-weight: bold;">What I did In my program</span> \
<br>I wrote my own program usb.c in VS2005 in a new project. <br>This had the \
initialization of the device name and I called pcap_open_live().<br>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 solution <br><br><span \
style="font-weight: bold;">What I did to Pcap-win32.c</span><br><ul><li>I changed the \
project properties to include my own preprocesser directive HAVE_USBSS7_API in \
project window</li><li>I changed the pcap_open_live() in this c file as below \
</li></ul><br>pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, \
char *ebuf)<br>{<br>&nbsp;&nbsp;&nbsp; register pcap_t *p;<br>&nbsp;&nbsp;&nbsp; \
NetType type;<br><br><br>#ifdef HAVE_REMOTE<br>&nbsp;&nbsp;&nbsp; char \
host[PCAP_BUF_SIZE + 1];<br> &nbsp;&nbsp;&nbsp; char port[PCAP_BUF_SIZE + \
1];<br>&nbsp;&nbsp;&nbsp; char name[PCAP_BUF_SIZE + 1];<br>&nbsp;&nbsp;&nbsp; int \
srctype;<br><br><span style="font-weight: bold;">#ifdef HAVE_USBSS7_API</span><br \
style="font-weight: bold;"><span style="font-weight: bold;"> &nbsp;&nbsp;&nbsp; \
printf(&quot;I am inside the Win32 \n&quot;);</span><br style="font-weight: \
bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; return NULL;</span><br \
style="font-weight: bold;"><span style="font-weight: bold;">#endif</span><br> \
<br>..............................................continued....<br><br>I added my \
piece of code inside the HAVE_REMOTE because I am using that build configuration. \
<br>I just want to know when I call pcap_open_live to which program does it get \
called which has that <br>routine (In windows)<br><br>I know that the routine gets \
called since I get an error message when I call pcap_open_live(),<br>But I doubt if \
it is the routine in Pcap-win32.c<br><br><span style="font-weight: bold;">The error \
message </span><br><span style="font-weight: bold;">Error opening adapter: The system \
cannot find the device specified. (20)</span><br><br>In seeing this message I just \
changed the occurrence of this statement in pcap-win32.c<br> <br>if (p-&gt;adapter == \
NULL)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
free(p);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* Adapter detected but we are not \
able to open it. Return failure. */<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
snprintf(ebuf, PCAP_ERRBUF_SIZE, &quot;Error opening adapter <font size="4"> <span \
style="font-weight: bold;">ss7_usb</span></font>: %s&quot;, \
pcap_win32strerror());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return \
NULL;<br>&nbsp;&nbsp;&nbsp; }<br><br>Just to see if it works .... Unfortunately \
not:-) the error message stays the same<br><br><br> The error message is alright \
cause I have done nothing to open the device,<br>But I want to know from where I get \
this message. Is it not the <br>Pcap-win32.c in winpcap\libpcap<br><br>Does \
Pcap-win32.c.orig has anything to do with it ? I didnt mingled with it <br>since that \
is not is the project tree. <br><br>Please Help me out with this....<br><br>I have no \
way out from here!<br><br>Thank you all<br><br>Xavier<br><br><br><br><br><br>



_______________________________________________
Winpcap-users mailing list
Winpcap-users@winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic