Incorrect Exception when linktype conflict with filter
Brief description
when I using Asnysniffer with filter, sometime the program will blocked at compile_filter, then when I stop Asynsniffer, there is no attribute stop_cb.
Scapy version
2.6.0
Python version
3.11
Operating system
ubuntu 20.04
Additional environment information
No response
How to reproduce
- enable Asynsniffer
- send some packet with scapy
- stop Asynsniffer
Actual result
have no attribute stop_cb
Expected result
have no error when finished sniffer capture
Related resources
No response
reproduce step:
from scapy.sendrecv import AsyncSniffer
import time
count = 0
sniffer = AsyncSniffer(iface='eth0', filter='wlan type mgt subtype deauth')
sniffer.start()
time.sleep(1)
sniffer.stop()
print(f'success {count}')
expect result is raise Scapy_Exception(scapy.error.Scapy_Exception: Cannot set filter real result is raise Scapy_Exception(scapy.error.Scapy_Exception: Unsupported (offline or unsupported socket)
This also hit me, when I had a typo in the filter:
sniffy = AsyncSniffer(iface="wlp0s20f3", filter="not arpand not port 22")
See: https://stackoverflow.com/q/79766638/21826195
Took some time to figure it out, because the same error also arises from timing issues: https://stackoverflow.com/q/70559382/21826195