Resolves the default L2 destination address when ARP is used.
(l2: Packet, l3: Packet)
| 595 | |
| 596 | |
| 597 | def 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 | |
| 623 | conf.neighbor.register_l3(Ether, ARP, l2_register_l3_arp) |
nothing calls this directly
no test coverage detected
searching dependent graphs…