import codecs
import struct
import socket
import ipaddress


def parse_ipv6_address(ipv6_hex):
    """
    Convert /proc IPv6 hex address into standard IPv6 notation.

        :param ipv6_hex: IPv6 string in hex format
        :return: IPv6Address object
    """
    # convert IPv6 address in ASCII hex format into binary format
    binary = codecs.decode(ipv6_hex, "hex")
    # unpack IPv6 address into 4 32-bit integers in big endian / network
    # byte order
    unpacked = struct.unpack("!LLLL", binary)
    # re-pack IPv6 address as 4 32-bit integers in system native byte order
    repacked = struct.pack("@IIII", *unpacked)
    # convert the IPv6 address from binary to text form
    ascii_ipv6_address = socket.inet_ntop(socket.AF_INET6, repacked)
    return ipaddress.ip_address(ascii_ipv6_address)