File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,7 +57,15 @@ cdef class Packet:
5757 self ._given_payload = None
5858
5959 def __str__ (self ):
60- cdef iphdr * hdr = < iphdr* > self .payload
60+ cdef unsigned char * payload = NULL
61+ if self ._owned_payload:
62+ payload = self ._owned_payload
63+ elif self .payload != NULL :
64+ payload = self .payload
65+ else :
66+ return " %d byte packet, contents unretained" % (self .payload_len,)
67+
68+ cdef iphdr * hdr = < iphdr* > payload
6169 protocol = PROTOCOLS.get(hdr.protocol, " Unknown protocol" )
6270 return " %s packet, %s bytes" % (protocol, self .payload_len)
6371
Original file line number Diff line number Diff line change 33
44exec (open ("netfilterqueue/_version.py" , encoding = "utf-8" ).read ())
55
6- setup_requires = []
6+ setup_requires = ["wheel" ]
77try :
88 # Use Cython
99 from Cython .Build import cythonize
2121 if "egg_info" in sys .argv :
2222 # We're being run by pip to figure out what we need. Request cython in
2323 # setup_requires below.
24- setup_requires = ["cython" ]
24+ setup_requires + = ["cython" ]
2525 elif not os .path .exists (
2626 os .path .join (os .path .dirname (__file__ ), "netfilterqueue/_impl.c" )
2727 ):
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ async def test_comms_without_queue(harness):
2323async def test_queue_dropping (harness ):
2424 async def drop (packets , msg ):
2525 async for packet in packets :
26+ assert "UDP packet" in str (packet )
2627 if packet .get_payload ()[28 :] == msg :
2728 packet .drop ()
2829 else :
@@ -190,6 +191,7 @@ async def test_errors(harness):
190191async def test_unretained (harness ):
191192 def cb (chan , pkt ):
192193 # Can access payload within callback
194+ assert "UDP packet" in str (pkt )
193195 assert pkt .get_payload ()[- 3 :] in (b"one" , b"two" )
194196 chan .send_nowait (pkt )
195197
@@ -202,6 +204,7 @@ def cb(chan, pkt):
202204 RuntimeError , match = "Payload data is no longer available"
203205 ):
204206 p .get_payload ()
207+ assert "contents unretained" in str (p )
205208 # Can still issue verdicts though
206209 if accept :
207210 p .accept ()
You can’t perform that action at this time.
0 commit comments