[Winpcap-users] C++ code to determine ports existence

Guy Harris guy at alum.mit.edu
Tue Jun 21 12:36:48 PDT 2011


(winpcap-announce is a list for the WinPcap developers to send out announcements; the list to send to for questions such as this is winpcap-users.)

On Jun 21, 2011, at 5:19 AM, rajath kumara wrote:

>  I need to find a C++ program, which when i run, gives me a list of all Ports in various NIC cards , i have in my system.
> I think winpcap function, findalldevs() does this, but i am not able to find this function

It's not "findalldevs()", it's "pcap_findalldevs()".

> nor i dont know how to compile or run it.

You don't compile it, you compile WinPcap.  It's part of WinPcap; see wpcap/libpcap/fad-win32.c in the WinPcap source.  You shouldn't need to compile WinPcap, however; you should just need the Developer's Pack - see

	http://www.winpcap.org/devel.htm

to download it.

pcap_findalldevs() is not a program, so you don't run it, you call it in *your* program:

	http://www.winpcap.org/docs/docs_412/html/group__wpcapfunc.html#ga7b128eaeef627b408f6a6e2a2f5eb45d

and you run your program.  It's a C function, not a C++ function, but its declaration in pcap/pcap.h is wrapped inside

	#ifdef __cplusplus
	extern "C" {
	#endif

and

	#ifdef __cplusplus
	}
	#endif

so it should be callable from C++ code.

> also the documentation page , isnt working http://www.winpcap.org/docs/docs40a1/html/group__compilation.html

That's for the 4.0a1 release, which was an alpha release, so they probably got rid of it when later releases came out.  Try the 4.1.2 documentation instead:

	http://www.winpcap.org/docs/docs_412/html/group__compilation.html


More information about the Winpcap-users mailing list