Merge pull request #26 from kti/25-Crash-in-iptables-OUTPUT-chain
25 crash in iptables output chain
This commit is contained in:
commit
db750b7212
|
@ -81,9 +81,8 @@ From source
|
|||
|
||||
To install from source::
|
||||
|
||||
wget https://pypi.python.org/packages/94/5b/83d10952c1312fe056f8f2f524a4a59fdc9d56b84a67cae1ed779e2da50b/NetfilterQueue-0.8.tar.gz#md5=8e78db992ad3a73dd86fef05293fff65
|
||||
tar -xvzf NetfilterQueue-0.8.tar.gz
|
||||
cd NetfilterQueue-0.8
|
||||
git clone git@github.com:kti/python-netfilterqueue.git
|
||||
cd python-netfilterqueue
|
||||
python setup.py install
|
||||
|
||||
If Cython is installed, Distutils will use it to regenerate the .c source from the .pyx. It will then compile the .c into a .so.
|
||||
|
|
|
@ -3,6 +3,9 @@ from netfilterqueue import NetfilterQueue
|
|||
|
||||
def print_and_accept(pkt):
|
||||
print(pkt)
|
||||
hw = pkt.get_hw()
|
||||
if hw:
|
||||
print(":".join("{:02x}".format(ord(c)) for c in hw[0:6]))
|
||||
pkt.accept()
|
||||
|
||||
nfqueue = NetfilterQueue()
|
||||
|
|
969
netfilterqueue.c
969
netfilterqueue.c
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,7 @@ function.
|
|||
Copyright: (c) 2011, Kerkhoff Technologies Inc.
|
||||
License: MIT; see LICENSE.txt
|
||||
"""
|
||||
VERSION = (0, 8, 0)
|
||||
VERSION = (0, 8, 1)
|
||||
|
||||
# Constants for module users
|
||||
COPY_NONE = 0
|
||||
|
@ -57,12 +57,10 @@ cdef class Packet:
|
|||
self._qh = qh
|
||||
self._nfa = nfa
|
||||
self._hdr = nfq_get_msg_packet_hdr(nfa)
|
||||
self._hw = nfq_get_packet_hw(nfa)
|
||||
|
||||
self.id = ntohl(self._hdr.packet_id)
|
||||
self.hw_protocol = ntohs(self._hdr.hw_protocol)
|
||||
self.hook = self._hdr.hook
|
||||
self.hw_addr = self._hw.hw_addr
|
||||
|
||||
self.payload_len = nfq_get_payload(self._nfa, &self.payload)
|
||||
if self.payload_len < 0:
|
||||
|
@ -101,6 +99,11 @@ cdef class Packet:
|
|||
|
||||
def get_hw(self):
|
||||
"""Return the hardware address as Python string."""
|
||||
self._hw = nfq_get_packet_hw(self._nfa)
|
||||
if self._hw == NULL:
|
||||
# nfq_get_packet_hw doesn't work on OUTPUT and PREROUTING chains
|
||||
return None
|
||||
self.hw_addr = self._hw.hw_addr
|
||||
cdef object py_string
|
||||
if cpython.version.PY_MAJOR_VERSION >= 3:
|
||||
py_string = PyBytes_FromStringAndSize(<char*>self.hw_addr, 8)
|
||||
|
|
Loading…
Reference in New Issue