[Winpcap-users] wpcap.dll & Visual C++.net

Hirtzel, Doug-p8094c Doug.Hirtzel at gdc4s.com
Mon May 24 09:46:15 PDT 2010


I am writing a simple application targeted for Visual C++.net 2008.

I have read numerous FAQ & message boards that talk about the Common
Language Runtime (CLR) and managed vs unmanaged. But they seem to refer
more to console based programs.
http://www.codeguru.com/Cpp/COM-Tech/complus/managed/article.php/c3947
http://www.winpcap.org/misc/faq.htm#Q-29
<http://www.winpcap.org/misc/faq.htm>  pcap_int.h is not in the release
directory. Where can I get this file? Or what is the definition of
struct pcap?

I have added the following lines to the stdafx.h file.
struct  pcap {};
typedef struct pcap        pcap_t;
typedef struct pcap_dumper pcap_dumper_t;
typedef struct pcap_if     pcap_if_t;
typedef struct pcap_addr   pcap_addr_t;

typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *, const
u_char *);

Is this the correct location for these declarations or should they go in
the Form1.h file inside the namespace wfa_send_packet { } section?
They compile in both locations.

I have added the following lines to the Form1.h namespace
wfa_send_packet { } section.

	using namespace System::Runtime::InteropServices;
	[DllImport("wpcap.dll")]    extern "C" int  pcap_open_live(const
char *, int, int, int, char *);

But problems persist when trying to call pcap_open_live.
			pcap_t *fp;
			/* Open the Ethernet I/O adapter */
			if ((fp = pcap_open_live(c_io_adapter_name, //
name of the device
	
65536,			    // portion of the packet to capture. It
doesn't matter in this case 
	
1,				    // promiscuous mode (nonzero means
promiscuous)
	
1000,			    // read timeout
	
errbuf			    // error buffer
	
)) == NULL)
			{
				fprintf(stderr,"\nUnable to open the
adapter. %s is not supported by WinPcap\n", c_io_adapter_name);
				return 2;
			}
error C2440: '=' : cannot convert from 'int' to 'pcap_t *'

Can anyone direct me with a simple project with what needs to be done to
implement winpcap in Visual C++.net Windows Form Applications?

Doug

This message and/or attachments may include information subject to GDC4S
O.M. 1.8.6 and GD Corporate Policy 07-706 and is intended to be accessed
only by authorized personnel of General Dynamics and approved service
providers. Use, storage and transmission are governed by General
Dynamics and its policies. Contractual restrictions apply to third
parties. Recipients should refer to the policies or contract to
determine proper handling. Unauthorized review, use, disclosure or
distribution is prohibited. If you are not an intended recipient, please
contact the sender and destroy all copies of the original message.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20100524/790c9078/attachment-0001.htm 


More information about the Winpcap-users mailing list