pcapy
pcapy copied to clipboard
Not working on Python3.10
Because of ignored problems with DeprecationWarning for PY_SSIZE_T_CLEAN (#67, #68), Pcapy doesn't work anymore on Python3.10 (Note: read https://docs.python.org/3.10/whatsnew/3.10.html#id2)
Minimalistic example which fails:
import pcapy
def recv(header, packet):
sec, usec = header.getts()
print(sec)
cap = pcapy.open_live("any", 65535, True, 100)
cap.loop(-1, recv)

https://pypi.org/project/pcapy-ng/ (tl;dr: just do the pip install pcapy-ng)
You can also try https://github.com/segevfiner/cypcap which is a different project I wrote out of frustration with existing ones, and boredom 😛