Skip to content

Commit 96d612b

Browse files
authored
Fix compile_filter on *BSD with non-ether linktypes (#4670)
* Fix compile_filter on *BSD with non-ether linktypes * Populate iface.type on the *BSDs * Fix IEEE802 ARP->DLT
1 parent d61ab7b commit 96d612b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

scapy/arch/bpf/pfroute.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,11 +1234,13 @@ def _get_if_list():
12341234
ifindex = msg.ifm_index
12351235
ifname = None
12361236
mac = "00:00:00:00:00:00"
1237+
itype = -1
12371238
ifflags = msg.ifm_flags
12381239
ips = []
12391240
for addr in msg.addrs:
12401241
if addr.sa_family == socket.AF_LINK:
12411242
ifname = addr.sdl_iface.decode()
1243+
itype = addr.sdl_type
12421244
if addr.sdl_addr:
12431245
mac = addr.sdl_addr
12441246
if ifname is not None:
@@ -1250,5 +1252,6 @@ def _get_if_list():
12501252
"flags": ifflags,
12511253
"mac": mac,
12521254
"ips": ips,
1255+
"type": itype,
12531256
}
12541257
return interfaces

scapy/arch/common.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import socket
1313

1414
from scapy.config import conf
15-
from scapy.data import MTU, ARPHDR_ETHER, ARPHRD_TO_DLT
15+
from scapy.data import MTU, ARPHRD_TO_DLT
1616
from scapy.error import Scapy_Exception, warning
1717
from scapy.interfaces import network_name, resolve_iface, NetworkInterface
1818
from scapy.libs.structures import bpf_program
@@ -105,8 +105,6 @@ def compile_filter(filter_exp, # type: str
105105
except Exception:
106106
# Failed to use linktype: use the interface
107107
pass
108-
if not linktype and conf.use_bpf:
109-
linktype = ARPHDR_ETHER
110108
if linktype is not None:
111109
ret = pcap_compile_nopcap(
112110
MTU, linktype, ctypes.byref(bpf), bpf_filter, 1, -1

scapy/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
ARPHRD_CHAOS: DLT_CHAOS,
203203
ARPHRD_CAN: DLT_LINUX_SLL,
204204
ARPHRD_IEEE802_TR: DLT_IEEE802,
205-
ARPHRD_IEEE802: DLT_IEEE802,
205+
ARPHRD_IEEE802: DLT_EN10MB,
206206
ARPHRD_ARCNET: DLT_ARCNET_LINUX,
207207
ARPHRD_FDDI: DLT_FDDI,
208208
ARPHRD_ATM: -1,

0 commit comments

Comments
 (0)