Skip to content

Commit ce406ff

Browse files
committed
fix: Revert to srp1 with BPF filter
1 parent 08dd8c2 commit ce406ff

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

scapy/layers/inet6.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117

118118

119119
@conf.commands.register
120-
def neighsol(addr, src, iface, timeout=1, chainCC=False):
120+
def neighsol(addr, src, iface, timeout=1, chainCC=0):
121121
"""Sends and receive an ICMPv6 Neighbor Solicitation message
122122
123123
This function sends an ICMPv6 Neighbor Solicitation message
@@ -139,26 +139,10 @@ def neighsol(addr, src, iface, timeout=1, chainCC=False):
139139
p = Ether(dst=dm, src=sm) / IPv6(dst=d, src=src, hlim=255)
140140
p /= ICMPv6ND_NS(tgt=addr)
141141
p /= ICMPv6NDOptSrcLLAddr(lladdr=sm)
142+
res = srp1(p, type=ETH_P_IPV6, iface=iface, timeout=timeout, verbose=0,
143+
filter="ip6[7] == 255", chainCC=chainCC)
142144

143-
def _match(pkt):
144-
return (
145-
IPv6 in pkt and ICMPv6ND_NA in pkt and
146-
pkt[IPv6].hlim == 255 and
147-
pkt[ICMPv6ND_NA].tgt == addr
148-
)
149-
150-
matches = sniff(
151-
iface=iface,
152-
timeout=timeout,
153-
lfilter=_match,
154-
started_callback=lambda: sendp(p, type=ETH_P_IPV6, iface=iface, verbose=0),
155-
count=1,
156-
chainCC=chainCC
157-
)
158-
159-
if matches:
160-
return matches[0]
161-
return None
145+
return res
162146

163147

164148
@conf.commands.register

0 commit comments

Comments
 (0)