summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpettai <pettai@pkgsrc.org>2010-03-13 10:20:53 +0000
committerpettai <pettai@pkgsrc.org>2010-03-13 10:20:53 +0000
commit1a81429f0115d5b252ca24b87ebeeb5dd669c023 (patch)
treeb2e8c3849e731f5aac2c87d3d00c133413b875b8
parent03b6159ae0c94316c3d9f69ec2c1eb538623b3cc (diff)
downloadpkgsrc-1a81429f0115d5b252ca24b87ebeeb5dd669c023.tar.gz
Simplified object-oriented Python extension module for libpcap -
the current tcpdump.org version, the legacy version shipping with some of the BSD operating systems, and the WinPcap port for Windows.
-rw-r--r--net/py-pcap/DESCR3
-rw-r--r--net/py-pcap/Makefile43
-rw-r--r--net/py-pcap/PLIST2
-rw-r--r--net/py-pcap/distinfo8
-rw-r--r--net/py-pcap/patches/patch-aa13
-rw-r--r--net/py-pcap/patches/patch-ab13
-rw-r--r--net/py-pcap/patches/patch-ac80
7 files changed, 162 insertions, 0 deletions
diff --git a/net/py-pcap/DESCR b/net/py-pcap/DESCR
new file mode 100644
index 00000000000..1d3d66e5c47
--- /dev/null
+++ b/net/py-pcap/DESCR
@@ -0,0 +1,3 @@
+Simplified object-oriented Python extension module for libpcap -
+the current tcpdump.org version, the legacy version shipping with some of
+the BSD operating systems, and the WinPcap port for Windows.
diff --git a/net/py-pcap/Makefile b/net/py-pcap/Makefile
new file mode 100644
index 00000000000..9e46dfb67fc
--- /dev/null
+++ b/net/py-pcap/Makefile
@@ -0,0 +1,43 @@
+# $NetBSD: Makefile,v 1.1.1.1 2010/03/13 10:20:53 pettai Exp $
+#
+
+DISTNAME= pypcap-1.1
+PKGNAME= ${PYPKGPREFIX}-pcap-1.1
+CATEGORIES= net python
+MASTER_SITES= http://pypcap.googlecode.com/files/
+
+MAINTAINER= pettai@NetBSD.org
+HOMEPAGE= http://code.google.com/p/pypcap/
+COMMENT= Simplified object-oriented python module for libpcap
+LICENSE= modified-bsd
+
+PKG_DESTDIR_SUPPORT= user-destdir
+
+BUILD_DEPENDS+= ${PYPKGPREFIX}-pyrex-[0-9]*:../../lang/py-pyrex
+
+SUBST_CLASSES+= python
+SUBST_FILES.python= Makefile
+SUBST_SED.python+= -e 's,@PYTHON@,${PYTHONBIN},g'
+SUBST_STAGE.python= post-patch
+SUBST_CLASSES+= prefix
+SUBST_FILES.prefix= Makefile
+SUBST_SED.prefix= -e "s|@PREFIX@|${PREFIX}|g"
+SUBST_STAGE.prefix= post-patch
+
+PYDISTUTILSPKG= yes
+
+FILES_SUBST+= PYTHONBIN=${PYTHONBIN:Q}
+
+pre-configure:
+ cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} \
+ pyrexc pcap.pyx
+
+do-configure:
+ cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} \
+ ${PYTHONBIN} setup.py config
+ # --with-pcap=${PREFIX}
+
+.include "../../net/libpcap/buildlink3.mk"
+.include "../../lang/python/extension.mk"
+.include "../../lang/python/application.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/net/py-pcap/PLIST b/net/py-pcap/PLIST
new file mode 100644
index 00000000000..a1ac170dde8
--- /dev/null
+++ b/net/py-pcap/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2010/03/13 10:20:53 pettai Exp $
+${PYSITELIB}/pcap.so
diff --git a/net/py-pcap/distinfo b/net/py-pcap/distinfo
new file mode 100644
index 00000000000..a35e5e650ac
--- /dev/null
+++ b/net/py-pcap/distinfo
@@ -0,0 +1,8 @@
+$NetBSD: distinfo,v 1.1.1.1 2010/03/13 10:20:53 pettai Exp $
+
+SHA1 (pypcap-1.1.tar.gz) = 966f62deca16d5086e2ef6694b0c795f273da15c
+RMD160 (pypcap-1.1.tar.gz) = 119dcc393d42678e6fa8f0b0f8b82536ab1efb13
+Size (pypcap-1.1.tar.gz) = 22951 bytes
+SHA1 (patch-aa) = 6fb58b55262a9b28bdc9e681b3b3ea07523bd8e3
+SHA1 (patch-ab) = 7d25548cd3c87d74b6e6ca1b080c32b07ece25eb
+SHA1 (patch-ac) = 4a4f28578b27b4605787ea566217397bf60fdea8
diff --git a/net/py-pcap/patches/patch-aa b/net/py-pcap/patches/patch-aa
new file mode 100644
index 00000000000..17ab570379a
--- /dev/null
+++ b/net/py-pcap/patches/patch-aa
@@ -0,0 +1,13 @@
+$NetBSD: patch-aa,v 1.1.1.1 2010/03/13 10:20:53 pettai Exp $
+
+--- setup.py.orig 2010-02-13 22:48:07.000000000 +0100
++++ setup.py 2010-02-13 22:48:31.000000000 +0100
+@@ -42,7 +42,7 @@
+ dirs = [ '/usr', sys.prefix ] + glob.glob('/opt/libpcap*') + \
+ glob.glob('../libpcap*') + glob.glob('../wpdpack*')
+ for d in dirs:
+- for sd in ('include', 'include/pcap', ''):
++ for sd in ('include/pcap', 'include', ''):
+ 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) ]
diff --git a/net/py-pcap/patches/patch-ab b/net/py-pcap/patches/patch-ab
new file mode 100644
index 00000000000..9dd7a0d2ec6
--- /dev/null
+++ b/net/py-pcap/patches/patch-ab
@@ -0,0 +1,13 @@
+$NetBSD: patch-ab,v 1.1.1.1 2010/03/13 10:20:53 pettai Exp $
+
+--- Makefile.orig 2005-10-17 02:08:17.000000000 +0200
++++ Makefile 2010-02-14 17:31:22.000000000 +0100
+@@ -2,7 +2,7 @@
+
+-PYTHON = python
+-#CONFIG_ARGS = --with-pcap=$(HOME)/build/libpcap-0.8.3
++PYTHON = @PYTHON@
++#CONFIG_ARGS = --with-pcap=@PREFIX@
+
+ # PYTHON = C:\\Python23\\python.exe
+ # CONFIG_ARGS = --with-pcap=..\\wpdpack
diff --git a/net/py-pcap/patches/patch-ac b/net/py-pcap/patches/patch-ac
new file mode 100644
index 00000000000..867cebc0d36
--- /dev/null
+++ b/net/py-pcap/patches/patch-ac
@@ -0,0 +1,80 @@
+$NetBSD: patch-ac,v 1.1.1.1 2010/03/13 10:20:53 pettai Exp $
+
+# Apply in SVN repo fixes
+#
+
+--- pcap.pyx.orig 2005-10-17 01:00:11.000000000 +0200
++++ pcap.pyx 2010-02-14 17:49:27.000000000 +0100
+@@ -20,6 +20,7 @@
+
+ cdef extern from "Python.h":
+ object PyBuffer_FromMemory(char *s, int len)
++ int PyObject_AsCharBuffer(object obj, char **buffer, int *buffer_len)
+ int PyGILState_Ensure()
+ void PyGILState_Release(int gil)
+ void Py_BEGIN_ALLOW_THREADS()
+@@ -134,16 +135,18 @@
+ raise IOError, 'bad filter'
+ def filter(self, buf):
+ """Return boolean match for buf against our filter."""
++ cdef char *p
+ cdef int n
+- n = len(buf)
+- if bpf_filter(self.fcode.bf_insns, buf, n, n) == 0:
++ if PyObject_AsCharBuffer(buf, &p, &n) < 0:
++ raise TypeError
++ if bpf_filter(self.fcode.bf_insns, p, n, n) == 0:
+ return False
+ return True
+ def __dealloc__(self):
+ pcap_freecode(&self.fcode)
+
+ cdef class pcap:
+- """pcap(name=None, snaplen=65535, promisc=True, immediate=False) -> packet capture object
++ """pcap(name=None, snaplen=65535, promisc=True, immediate=False, timeout_ms=None) -> packet capture object
+
+ Open a handle to a packet capture descriptor.
+
+@@ -153,15 +156,19 @@
+ snaplen -- maximum number of bytes to capture for each packet
+ promisc -- boolean to specify promiscuous mode sniffing
+ immediate -- disable buffering, if possible
++ timeout_ms -- requests for the next packet will return None if the timeout
++ (in milliseconds) is reached and no packets were received
++ (Default: no timeout)
+ """
+ cdef pcap_t *__pcap
+ cdef char *__name
+ cdef char *__filter
+ cdef char __ebuf[256]
+ cdef int __dloff
++ cdef int __timeout_returns_none
+
+ def __init__(self, name=None, snaplen=65535, promisc=True,
+- timeout_ms=500, immediate=False):
++ timeout_ms=None, immediate=False):
+ global dltoff
+ cdef char *p
+
+@@ -172,6 +179,12 @@
+ else:
+ p = name
+
++ if timeout_ms is None:
++ timeout_ms = 500
++ self.__timeout_returns_none = 0
++ else:
++ self.__timeout_returns_none = 1
++
+ self.__pcap = pcap_open_offline(p, self.__ebuf)
+ if not self.__pcap:
+ self.__pcap = pcap_open_live(pcap_ex_name(p), snaplen, promisc,
+@@ -340,6 +353,8 @@
+ if n == 1:
+ return (hdr.ts.tv_sec + (hdr.ts.tv_usec / 1000000.0),
+ PyBuffer_FromMemory(pkt, hdr.caplen))
++ elif n == 0 and self.__timeout_returns_none == 1:
++ return (hdr.ts.tv_sec + (hdr.ts.tv_usec / 1000000.0), None)
+ elif n == -1:
+ raise KeyboardInterrupt
+ elif n == -2: