dlls: add wpcap

James Hawkins truiken at gmail.com
Wed Nov 22 02:05:50 CST 2006


On 11/21/06, mengzhuo li <muziwind at yahoo.com.cn> wrote:
> Changlog: add wpcap.dll.so in wine, there are some wpcap functions added,
> not all.
> note: before configure, you should use autoreconf to generate a new
> configure file.
>

Why are you adding this dll?  Does it fix some app?  I just looked
around and wpcap.dll is a third-party library used for packet
capturing.  This does not need to be implemented in Wine if that's the
case, but I've added comments below for future reference.

diff -uNr wine.orig/configure.ac wine/configure.ac
--- wine.orig/configure.ac	2006-11-21 16:28:25.000000000 +0800
+++ wine/configure.ac	2006-11-21 16:30:51.000000000 +0800
@@ -1669,6 +1669,7 @@
 dlls/ntdsapi/Makefile
 dlls/objsel/Makefile
 dlls/odbc32/Makefile
+dlls/wpcap/Makefile
 dlls/odbccp32/Makefile
 dlls/ole32/Makefile
 dlls/ole32/tests/Makefile
diff -uNr wine.orig/dlls/Makefile.in wine/dlls/Makefile.in
--- wine.orig/dlls/Makefile.in	2006-11-21 16:27:59.000000000 +0800
+++ wine/dlls/Makefile.in	2006-11-21 16:30:51.000000000 +0800
@@ -125,6 +125,7 @@
 	ntdsapi \
 	objsel \
 	odbc32 \
+	wpcap \
 	odbccp32 \
 	ole32 \
 	oleacc \
@@ -559,6 +560,7 @@
 	ntdll/libntdll.$(IMPLIBEXT) \
 	ntdsapi/libntdsapi.$(IMPLIBEXT) \
 	odbc32/libodbc32.$(IMPLIBEXT) \
+	wpcap/libwpcap.$(IMPLIBEXT) \
 	odbccp32/libodbccp32.$(IMPLIBEXT) \
 	ole32/libole32.$(IMPLIBEXT) \
 	oleacc/liboleacc.$(IMPLIBEXT) \
@@ -820,6 +822,9 @@
 odbc32/libodbc32.$(IMPLIBEXT): odbc32/odbc32.spec $(WINEBUILD)
 	@cd odbc32 && $(MAKE) libodbc32.$(IMPLIBEXT)

+wpcap/libwpcap.$(IMPLIBEXT): wpcap/wpcap.spec $(WINEBUILD)
+	@cd wpcap && $(MAKE) libwpcap.$(IMPLIBEXT)
+
 odbccp32/libodbccp32.$(IMPLIBEXT): odbccp32/odbccp32.spec $(WINEBUILD)
 	@cd odbccp32 && $(MAKE) libodbccp32.$(IMPLIBEXT)

diff -uNr wine.orig/dlls/wpcap/Makefile.in wine/dlls/wpcap/Makefile.in
--- wine.orig/dlls/wpcap/Makefile.in	1970-01-01 08:00:00.000000000 +0800
+++ wine/dlls/wpcap/Makefile.in	2006-11-21 16:30:51.000000000 +0800
@@ -0,0 +1,16 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = wpcap.dll
+IMPORTLIB = libwpcap.$(IMPLIBEXT)
+IMPORTS   = kernel32 ntdll
+EXTRAINCL = @X_CFLAGS@
+EXTRALIBS = @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@ -lpcap
+

I'm not a Makefile pro by any means, but why do you need all thse
EXTRALIBS?  Also, you're going to have to add a configure check for
-lpcap.

+C_SRCS = \
+	wpcap.c
+
+ at MAKE_DLL_RULES@
+
+### Dependencies:
diff -uNr wine.orig/dlls/wpcap/wpcap.c wine/dlls/wpcap/wpcap.c
--- wine.orig/dlls/wpcap/wpcap.c	1970-01-01 08:00:00.000000000 +0800
+++ wine/dlls/wpcap/wpcap.c	2006-11-21 16:30:51.000000000 +0800
@@ -0,0 +1,73 @@
+#ifdef WIN32
+#undef WIN32
+#endif
+#include <pcap.h>

You need to add the GPL license to the top of every source file.
Check out any other source file in the code base for examples.

+void wine_pcap_close(pcap_t * a)
+{
+	pcap_close(a);
+}
+

Assuming the name of the API is pcap_close, you'll have to define it like this:

void WINAPI pcap_close(pcap_t *a)

WINAPI is needed, but the wine_ prefix is not.

+pcap_t * wine_pcap_open_live(const char * a, int b, int c , int d , char * e )
+{
+	return pcap_open_live(a,b,c,d,e);
+}
+
+int wine_pcap_findalldevs(pcap_if_t ** a, char * b)
+{
+	return pcap_findalldevs(a,b);
+}
+
+void wine_pcap_freealldevs(pcap_if_t * a)
+{
+	pcap_freealldevs(a);
+}
+
+int  wine_pcap_compile(pcap_t * a, struct bpf_program * b, char * c,
int d, bpf_u_int32 e )
+{
+	return pcap_compile(a,b,c,d,e);
+}
+
+int wine_pcap_setfilter(pcap_t * a, struct bpf_program * b)
+{
+	return pcap_setfilter(a,b);
+}
+
+int wine_pcap_datalink(pcap_t * a)
+{
+	return pcap_datalink(a);
+}
+
+const u_char* wine_pcap_next(pcap_t * a, struct pcap_pkthdr * b)
+{
+	return pcap_next(a,b);
+}
+
+int wine_pcap_setbuff(pcap_t * p, int dim)
+{
+	//return pcap_setbuff(p ,dim);
+	return 0;
+#if 0
+        #ifdef HAVE_REMOTE
+        if (p->rmt_clientside)
+        {
+                /* Currently, this is a bug: the capture buffer
cannot be set with remote capture */
+                return 0;
+        }
+#endif  /* HAVE_REMOTE */
+
+        if (p->adapter==NULL)
+        {
+                snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "The kernel
buffer size cannot be set while reading from a file");
+                return -1;
+        }
+
+        if(PacketSetBuff(p->adapter,dim)==FALSE)
+        {
+                snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "driver error:
not enough memory to allocate the kernel buffer");
+                return -1;
+        }
+        return 0;
+#endif
+}
+
+
diff -uNr wine.orig/dlls/wpcap/wpcap.spec wine/dlls/wpcap/wpcap.spec
--- wine.orig/dlls/wpcap/wpcap.spec	1970-01-01 08:00:00.000000000 +0800
+++ wine/dlls/wpcap/wpcap.spec	2006-11-21 16:30:51.000000000 +0800
@@ -0,0 +1,9 @@
+@ stdcall pcap_close(ptr) wine_pcap_close
+@ stdcall pcap_open_live(str long long long str) wine_pcap_open_live
+@ stdcall pcap_findalldevs(ptr str) wine_pcap_findalldevs
+@ stdcall pcap_freealldevs(ptr) wine_pcap_freealldevs
+@ stdcall pcap_compile(ptr ptr str long long)  wine_pcap_compile
+@ stdcall pcap_setfilter(ptr ptr) wine_pcap_setfilter
+@ stdcall pcap_datalink(ptr) wine_pcap_datalink
+@ stdcall pcap_next(ptr ptr) wine_pcap_next
+@ stdcall pcap_setbuff(ptr long) wine_pcap_setbuff

As I said before, you don't need to forward these, just name the APIs
like they are in the spec file and it should work.

-- 
James Hawkins



More information about the wine-devel mailing list