MCPcopy Index your code
hub / github.com/secdev/scapy / ARP

Class ARP

scapy/layers/l2.py:471–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469
470
471class ARP(Packet):
472 name = "ARP"
473 fields_desc = [
474 XShortEnumField("hwtype", 0x0001, HARDWARE_TYPES),
475 XShortEnumField("ptype", 0x0800, ETHER_TYPES),
476 FieldLenField("hwlen", None, fmt="B", length_of="hwsrc"),
477 FieldLenField("plen", None, fmt="B", length_of="psrc"),
478 ShortEnumField("op", 1, {
479 "who-has": 1,
480 "is-at": 2,
481 "RARP-req": 3,
482 "RARP-rep": 4,
483 "Dyn-RARP-req": 5,
484 "Dyn-RAR-rep": 6,
485 "Dyn-RARP-err": 7,
486 "InARP-req": 8,
487 "InARP-rep": 9
488 }),
489 MultipleTypeField(
490 [
491 (SourceMACField("hwsrc"),
492 (lambda pkt: pkt.hwtype == 1 and pkt.hwlen == 6,
493 lambda pkt, val: pkt.hwtype == 1 and (
494 pkt.hwlen == 6 or (pkt.hwlen is None and
495 (val is None or len(val) == 6 or
496 valid_mac(val)))
497 ))),
498 ],
499 StrFixedLenField("hwsrc", None, length_from=lambda pkt: pkt.hwlen),
500 ),
501 MultipleTypeField(
502 [
503 (SourceIPField("psrc"),
504 (lambda pkt: pkt.ptype == 0x0800 and pkt.plen == 4,
505 lambda pkt, val: pkt.ptype == 0x0800 and (
506 pkt.plen == 4 or (pkt.plen is None and
507 (val is None or valid_net(val)))
508 ))),
509 (SourceIP6Field("psrc"),
510 (lambda pkt: pkt.ptype == 0x86dd and pkt.plen == 16,
511 lambda pkt, val: pkt.ptype == 0x86dd and (
512 pkt.plen == 16 or (pkt.plen is None and
513 (val is None or valid_net6(val)))
514 ))),
515 ],
516 StrFixedLenField("psrc", None, length_from=lambda pkt: pkt.plen),
517 ),
518 MultipleTypeField(
519 [
520 (MACField("hwdst", ETHER_ANY),
521 (lambda pkt: pkt.hwtype == 1 and pkt.hwlen == 6,
522 lambda pkt, val: pkt.hwtype == 1 and (
523 pkt.hwlen == 6 or (pkt.hwlen is None and
524 (val is None or len(val) == 6 or
525 valid_mac(val)))
526 ))),
527 ],
528 StrFixedLenField("hwdst", None, length_from=lambda pkt: pkt.hwlen),

Callers 11

deal_common_pktMethod · 0.90
send_arp_reqMethod · 0.90
getmacbyipFunction · 0.85
arpcachepoisonFunction · 0.85
arp_mitmFunction · 0.85
arpingFunction · 0.85
is_promiscFunction · 0.85
promiscpingFunction · 0.85
make_replyMethod · 0.85
etherleakFunction · 0.85
arpleakFunction · 0.85

Calls 14

XShortEnumFieldClass · 0.90
FieldLenFieldClass · 0.90
ShortEnumFieldClass · 0.90
MultipleTypeFieldClass · 0.90
valid_macFunction · 0.90
StrFixedLenFieldClass · 0.90
SourceIPFieldClass · 0.90
valid_netFunction · 0.90
SourceIP6FieldClass · 0.90
valid_net6Function · 0.90
MACFieldClass · 0.90
IPFieldClass · 0.90

Tested by

no test coverage detected