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

Function inet_pton

scapy/pton_ntop.py:83–97  ·  view source on GitHub ↗

Convert an IP address from text representation into binary form.

(af, addr)

Source from the content-addressed store, hash-verified

81
82
83def inet_pton(af, addr):
84 # type: (socket.AddressFamily, Union[bytes, str]) -> bytes
85 """Convert an IP address from text representation into binary form."""
86 # Will replace Net/Net6 objects
87 addr = plain_str(addr)
88 # Use inet_pton if available
89 try:
90 if not socket.has_ipv6:
91 raise AttributeError
92 return socket.inet_pton(af, addr)
93 except AttributeError:
94 try:
95 return _INET_PTON[af](addr)
96 except KeyError:
97 raise socket.error("Address family not supported by protocol")
98
99
100def _inet6_ntop(addr):

Callers 15

valid_ip6Function · 0.90
in4_isincludedFunction · 0.90
in4_isaddrllallnodesFunction · 0.90
i2mMethod · 0.90
__init__Method · 0.90
in6_getAddrTypeFunction · 0.90
in6_ifaceidtomacFunction · 0.90
in6_addrtomacFunction · 0.90
in6_get6to4PrefixFunction · 0.90
in6_6to4ExtractAddrFunction · 0.90
in6_getLocalUniquePrefixFunction · 0.90

Calls 1

plain_strFunction · 0.90

Tested by

no test coverage detected