MCPcopy Create free account
hub / github.com/secdev/scapy / l2_register_l3_arp

Function l2_register_l3_arp

scapy/layers/l2.py:597–620  ·  view source on GitHub ↗

Resolves the default L2 destination address when ARP is used.

(l2: Packet, l3: Packet)

Source from the content-addressed store, hash-verified

595
596
597def l2_register_l3_arp(l2: Packet, l3: Packet) -> Optional[str]:
598 """
599 Resolves the default L2 destination address when ARP is used.
600 """
601 if l3.op == 1: # who-has
602 return "ff:ff:ff:ff:ff:ff"
603 elif l3.op == 2: # is-at
604 log_runtime.warning(
605 "You should be providing the Ethernet destination MAC address when "
606 "sending an is-at ARP."
607 )
608 # Need ARP request to send ARP request...
609 plen = l3.get_field("pdst").i2len(l3, l3.pdst)
610 if plen == 4:
611 return getmacbyip(l3.pdst)
612 elif plen == 32:
613 from scapy.layers.inet6 import getmacbyip6
614 return getmacbyip6(l3.pdst)
615 # Can't even do that
616 log_runtime.warning(
617 "You should be providing the Ethernet destination mac when sending this "
618 "kind of ARP packets."
619 )
620 return None
621
622
623conf.neighbor.register_l3(Ether, ARP, l2_register_l3_arp)

Callers

nothing calls this directly

Calls 4

getmacbyip6Function · 0.90
getmacbyipFunction · 0.85
get_fieldMethod · 0.80
i2lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…