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

Class RandMAC

scapy/volatile.py:612–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610
611
612class RandMAC(_RandString[str]):
613 def __init__(self, _template="*"):
614 # type: (str) -> None
615 super(RandMAC, self).__init__()
616 self._template = _template
617 _template += ":*:*:*:*:*"
618 template = _template.split(":")
619 self.mac = () # type: Tuple[Union[int, RandNum], ...]
620 for i in range(6):
621 v = 0 # type: Union[int, RandNum]
622 if template[i] == "*":
623 v = RandByte()
624 elif "-" in template[i]:
625 x, y = template[i].split("-")
626 v = RandNum(int(x, 16), int(y, 16))
627 else:
628 v = int(template[i], 16)
629 self.mac += (v,)
630
631 def _command_args(self):
632 # type: () -> str
633 if self._template == "*":
634 return ""
635 return "template=%r" % self._template
636
637 def _fix(self):
638 # type: () -> str
639 return "%02x:%02x:%02x:%02x:%02x:%02x" % self.mac # type: ignore
640
641
642class RandIP6(_RandString[str]):

Callers 3

randvalMethod · 0.90
in6_getLocalUniquePrefixFunction · 0.90
negotiate_trunkFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected