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

Method h2i

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

Source from the content-addressed store, hash-verified

850 Field.__init__(self, name, default, "4s")
851
852 def h2i(self, pkt, x):
853 # type: (Optional[Packet], Union[AnyStr, List[AnyStr]]) -> Any
854 if isinstance(x, bytes):
855 x = plain_str(x) # type: ignore
856 if isinstance(x, _ScopedIP):
857 return x
858 elif isinstance(x, str):
859 x = ScopedIP(x)
860 try:
861 inet_aton(x)
862 except socket.error:
863 return Net(x)
864 elif isinstance(x, tuple):
865 if len(x) != 2:
866 raise ValueError("Invalid IP format")
867 return Net(*x)
868 elif isinstance(x, list):
869 return [self.h2i(pkt, n) for n in x]
870 return x
871
872 def i2h(self, pkt, x):
873 # type: (Optional[Packet], Optional[Union[str, Net]]) -> str

Callers 1

any2iMethod · 0.95

Calls 4

plain_strFunction · 0.90
ScopedIPFunction · 0.90
inet_atonFunction · 0.90
NetClass · 0.90

Tested by

no test coverage detected