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

Method _fix

scapy/volatile.py:676–702  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

674 return "ip6template=%r" % self.tmpl
675
676 def _fix(self):
677 # type: () -> str
678 nbm = self.multi
679 ip = [] # type: List[str]
680 for i, n in enumerate(self.sp):
681 if n == "**":
682 nbm -= 1
683 remain = 8 - (len(self.sp) - i - 1) - len(ip) + nbm
684 if "" in self.sp:
685 remain += 1
686 if nbm or self.variable:
687 remain = random.randint(0, remain)
688 for j in range(remain):
689 ip.append("%04x" % random.randint(0, 65535))
690 elif isinstance(n, RandNum):
691 ip.append("%04x" % int(n))
692 elif n == 0:
693 ip.append("0")
694 elif not n:
695 ip.append("")
696 else:
697 ip.append("%04x" % int(n))
698 if len(ip) == 9:
699 ip.remove("")
700 if ip[-1] == "":
701 ip[-1] = "0"
702 return ":".join(ip)
703
704
705class RandOID(_RandString[str]):

Callers

nothing calls this directly

Calls 3

joinMethod · 0.80
appendMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected