aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authoryuri <yuri@FreeBSD.org>2018-02-25 07:41:25 +0800
committeryuri <yuri@FreeBSD.org>2018-02-25 07:41:25 +0800
commit31659bac8b022ed07b16a819ef4cb180b9493ec1 (patch)
tree6ad0e792e2be6361a3664784282dbd336926d528 /net
parentcf723caa1adc5b0a44237fd7a3cf7359e8fc0192 (diff)
downloadfreebsd-ports-gnome-31659bac8b022ed07b16a819ef4cb180b9493ec1.tar.gz
freebsd-ports-gnome-31659bac8b022ed07b16a819ef4cb180b9493ec1.tar.zst
freebsd-ports-gnome-31659bac8b022ed07b16a819ef4cb180b9493ec1.zip
net/py-pypcap: Update to 1.2.0
Maintainer's timeout expired wxs@. Additiojnal port changes: * Source from CHEESESHOP instead of GH * Removed LICENSE_FILE (not available) * Added USE_PYTHON=cython (instead of pyrex) * Removed post-patch * Now works for all python versions * Updated WWW PR: 223864 Reported by: yuri Approved by: portmgr (maintainer timeout, 14 days) Approved by: tcberner (mentor, implicit)
Diffstat (limited to 'net')
-rw-r--r--net/py-pypcap/Makefile20
-rw-r--r--net/py-pypcap/distinfo6
-rw-r--r--net/py-pypcap/files/patch-pcap.pyx212
-rw-r--r--net/py-pypcap/files/patch-setup.py22
-rw-r--r--net/py-pypcap/pkg-descr2
5 files changed, 9 insertions, 253 deletions
diff --git a/net/py-pypcap/Makefile b/net/py-pypcap/Makefile
index 239af98aa39b..94243fd1a5fa 100644
--- a/net/py-pypcap/Makefile
+++ b/net/py-pypcap/Makefile
@@ -2,31 +2,21 @@
# $FreeBSD$
PORTNAME= pypcap
-DISTVERSIONPREFIX= ${PORTNAME:tu}_
-DISTVERSION= 1_1
-PORTREVISION= 6
+DISTVERSION= 1.2.0
CATEGORIES= net python
+MASTER_SITES= CHEESESHOP
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
MAINTAINER= wxs@FreeBSD.org
COMMENT= Simplified object-oriented Python extension module for libpcap
LICENSE= BSD3CLAUSE
-LICENSE_FILE= ${WRKSRC}/LICENSE
-BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pyrex>0:devel/pyrex@${FLAVOR}
-
-USE_GITHUB= yes
-GH_ACCOUNT= dugsong
-
-USES= python:2.7
-USE_PYTHON= distutils autoplist
-
-post-patch:
- @${RM} ${WRKDIR}/${PORTNAME}-${PORTVERSION}/pcap.c
+USES= python
+USE_PYTHON= distutils cython autoplist
pre-build:
- (cd ${WRKSRC}; pyrexc pcap.pyx)
+ @cd ${WRKSRC} && cython-${PYTHON_VER} pcap.pyx
post-install:
@${STRIP_CMD} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/pcap.so
diff --git a/net/py-pypcap/distinfo b/net/py-pypcap/distinfo
index 8cae8e433709..3c71f1bee189 100644
--- a/net/py-pypcap/distinfo
+++ b/net/py-pypcap/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1493813267
-SHA256 (dugsong-pypcap-PYPCAP_1_1_GH0.tar.gz) = a75d165f70a71e6c14c46b77c1b9b7a395fa425d0f90a2e342e641c66c14e634
-SIZE (dugsong-pypcap-PYPCAP_1_1_GH0.tar.gz) = 22812
+TIMESTAMP = 1519513659
+SHA256 (pypcap-1.2.0.tar.gz) = 6981b95a975cb964806899735319ca71cfd0b5a4e9f9a45970b558f49eec0158
+SIZE (pypcap-1.2.0.tar.gz) = 123971
diff --git a/net/py-pypcap/files/patch-pcap.pyx b/net/py-pypcap/files/patch-pcap.pyx
deleted file mode 100644
index f0aa06856fc7..000000000000
--- a/net/py-pypcap/files/patch-pcap.pyx
+++ /dev/null
@@ -1,212 +0,0 @@
---- pcap.pyx.orig 2005-10-17 00:08:17 UTC
-+++ pcap.pyx
-@@ -17,9 +17,11 @@ __url__ = 'http://monkey.org/~dugsong/py
- __version__ = '1.1'
-
- import sys
-+import struct
-
- 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()
-@@ -42,6 +44,10 @@ cdef extern from "pcap.h":
- unsigned int caplen
- ctypedef struct pcap_t:
- int __xxx
-+ ctypedef struct pcap_if_t # hack for win32
-+ ctypedef struct pcap_if_t:
-+ pcap_if_t *next
-+ char *name
-
- ctypedef void (*pcap_handler)(void *arg, pcap_pkthdr *hdr, char *pkt)
-
-@@ -62,6 +68,13 @@ cdef extern from "pcap.h":
- char *pcap_geterr(pcap_t *p)
- void pcap_close(pcap_t *p)
- int bpf_filter(bpf_insn *insns, char *buf, int len, int caplen)
-+ int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
-+ void pcap_freealldevs(pcap_if_t *alldevs)
-+ int pcap_lookupnet(char *device,
-+ unsigned int *netp,
-+ unsigned int *maskp,
-+ char *errbuf)
-+ int pcap_sendpacket(pcap_t *p, char *buf, int size)
-
- cdef extern from "pcap_ex.h":
- # XXX - hrr, sync with libdnet and libevent
-@@ -134,16 +147,18 @@ cdef class bpf:
- 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, timeout_ms=None, immediate=False) -> packet capture object
-
- Open a handle to a packet capture descriptor.
-
-@@ -152,6 +167,9 @@ cdef class pcap:
- or None to open the first available up interface
- snaplen -- maximum number of bytes to capture for each packet
- promisc -- boolean to specify promiscuous mode sniffing
-+ 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)
- immediate -- disable buffering, if possible
- """
- cdef pcap_t *__pcap
-@@ -161,7 +179,7 @@ cdef class pcap:
- cdef int __dloff
-
- def __init__(self, name=None, snaplen=65535, promisc=True,
-- timeout_ms=500, immediate=False):
-+ timeout_ms=0, immediate=False):
- global dltoff
- cdef char *p
-
-@@ -171,7 +189,7 @@ cdef class pcap:
- raise OSError, self.__ebuf
- else:
- p = name
--
-+
- self.__pcap = pcap_open_offline(p, self.__ebuf)
- if not self.__pcap:
- self.__pcap = pcap_open_live(pcap_ex_name(p), snaplen, promisc,
-@@ -184,7 +202,7 @@ cdef class pcap:
- try: self.__dloff = dltoff[pcap_datalink(self.__pcap)]
- except KeyError: pass
- if immediate and pcap_ex_immediate(self.__pcap) < 0:
-- raise OSError, "couldn't set BPF immediate mode"
-+ raise OSError, "couldn't enable immediate mode"
-
- property name:
- """Network interface or dumpfile name."""
-@@ -243,16 +261,6 @@ cdef class pcap:
- """Return datalink type (DLT_* values)."""
- return pcap_datalink(self.__pcap)
-
-- def next(self):
-- """Return the next (timestamp, packet) tuple, or None on error."""
-- cdef pcap_pkthdr hdr
-- cdef char *pkt
-- pkt = <char *>pcap_next(self.__pcap, &hdr)
-- if not pkt:
-- return None
-- return (hdr.ts.tv_sec + (hdr.ts.tv_usec / 1000000.0),
-- PyBuffer_FromMemory(pkt, hdr.caplen))
--
- def __add_pkts(self, ts, pkt, pkts):
- pkts.append((ts, pkt))
-
-@@ -288,18 +296,24 @@ cdef class pcap:
- raise exc[0], exc[1], exc[2]
- return n
-
-- def loop(self, callback, *args):
-- """Loop forever, processing packets with a user callback.
-- The loop can be exited with an exception, including KeyboardInterrupt.
-+ def loop(self, cnt, callback, *args):
-+ """Processing packets with a user callback during a loop.
-+ The loop can be exited when cnt value is reached
-+ or with an exception, including KeyboardInterrupt.
-
- Arguments:
-
-+ cnt -- number of packets to process;
-+ 0 or -1 to process all packets until an error occurs,
-+ EOF is reached;
- callback -- function with (timestamp, pkt, *args) prototype
- *args -- optional arguments passed to callback on execution
- """
- cdef pcap_pkthdr *hdr
- cdef char *pkt
- cdef int n
-+ cdef int i
-+ i = 1
- pcap_ex_setup(self.__pcap)
- while 1:
- Py_BEGIN_ALLOW_THREADS
-@@ -308,10 +322,22 @@ cdef class pcap:
- if n == 1:
- callback(hdr.ts.tv_sec + (hdr.ts.tv_usec / 1000000.0),
- PyBuffer_FromMemory(pkt, hdr.caplen), *args)
-+ elif n == 0:
-+ break
- elif n == -1:
- raise KeyboardInterrupt
- elif n == -2:
- break
-+ if i == cnt:
-+ break
-+ i = i + 1
-+
-+ def sendpacket(self, buf):
-+ """Send a raw network packet on the interface."""
-+ ret = pcap_sendpacket(self.__pcap, buf, len(buf))
-+ if ret == -1:
-+ raise OSError, pcap_geterr(self.__pcap)
-+ return len(buf)
-
- def geterr(self):
- """Return the last error message associated with this handle."""
-@@ -340,6 +366,8 @@ cdef class pcap:
- if n == 1:
- return (hdr.ts.tv_sec + (hdr.ts.tv_usec / 1000000.0),
- PyBuffer_FromMemory(pkt, hdr.caplen))
-+ elif n == 0:
-+ return None
- elif n == -1:
- raise KeyboardInterrupt
- elif n == -2:
-@@ -364,3 +392,36 @@ def lookupdev():
- raise OSError, ebuf
- return p
-
-+def findalldevs():
-+ """Return a list of capture devices."""
-+ cdef pcap_if_t *devs, *curr
-+ cdef char ebuf[256]
-+
-+ status = pcap_findalldevs(&devs, ebuf)
-+ if status:
-+ raise OSError(ebuf)
-+ retval = []
-+ if not devs:
-+ return retval
-+ curr = devs
-+ while 1:
-+ retval.append(curr.name)
-+ if not curr.next:
-+ break
-+ curr = curr.next
-+ pcap_freealldevs(devs)
-+ return retval
-+
-+def lookupnet(char *dev):
-+ """
-+ Return the address and the netmask of a given device
-+ as network-byteorder integers.
-+ """
-+ cdef unsigned int netp
-+ cdef unsigned int maskp
-+ cdef char ebuf[256]
-+
-+ status = pcap_lookupnet(dev, &netp, &maskp, ebuf)
-+ if status:
-+ raise OSError(ebuf)
-+ return struct.pack('I', netp), struct.pack('I', maskp)
diff --git a/net/py-pypcap/files/patch-setup.py b/net/py-pypcap/files/patch-setup.py
deleted file mode 100644
index ebfc9cc94c64..000000000000
--- a/net/py-pypcap/files/patch-setup.py
+++ /dev/null
@@ -1,22 +0,0 @@
---- setup.py.orig 2005-10-17 00:08:17 UTC
-+++ setup.py
-@@ -25,7 +25,10 @@ class config_pcap(config.config):
- d = {}
- if os.path.exists(os.path.join(cfg['include_dirs'][0], 'pcap-int.h')):
- d['HAVE_PCAP_INT_H'] = 1
-- buf = open(os.path.join(cfg['include_dirs'][0], 'pcap.h')).read()
-+ if int(os.uname()[2].split('.')[0]) >= 8:
-+ buf = open(os.path.join(cfg['include_dirs'][1], 'pcap.h')).read()
-+ else:
-+ buf = open(os.path.join(cfg['include_dirs'][0], 'pcap.h')).read()
- if buf.find('pcap_file(') != -1:
- d['HAVE_PCAP_FILE'] = 1
- if buf.find('pcap_compile_nopcap(') != -1:
-@@ -46,6 +49,7 @@ class config_pcap(config.config):
- 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) ]
-+ cfg['include_dirs'].append(os.path.join(d, 'include/pcap'))
- for sd in ('lib', ''):
- for lib in (('pcap', 'libpcap.a'),
- ('pcap', 'libpcap.dylib'),
diff --git a/net/py-pypcap/pkg-descr b/net/py-pypcap/pkg-descr
index 1f22afd7bbcb..6dfd0c495b10 100644
--- a/net/py-pypcap/pkg-descr
+++ b/net/py-pypcap/pkg-descr
@@ -1,3 +1,3 @@
A simplified object-oriented Python extension module for libpcap
-WWW: https://github.com/dugsong/pypcap
+WWW: https://github.com/pynetwork/pypcap