On Wed, Sep 24, 2003 at 12:03:14PM -0300, Dario Tamburi wrote:
> I do:
> 
> manija=pcap_open_live(d->name,65536,1,1000,buffer);
>  if(manija==NULL)
>  {
>   cout << "error al abrir la interfaz";

I suggest you instead do

        cout << "error al abrir la interfaz: " << buffer;

so that you also see the error message from "pcap_open_live()", not just
a message saying you got an error opening the interface.

>   pcap_freealldevs(dispositivos);
>   return 1;
>  }
> 
>  pcap_freealldevs(dispositivos);
>  cout << "escuchabdo sobre: " << d->description;

You should probably do something such as

        if (d->description != NULL)
                cout << "escuchabdo sobre: " << d->description;
        else
                cout << "escuchabdo sobre: " << d->name;

as there's no guarantee that "d->description" is non-NULL.  (It might
never be null on Windows, but I don't know that WinPcap will guarantee
that - and if you check for it, your program will be more likely to work
on UNIX platforms where it *can* be null.)

>  /*capturo paquetes*/
>  pcap_loop(manija,0,packet_handler,NULL);
>  return 0;
> 
> and I has the error:
> 
> error C2664: 'pcap_loop' : cannot convert parameter 3 from 'void (char,const struct 
> pcap_pkthdr,const char)' to 'void (__cdecl *)(unsigned char *,const struct 
> pcap_pkthdr *,const unsigned char
> 
> Why?

Because "packet_handler()" isn't a C function (you might have to wrap it
in

        extern "C" {

                ...

        };

to ensure that it's a C function, not a C++ function) that takes, as its
arguments:

        an "unsigned char *";

        a "const struct pcap_pkthdr *;

        a "const unsigned char *".

It must take three *pointers* as arguments; it cannot take "char",
"const struct pcap_pkthdr", and "const char" as arguments.


==================================================================
 This is the WinPcap users list. It is archived at
 http://www.mail-archive.com/[EMAIL PROTECTED]/

 To unsubscribe use 
 mailto: [EMAIL PROTECTED]
==================================================================

Reply via email to