int dispatch ( maxcant,
(* callback));
int maxcant ;
void (* callback) (Pkthdr, string) ;
callback specifies a routine to be called with two arguments: a Pkthdr instance describing the data passed and the data itself.
На деле функции никакие аргументы не передаются:
In [238]: import pcapy
In [239]: reader = pcapy.open_offline(my_pcap_file)
In [240]: reader.dispatch(-1, lambda hdr, data: print(hdr.caplen()))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: <lambda>() missing 2 required positional arguments: 'hdr' and 'data'
The above exception was the direct cause of the following exception:
SystemError Traceback (most recent call last)
<ipython-input-240-c10b6d091522> in <module>
----> 1 reader.dispatch(-1, lambda hdr, data: print(hdr.caplen()))
SystemError: <built-in method dispatch of Reader object at 0x7fad32317a90> returned a result with an exception set
Очевидно, что ошибка где-то здесь: https://github.com/stamparm/pcapy-ng/blob/master/pcapobj.cc
т.к. в CL у которого plokami:capture поверх того же pcap_dispatch всё работает на ура:
CL-USER> (block b
(plokami:with-pcap-reader (reader *my-pcap-file*)
(plokami:set-filter reader "udp")
(plokami:capture reader -1
(lambda (sec usec caplen len buffer)
(declare (ignore sec usec buffer))
(when (/= caplen len)
(return-from b nil))
(format t "Packet length: ~A bytes, on the wire: ~A bytes~%"
caplen len))))
t)
Packet length: 76 bytes, on the wire: 76 bytes
Packet length: 76 bytes, on the wire: 76 bytes
Packet length: 92 bytes, on the wire: 92 bytes
Packet length: 135 bytes, on the wire: 135 bytes
Packet length: 76 bytes, on the wire: 76 bytes
Packet length: 92 bytes, on the wire: 92 bytes
Packet length: 74 bytes, on the wire: 74 bytes
Packet length: 74 bytes, on the wire: 74 bytes
Packet length: 173 bytes, on the wire: 173 bytes
Packet length: 197 bytes, on the wire: 197 bytes
Packet length: 84 bytes, on the wire: 84 bytes
Packet length: 84 bytes, on the wire: 84 bytes
Packet length: 144 bytes, on the wire: 144 bytes
Packet length: 156 bytes, on the wire: 156 bytes
Packet length: 76 bytes, on the wire: 76 bytes
Packet length: 92 bytes, on the wire: 92 bytes
Packet length: 79 bytes, on the wire: 79 bytes
Packet length: 79 bytes, on the wire: 79 bytes
Packet length: 95 bytes, on the wire: 95 bytes
Packet length: 107 bytes, on the wire: 107 bytes
Packet length: 72 bytes, on the wire: 72 bytes
Packet length: 72 bytes, on the wire: 72 bytes
Packet length: 152 bytes, on the wire: 152 bytes
Packet length: 100 bytes, on the wire: 100 bytes
Packet length: 76 bytes, on the wire: 76 bytes
Packet length: 92 bytes, on the wire: 92 bytes
T