itxx00 / pypcap

Automatically exported from code.google.com/p/pypcap
Other
0 stars 0 forks source link

PCAP on Python 2.7 #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Has anyone got PCAP to run on Python 2.7

Original issue reported on code.google.com by ajcbl...@glam.ac.uk on 15 Sep 2010 at 10:07

GoogleCodeExporter commented 9 years ago
Up

Original comment by tbjhdani...@gmail.com on 8 Oct 2010 at 11:05

GoogleCodeExporter commented 9 years ago
Up

Original comment by tbjhdani...@gmail.com on 8 Oct 2010 at 11:07

GoogleCodeExporter commented 9 years ago
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

Original comment by sadashiv...@gmail.com on 27 Oct 2010 at 1:57

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I get the exact same thing on Mac OS X 10.6.4 Snow Leopard ^

Original comment by crh0...@gmail.com on 28 Oct 2010 at 4:58

GoogleCodeExporter commented 9 years ago
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>

Original comment by crh0...@gmail.com on 28 Oct 2010 at 5:08

GoogleCodeExporter commented 9 years ago
Thanks for posting the info and patch in Comment 6. A tiny correction to the 
redirection- it should be

  patch < python27patch

Original comment by chris.mc...@uwa.edu.au on 15 Feb 2011 at 10:53

GoogleCodeExporter commented 9 years ago
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

Original comment by sander.j...@gmail.com on 24 May 2011 at 10:57

GoogleCodeExporter commented 9 years ago
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')):

Original comment by japr...@gmail.com on 3 Jan 2012 at 5:29

GoogleCodeExporter commented 9 years ago
look at here:http://code.google.com/p/pypcap/issues/detail?id=36

Original comment by lifuling...@126.com on 29 Feb 2012 at 4:23

GoogleCodeExporter commented 9 years ago
I got it working in Win7 x64. 

Download WinPcap 4.1.2 Developer's Pack and extract:
http://www.winpcap.org/devel.htm

Download Pyrex and install:
http://brl.thefreecat.org/python-pyrex/

Get trunk and change line 45 in setup.py 
from:
for sd in ('include/pcap', 'include', ''):
to:
for sd in ('include', 'include', ''):

Then run as admininstrator:

python setup.py config --with-pcap="C:\Downloads\WpdPack_4_1_2\WpdPack"
python "c:\Python27\Scripts\pyrexc.py" pcap.pyx
python setup.py build
python setup.py install

Original comment by markus.r...@gmail.com on 4 Jun 2012 at 4:56

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/pypcap/issues/detail?id=36
非常感谢
Tanks so much
Merci bcp

Original comment by 1989caoy...@gmail.com on 11 Oct 2013 at 3:02