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

Method h2i

scapy/fields.py:944–962  ·  view source on GitHub ↗
(self, pkt, x)

Source from the content-addressed store, hash-verified

942 Field.__init__(self, name, default, "16s")
943
944 def h2i(self, pkt, x):
945 # type: (Optional[Packet], Any) -> str
946 if isinstance(x, bytes):
947 x = plain_str(x)
948 if isinstance(x, _ScopedIP):
949 return x
950 elif isinstance(x, str):
951 x = ScopedIP(x)
952 try:
953 x = ScopedIP(in6_ptop(x), scope=x.scope)
954 except socket.error:
955 return Net6(x) # type: ignore
956 elif isinstance(x, tuple):
957 if len(x) != 2:
958 raise ValueError("Invalid IPv6 format")
959 return Net6(*x) # type: ignore
960 elif isinstance(x, list):
961 x = [self.h2i(pkt, n) for n in x]
962 return x # type: ignore
963
964 def i2h(self, pkt, x):
965 # type: (Optional[Packet], Optional[Union[str, Net6]]) -> str

Callers 1

any2iMethod · 0.95

Calls 4

plain_strFunction · 0.90
ScopedIPFunction · 0.90
in6_ptopFunction · 0.90
Net6Class · 0.90

Tested by

no test coverage detected