????

Your IP : 216.73.217.84


Current Path : /lib/python3.9/site-packages/netaddr/strategy/__pycache__/
Upload File :
Current File : //lib/python3.9/site-packages/netaddr/strategy/__pycache__/ipv6.cpython-39.opt-1.pyc

a

��g��@sdZddlZdZz>ddlZejs(ed��ejej	ddlmZ
mZm	Z	dZWn&eytddl
mZ
mZm	Z	Yn0ddlmZddlmZmZmZmZmZmZmZmZ m!Z"d	Z#d
Z$dZ%e	Z&dZ'd
Z(d
Z)de#dZ*e#e$Z+de$dZ,e-dd�e.de#d�D��Z/e-dd�e.de#d�D��Z0e-dd�e.de#d�D��Z1e-dd�e.de#d�D��Z2Gdd�de3�Z4Gdd�de4�Z5Gdd�de4�Z6d9dd�Z7d:dd�Z8d;dd �Z9d!d"�Z:d#d$�Z;d%d&�Z<d'd(�Zd<d)d*�Zd+d,�Zd-d.�Zd/d0�Zd=d1d2�Zd3d4�Zd5d6�Zd7d8�Z!dS)>z
IPv6 address logic.
�NFz
IPv6 disabled)�	inet_pton�	inet_ntop�AF_INET6T)�AddrFormatError)	�valid_words�int_to_words�words_to_int�
valid_bits�bits_to_int�int_to_bits�	valid_bin�
int_to_bin�
bin_to_int���:ZIPv6���cCs$g|]}|tdt|dAf�qS�rr��max_int�width��.0�i�r�9/usr/lib/python3.9/site-packages/netaddr/strategy/ipv6.py�
<listcomp>D�rcCs$g|]}tdt|dA|f�qSrrrrrrrHrcCs g|]}|dt|df�qSr�rrrrrrLrcCs g|]}dt|d|f�qSrr rrrrrPrc@seZdZdZdZdZdS)�ipv6_compactz%An IPv6 dialect class - compact form.z%xTN��__name__�
__module__�__qualname__�__doc__�word_fmt�compactrrrrr!Vsr!c@seZdZdZdZdS)�	ipv6_fullz*An IPv6 dialect class - 'all zeroes' form.FN)r#r$r%r&r(rrrrr)^sr)c@seZdZdZdZdZdS)�ipv6_verbosez5An IPv6 dialect class - extra wide 'all zeroes' form.z%.4xFNr"rrrrr*dsr*cCs2|dkrtd��ztt|�WnYdS0dS)a
    :param addr: An IPv6 address in presentation (string) format.

    :param flags: decides which rules are applied to the interpretation of the
        addr value. Future use - currently has no effect.

    :return: ``True`` if IPv6 address is valid, ``False`` otherwise.
    �z Empty strings are not supported!FT)r�
_inet_ptonr)�addr�flagsrrr�	valid_strns	r/cCs:ztt|�}t|�WSty4td|f��Yn0dS)a
    :param addr: An IPv6 address in string form.

    :param flags: decides which rules are applied to the interpretation of the
        addr value. Future use - currently has no effect.

    :return: The equivalent unsigned integer for a given IPv6 address.
    z&%r is not a valid IPv6 address string!N)r,r�
packed_to_int�	Exceptionr)r-r.�
packed_intrrr�
str_to_int�s
	

r3cs��durt�d}zJt|�}�jr,tt|�}n,tt�d|��}�fdd�|D�}t�	|�}Wn t
yztd|f��Yn0|S)z�
    :param int_val: An unsigned integer.

    :param dialect: (optional) a Python class defining formatting options.

    :return: The IPv6 presentation (string) format address equivalent to the
        unsigned integer provided.
    Nz>8Hcsg|]}�j|�qSr)r')r�word��dialectrrr�rzint_to_str.<locals>.<listcomp>z+%r is not a valid 128-bit unsigned integer!)r!�
int_to_packedr(�
_inet_ntopr�list�_struct�unpack�word_sep�joinr1�
ValueError)�int_valr6r-r2�words�tokensrr5r�
int_to_str�s	rBcCs8t|t�}t|�dd��}|��|gd�}d�|�S)z�
    :param int_val: An unsigned integer.

    :return: The reverse DNS lookup for an IPv6 address in network byte
        order integer form.
    rr+)Zip6Zarpar+�.)rBr*r9�replace�reverser=)r?r-rArrr�int_to_arpa�s

rFcCst|dd�}tjdg|�R�S)z�
    :param int_val: the integer to be packed.

    :return: a packed string that is equivalent to value represented by an
    unsigned integer.
    �� �>4I)rr:�pack)r?r@rrrr7�sr7cCsFtt�d|��}d}tt|��D] \}}|}|d|>}||B}q |S)a
    :param packed_int: a packed string containing an unsigned integer.
        It is assumed that string is packed in network byte order.

    :return: An unsigned integer equivalent to value of network address
        represented by packed binary string.
    rIrrH)r9r:r;�	enumerate�reversed)r2r@r?rZnumr4rrrr0�s
r0cCst|tt�S�N)�_valid_words�	word_size�	num_words�r@rrrr�srcCs0|durt�d}|dur$t�d}t|||�S)NrPrO)�globals�
_int_to_words)r?rPrOrrrr�s


rcCst|tt�SrM)�
_words_to_intrOrPrQrrrr�srcCst|tt�SrM)�_valid_bitsrr<��bitsrrrr	�sr	cCst|tt�SrM)�_bits_to_intrr<rVrrrr
�sr
cCs |durt�d}t|tt|�S)Nr<)rR�_int_to_bitsrOrP)r?r<rrrr�s
rcCs
t|t�SrM)�
_valid_binr�Zbin_valrrrr�srcCs
t|t�SrM)�_int_to_binr)r?rrrr
�sr
cCs
t|t�SrM)�_bin_to_intrr[rrrrsr)r)r)N)NN)N)=r&�structr:ZOPT_IMPORTSZsocketZ_socketZhas_ipv6r1rrr,rr8Znetaddr.fbsocketZnetaddr.corerZnetaddr.strategyrrNrrSrrTr	rUr
rXrrYrrZr
r\rr]rrOr<ZfamilyZfamily_name�versionZ	word_baserrPZmax_word�dict�rangeZprefix_to_netmaskZnetmask_to_prefixZprefix_to_hostmaskZhostmask_to_prefix�objectr!r)r*r/r3rBrFr7r0rrrr�<module>sl,����