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

Function in6_ctop

scapy/utils6.py:478–497  ·  view source on GitHub ↗

Convert an IPv6 address in Compact Representation Notation (RFC 1924) to printable representation ;-) Returns None on error.

(addr)

Source from the content-addressed store, hash-verified

476
477
478def in6_ctop(addr):
479 # type: (str) -> Optional[str]
480 """
481 Convert an IPv6 address in Compact Representation Notation
482 (RFC 1924) to printable representation ;-)
483 Returns None on error.
484 """
485 if len(addr) != 20 or not reduce(lambda x, y: x and y,
486 [x in _rfc1924map for x in addr]):
487 return None
488 i = 0
489 for c in addr:
490 j = _rfc1924map.index(c)
491 i = 85 * i + j
492 res = []
493 for j in range(4):
494 res.append(struct.pack("!I", i % 2**32))
495 i = i // (2**32)
496 res.reverse()
497 return inet_ntop(socket.AF_INET6, b"".join(res))
498
499
500def in6_ptoc(addr):

Callers

nothing calls this directly

Calls 3

inet_ntopFunction · 0.90
joinMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected