aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2010-06-01 22:20:15 +0000
committerGerald Combs <gerald@wireshark.org>2010-06-01 22:20:15 +0000
commitfe79af8f421f738dcb767b4fdadad8bf65c81400 (patch)
treee9d095d8acc923c5458ff7870a7e148134762a6f
parent217b344bd982ce69a688805ee9f5d27aa9c9ecbd (diff)
From Kovarththanan Rajaratnam via bug 3500:
Sébastien's initial commit [1] didn't contain support for embedding Python on Windows. [1] http://anonsvn.wireshark.org/viewvc?view=rev&revision=28529 From me: Comment out PYTHON_EMBED for now. Start a list of known Python+CRT versions. Add get_wspython_dir to libwireshark.def. svn path=/trunk/; revision=33036
-rw-r--r--Makefile.nmake15
-rw-r--r--config.h.win323
-rw-r--r--config.nmake101
-rw-r--r--epan/Makefile.nmake33
-rw-r--r--epan/libwireshark.def1
-rw-r--r--epan/wspython/wspy_register.c2
6 files changed, 124 insertions, 31 deletions
diff --git a/Makefile.nmake b/Makefile.nmake
index 75298aa5d7..b8335c8c36 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -43,7 +43,7 @@ GENERATED_CFLAGS=-DHAVE_CONFIG_H $(LOCAL_CFLAGS) $(GLIB_CFLAGS) /I. /Iwiretap \
$(ZLIB_CFLAGS) /I$(PCAP_DIR)\include \
$(AIRPCAP_CFLAGS) \
$(C_ARES_CFLAGS) $(ADNS_CFLAGS) $(PCRE_CFLAGS) $(GNUTLS_CFLAGS) \
- $(LUA_CFLAGS) $(SMI_CFLAGS) $(GEOIP_CFLAGS) \
+ $(LUA_CFLAGS) $(PYTHON_CFLAGS) $(SMI_CFLAGS) $(GEOIP_CFLAGS) \
-D_U_="" -D_NEED_VAR_IMPORT_
CFLAGS=-WX $(GENERATED_CFLAGS)
@@ -77,6 +77,7 @@ wireshark_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
$(HHC_LIBS) \
wsutil\libwsutil.lib \
$(GNUTLS_LIBS) \
+ $(PYTHON_LIBS) \
!IFDEF ENABLE_LIBWIRESHARK
epan\libwireshark.lib \
!ELSE
@@ -96,6 +97,7 @@ tshark_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
$(GLIB_LIBS) \
wsutil\libwsutil.lib \
$(GNUTLS_LIBS) \
+ $(PYTHON_LIBS) \
!IFDEF ENABLE_LIBWIRESHARK
epan\libwireshark.lib \
!ELSE
@@ -115,6 +117,7 @@ rawshark_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
$(GLIB_LIBS) \
wsutil\libwsutil.lib \
$(GNUTLS_LIBS) \
+ $(PYTHON_LIBS) \
!IFDEF ENABLE_LIBWIRESHARK
epan\libwireshark.lib \
!ELSE
@@ -155,7 +158,8 @@ dumpcap_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
wsutil\libwsutil.lib \
$(GLIB_LIBS) \
$(GTHREAD_LIBS) \
- $(GNUTLS_LIBS)
+ $(GNUTLS_LIBS) \
+ $(PYTHON_LIBS)
dftest_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
wsock32.lib user32.lib \
@@ -369,6 +373,7 @@ config.h : config.h.win32 config.nmake
-e "s/@HAVE_LIBGCRYPT@/$(LIBGCRYPT_CONFIG)/" \
-e "s/@HAVE_LUA@/$(LUA_CONFIG)/" \
-e "s/@HAVE_LUA_5_1@/$(LUA_VERSION)/" \
+ -e "s/@HAVE_PYTHON@/$(PYTHON_CONFIG)/" \
-e "s/@HAVE_AIRPCAP@/$(AIRPCAP_CONFIG)/" \
-e "s/@HAVE_AIRPDCAP@/$(AIRPDCAP_CONFIG)/" \
-e "s/@HAVE_LIBPORTAUDIO@/$(PORTAUDIO_CONFIG)/" \
@@ -944,6 +949,12 @@ install-generated-files:
xcopy ".\epan\wslua\init.lua" $(INSTALL_DIR) /d
xcopy ".\epan\wslua\console.lua" $(INSTALL_DIR) /d
!ENDIF
+!IFDEF PYTHON_DIR
+ if not exist $(INSTALL_DIR)\python mkdir $(INSTALL_DIR)\python
+ xcopy ".\epan\wspython\register-dissector.py" $(INSTALL_DIR)\python /d
+ xcopy ".\epan\wspython\wspy_dissector.py" $(INSTALL_DIR)\python /d
+ xcopy ".\epan\wspython\wspy_libws.py" $(INSTALL_DIR)\python /d
+!ENDIF
xcopy ipmap.html $(INSTALL_DIR) /d
xcopy doc\*.html $(INSTALL_DIR) /d
if not exist $(INSTALL_DIR)\help mkdir $(INSTALL_DIR)\help
diff --git a/config.h.win32 b/config.h.win32
index a463161c5a..aed2d95469 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -192,6 +192,9 @@
@HAVE_LUA@
@HAVE_LUA_5_1@
+/* Define to use Python */
+@HAVE_PYTHON@
+
/* Define to use Portaudio library */
@HAVE_LIBPORTAUDIO@
/* Define version of of the Portaudio library API */
diff --git a/config.nmake b/config.nmake
index 5bba362a6d..8e7cea3b9e 100644
--- a/config.nmake
+++ b/config.nmake
@@ -138,6 +138,40 @@ MSVC_VARIANT=MSVC2008
#
NASM=$(WIRESHARK_LIBS)\nasm-2.02\nasm.exe
+#
+# Optional: the Python library enables scripting support.
+#
+# If you don't have the Python library, comment this line out, so that
+# PYTHON_EMBED isn't defined.
+#
+# NOTE: The Python library must have been compiled with the same
+# compiler (MSVC_VARIANT) as Wireshark. Kown python.org Python
+# CRT versions:
+#
+# Python version CRT (32-bit) CRT (64-bit)
+# 2.4.4 7.1 ?
+# 2.6.1 9.0 ?
+# 2.6.2 9.0
+#
+# If you versions of Python and Visual C++ use different CRTs
+# comment this out.
+#
+#PYTHON_EMBED=1
+
+#
+# Optional: the Python interpreter is used as part of the buildsystem
+#
+# If you have the Python interpreter, set this to the directory in which
+# the Python package is stored
+#
+# If you don't have the Python interpreter, comment this line out, so that
+# PYTHON_DIR isn't defined.
+#
+# V2.4 to V2.6 should work
+#
+#PYTHON_VER=26
+#PYTHON_DIR=C:\Python$(PYTHON_VER)
+
!if "$(WIRESHARK_TARGET_PLATFORM)" == "win32"
##### Win32 Libraries #####
@@ -582,30 +616,12 @@ PERL=perl
POD2MAN=$(SH) pod2man
POD2HTML=$(SH) pod2html
-# Command for native Windows Python (recommended)
-# V2.4 to V2.6 should work
-
-# If you want to specify your Python settings, uncomment the lines below.
-#PYTHON="C:\Python26\python.exe"
-#PATH=c:\Python26;$(PATH)
-
-# Command for Cygwin's Python (not recommended)
+#
+# If you don't have the native Python package installed, you can use
+# the Cygwin version (not recommended)
+#
#PYTHON=env python
-# Otherwise, find Python automatically.
-!IF !DEFINED(PYTHON)
-!IF EXIST(c:\Python26\python.exe)
-PYTHON="C:\Python26\python.exe"
-PATH=c:\Python26;$(PATH)
-!ELSE IF EXIST(c:\Python25\python.exe)
-PYTHON="C:\Python25\python.exe"
-PATH=c:\Python25;$(PATH)
-!ELSE IF EXIST(c:\Python24\python.exe)
-PYTHON="C:\Python24\python.exe"
-PATH=c:\Python24;$(PATH)
-!ENDIF
-!ENDIF
-
# command for lex/flexx (cygwin's flex recommended)
LEX=flex
@@ -674,6 +690,36 @@ UPX=$(WIRESHARK_LIBS)\upx303w\upx.exe
##### Flags, PATHs and Miscellaneous #####
+# Santity check: native vs Cygwin Python options
+!IF DEFINED(PYTHON) && DEFINED(PYTHON_DIR)
+!ERROR PYTHON and PYTHON_DIR cannot be specified at the same time
+!ENDIF
+
+# Find native Python automatically if PYTHON(_DIR) wasn't defined
+!IF !DEFINED(PYTHON) && !DEFINED(PYTHON_DIR)
+!IF EXIST(c:\Python26\python.exe)
+PYTHON_VER=26
+!ELSE IF EXIST(c:\Python25\python.exe)
+PYTHON_VER=25
+!ELSE IF EXIST(c:\Python24\python.exe)
+PYTHON_VER=24
+!ENDIF
+
+!IF DEFINED(PYTHON_VER)
+PYTHON_DIR=C:\Python$(PYTHON_VER)
+!ENDIF
+!ENDIF
+
+!IF DEFINED(PYTHON_DIR)
+PYTHON="$(PYTHON_DIR)\python.exe"
+PATH=$(PYTHON_DIR);$(PATH)
+!ENDIF
+
+# Santity check: Python embedding requires a valid PYTHON_DIR
+!IF DEFINED(PYTHON_EMBED) && !DEFINED(PYTHON_DIR)
+!ERROR PYTHON_EMBED requires that PYTHON_DIR is defined
+!ENDIF
+
# "convert" the MSVC variant into the required MSC compiler version
!IF "$(MSVC_VARIANT)" == "MSVC6"
MSC_VER_REQUIRED=1200
@@ -1116,6 +1162,17 @@ LUA_LIBS=
LUA_CONFIG=
!ENDIF
+!IF DEFINED(PYTHON_EMBED)
+PYTHON_CFLAGS=/I$(PYTHON_DIR)\include
+PYTHON_LIBS=$(PYTHON_DIR)\libs\python$(PYTHON_VER).lib
+# Nmake uses carets to escape special characters
+PYTHON_CONFIG=^#define HAVE_PYTHON 1
+!else
+PYTHON_CFLAGS=
+PYTHON_LIBS=
+PYTHON_CONFIG=
+!ENDIF
+
!IFDEF PORTAUDIO_DIR
# Nmake uses carets to escape special characters
PORTAUDIO_CONFIG=^#define HAVE_LIBPORTAUDIO 1
diff --git a/epan/Makefile.nmake b/epan/Makefile.nmake
index b0e2d43ed7..77f5fa026e 100644
--- a/epan/Makefile.nmake
+++ b/epan/Makefile.nmake
@@ -28,6 +28,14 @@ WSLUA_LIB=
WSLUA_DIR=
!ENDIf
+!IFDEF PYTHON_DIR
+WSPYTHON_LIB=wspython\wspython.lib
+WSPYTHON_DIR=wspython
+!ELSE
+WSPYTHON_LIB=
+WSPYTHON_DIR=
+!ENDIf
+
# For use when making libwireshark.dll
libwireshark_LIBS = \
$(GLIB_LIBS) \
@@ -39,6 +47,7 @@ libwireshark_LIBS = \
$(ZLIB_LIBS) \
$(GNUTLS_LIBS) \
$(LUA_LIBS) \
+ $(PYTHON_LIBS) \
$(SMI_LIBS) \
$(GEOIP_LIBS) \
..\wsutil\libwsutil.lib \
@@ -48,6 +57,7 @@ libwireshark_LIBS = \
ftypes\ftypes.lib \
dfilter\dfilter.lib \
$(WSLUA_LIB) \
+ $(WSPYTHON_LIB) \
dissectors\dissectors.lib
.c.obj::
@@ -67,17 +77,17 @@ DOXYGEN_DEP=doxygen
!ENDIF
!IFDEF ENABLE_LIBWIRESHARK
-all: crc crypt ftypes dfilter $(WSLUA_DIR) dissectors libwireshark.dll
+all: crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors libwireshark.dll
!ELSE
-all: crc crypt ftypes dfilter $(WSLUA_DIR) dissectors libwireshark.lib
+all: crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors libwireshark.lib
!ENDIF
# For use when making libwireshark.dll
libwireshark.lib: libwireshark.dll
libwireshark.exp: libwireshark.dll
-libwireshark.dll: ..\config.h $(LIBWIRESHARK_OBJECTS) libwireshark.def crc crypt ftypes dfilter $(WSLUA_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
- crc\crc.lib crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib dissectors\dissectors.lib $(WSLUA_LIB) ..\image\libwireshark.res
+libwireshark.dll: ..\config.h $(LIBWIRESHARK_OBJECTS) libwireshark.def crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
+ crc\crc.lib crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib dissectors\dissectors.lib $(WSLUA_LIB) $(WSPYTHON_LIB) ..\image\libwireshark.res
@echo Linking libwireshark.dll
$(link) $(dlllflags) $(conlibsdll) shell32.lib \
$(LOCAL_LDFLAGS) $(DLL_LDFLAGS) \
@@ -87,8 +97,8 @@ libwireshark.dll: ..\config.h $(LIBWIRESHARK_OBJECTS) libwireshark.def crc crypt
dissectors\register.obj \
$(EXTRA_OBJECTS)
-libwireshark.lib : ..\config.h $(LIBWIRESHARK_OBJECTS) crc crypt ftypes dfilter $(WSLUA_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
- crc\crc.lib crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib $(WSLUA_LIB) dissectors\dissectors.lib
+libwireshark.lib : ..\config.h $(LIBWIRESHARK_OBJECTS) crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
+ crc\crc.lib crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib $(WSLUA_LIB) $(WSPYTHON_LIB) dissectors\dissectors.lib
link /lib /out:libwireshark.lib $(LIBWIRESHARK_OBJECTS) \
$(EXTRA_OBJECTS)
@@ -117,6 +127,8 @@ clean: clean-local
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ../wslua
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
+ cd ../wspython
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
#
@@ -149,6 +161,8 @@ distclean: distclean-local
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
cd ../wslua
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
+ cd ../wspython
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
cd ..
maintainer-clean-local: distclean-local
@@ -166,6 +180,8 @@ maintainer-clean: maintainer-clean-local
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
cd ../wslua
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
+ cd ../wspython
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
cd ..
crc:: ..\config.h
@@ -198,6 +214,11 @@ wslua:: ..\config.h
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
cd ..
+wspython:: ..\config.h
+ cd wspython
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
+ cd ..
+
doxygen.cfg: ..\config.nmake doxygen.cfg.in
sed -e s/@VERSION@/$(VERSION)/ \
< doxygen.cfg.in > $@
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index bddcb9152b..fe9684fe4c 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -542,6 +542,7 @@ get_systemfile_dir
get_tcp_port
get_tempfile_path
get_udp_port
+get_wspython_dir
getenv_utf8
golay_decode
golay_encode
diff --git a/epan/wspython/wspy_register.c b/epan/wspython/wspy_register.c
index dd3e4fb1bc..76f4efd8f3 100644
--- a/epan/wspython/wspy_register.c
+++ b/epan/wspython/wspy_register.c
@@ -229,7 +229,7 @@ void py_dissect(tvbuff_t * tvb, packet_info * pinfo,
*/
dissector_t py_generic_dissector(void)
{
- return py_dissect;
+ return &py_dissect;
}
struct SRegisterHandoffsForeach {