[Winpcap-bugs] pcap_lookupdev returns wide characters

Gianluca Varenni gianluca.varenni at cacetech.com
Mon May 29 14:47:17 GMT 2006


Nic,

this is a sort of known problem with pcap_lookupdev (it was a design error 
when pcap_lookupdev was ported from unix to win32). Moreover, this API is in 
any case broken (it's not thread safe, and the behaviour is in any case 
different from Linux because it reports all the adapters, while 
pcap_lookupdev on unix reports just the first adapter), and deprecated. You 
should use pcap_findalldevs (or pcap_findalldevs_ex) to list all the 
adapters of your system (pcap_findalldevs is available on win32 as well as 
on unix, in libpcap).

Have a nice day
GV

----- Original Message ----- 
From: "Nic Watson" <nic at ghs.com>
To: <winpcap-bugs at winpcap.org>
Sent: Friday, May 19, 2006 10:21 PM
Subject: [Winpcap-bugs] pcap_lookupdev returns wide characters


>I have some old pcap-using code that uses pcap_lookupdev.  I'm using
> winpcap version 3.1 on XP SP2.  4.0 alpha 1 has the same problem.  It
> returns a pointer to a buffer that contains every other byte null'd.
>
>  char *this_devname = pcap_lookupdev(errbuf);
>  printf("lookupdev is %s\n", this_devname);
>
> It prints:  "lookupdev is \".  The memory region at this_devname is:
>
> \.D.e.v.i.c.e.\.
> N.P.F._.G.e.n.e.
> r.i.c.D.i.a.l.u.
> p.A.d.a.p.t.e.r.
> ..\.D.e.v.i.c.e.
> \.N.P.F._.{.9.D.
> D.2.6.E.2.9.-.4.
> A.4.A.-.4.F.F.5.
> -.B.D.A.4.-.B.5.
> 9.C.5.D.E.1.7.5.
> 3.A.}
>
> It would be correct if the nulls were taken out.
>
> Nic Watson
> _______________________________________________
> Winpcap-bugs mailing list
> Winpcap-bugs at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-bugs 




More information about the Winpcap-bugs mailing list