您的位置:首页 > 编程语言 > Python开发

PCAP on Python 2.7

2012-04-24 10:19 281 查看
原文:http://code.google.com/p/pypcap/issues/detail?id=27

Reported by
ajcbl...@glam.ac.uk, Sep 15, 2010

Has anyone got PCAP to run on Python 2.7


Comment
1 by
tbjhdani...@gmail.com,
Oct 8, 2010
Up


Comment
2 by
tbjhdani...@gmail.com,
Oct 8, 2010
Up


Comment
3 by
sadashiv...@gmail.com,
Oct 27, 2010
Not up yet... I'm getting following error with latest download

gcc -pthread -fno-strict-aliasing -g -O2 -g -O0 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pcap_ex.c -o build/temp.linux-i686-2.7-pydebug/pcap_ex.o
pcap_ex.c:22:20: error: config.h: No such file or directory
pcap_ex.c: In function ‘pcap_ex_fileno’:
pcap_ex.c:165: error: dereferencing pointer to incomplete type
pcap_ex.c: In function ‘pcap_ex_next’:
pcap_ex.c:253: error: dereferencing pointer to incomplete type
pcap_ex.c: In function ‘pcap_ex_compile_nopcap’:
pcap_ex.c:285: warning: implicit declaration of function ‘mktemp’
error: command 'gcc' failed with exit status 1


Comment
5 by
crh0...@gmail.com,
Oct 27, 2010
I get the exact same thing on Mac OS X 10.6.4 Snow Leopard ^


Comment
6 by
crh0...@gmail.com,
Oct 27, 2010
Ok, I think I found a solution.  Someone posted a patch here http://trac.umitproject.org/ticket/328 that seems to work!  Save the following text to "python27patch" or whatever you want, save it in the same directory as the source code, and type: patch > python27patch.  Then just do python setup.py build, pythonsetup.py install, worked for me.

Index: pcap_ex.c
===================================================================
--- pcap_ex.c	(revision 85)
+++ pcap_ex.c	(working copy)
@@ -12,7 +12,7 @@
# include <signal.h>
# include <unistd.h>
#endif
-
+#define HAVE_PCAP_FILE
#include <pcap.h>
#ifdef HAVE_PCAP_INT_H
# include <pcap-int.h>


Comment
7 by
ch...@csse.uwa.edu.au,
Feb 15, 2011
Thanks for posting the info and patch in Comment 6. A tiny correction to the redirection- it should be

patch < python27patch


Comment
8 by
sander.j...@gmail.com,
May 24, 2011
Hi,

I can confirm adding the line "#define HAVE_PCAP_FILE" to pcap_ex.c (from pypcap-1.1) solves the error message below. (FWIW: Ubuntu 11.04, python 2.7)

pcap.c:28:12: warning: ‘__Pyx_SetVtable’ declared ‘static’ but never defined
pcap.c:29:12: warning: ‘__Pyx_GetVtable’ declared ‘static’ but never defined
pcap.c:30:18: warning: ‘__Pyx_CreateClass’ declared ‘static’ but never defined
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include -I/usr/include/python2.7 -c pcap_ex.c -o build/temp.linux-x86_64-2.7/pcap_ex.o
pcap_ex.c: In function ‘pcap_ex_fileno’:
pcap_ex.c:165:16: error: dereferencing pointer to incomplete type
pcap_ex.c: In function ‘pcap_ex_next’:
pcap_ex.c:253:12: error: dereferencing pointer to incomplete type
pcap_ex.c: In function ‘pcap_ex_compile_nopcap’:
pcap_ex.c:285:2: warning: implicit declaration of function ‘mktemp’
error: command 'gcc' failed with exit status 1
make: *** [all] Error 1


Comment
9 by
japr...@gmail.com,
Jan 3, 2012
I had to use this patch in addition to the one above, to work with Ubuntu 10.11 (oneiric):

--- setup.py	2005-10-16 19:07:03.000000000 -0400
+++ setup.py	2012-01-03 12:22:04.761298898 -0500
@@ -46,7 +46,7 @@
incdirs = [ os.path.join(d, sd) ]
if os.path.exists(os.path.join(d, sd, 'pcap.h')):
cfg['include_dirs'] = [ os.path.join(d, sd) ]
-                    for sd in ('lib', ''):
+                    for sd in ('lib', 'lib/i386-linux-gnu'):
for lib in (('pcap', 'libpcap.a'),
('pcap', 'libpcap.dylib'),
('wpcap', 'wpcap.lib')):


Comment
10 by
lifuling...@126.com,
Feb 28, 2012
look at here:http://code.google.com/p/pypcap/issues/detail?id=36
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: