
    ӊ^              
       j   d Z ddlZdZ	 ddlZej                  s ed      ej                   ej                   ddlmZ
mZm	Z	 dZddlmZ ddlmZmZmZmZmZmZmZmZ m!Z" d	Z#d
Z$dZ%e	Z&dZ'dZ(d
Z)de#z  dz
  Z*e#e$z  Z+de$z  dz
  Z, e- e.de#dz         D  cg c]  } | e*de#| z
  z  dz
  z  f c}       Z/ e- e.de#dz         D  cg c]  } e*de#| z
  z  dz
  z  | f c}       Z0 e- e.de#dz         D  cg c]  } | de#| z
  z  dz
  f c}       Z1 e- e.de#dz         D  cg c]  } de#| z
  z  dz
  | f c}       Z2 G d de3      Z4 G d de4      Z5 G d de4      Z6d%dZ7d%dZ8d&dZ9d Z:d Z;d Z<d Zd'dZd Zd Zd  Zd&d!Zd" Zd# Zd$ Z!y# e$ r ddlmZ
mZm	Z	 Y Ww xY wc c} w c c} w c c} w c c} w )(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      :IPv6         c                       e Zd ZdZdZdZy)ipv6_compactz%An IPv6 dialect class - compact form.z%xTN__name__
__module____qualname____doc__word_fmtcompact     7/usr/lib/python3/dist-packages/netaddr/strategy/ipv6.pyr   r   V   s    /H Gr!   r   c                       e Zd ZdZdZy)	ipv6_fullz*An IPv6 dialect class - 'all zeroes' form.FN)r   r   r   r   r   r    r!   r"   r$   r$   ^   s    4 Gr!   r$   c                       e Zd ZdZdZdZy)ipv6_verbosez5An IPv6 dialect class - extra wide 'all zeroes' form.z%.4xFNr   r    r!   r"   r&   r&   d   s    ? H Gr!   r&   c                 T    | dk(  rt        d      	 t        t        |        y#  Y yxY w)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flagss     r"   	valid_strr,   n   s5     rz@AA8T" s   # 'c                 p    	 t        t        |       }t        |      S # t        $ r t	        | d      w xY w)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$ is not a valid IPv6 address string!)r)   r   packed_to_int	Exceptionr   )r*   r+   
packed_ints      r"   
str_to_intr1      s>    R$/
Z(( R$PQQRs    5c                 P   |t         }d}	 t        |       }|j                  rt        t        |      }|S t        t        j                  d|            }|D cg c]  }|j                  |z   }}t        j                  |      }	 |S c c}w # t        $ r t        | d      w xY w)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>8Hz) is not a valid 128-bit unsigned integer!)r   int_to_packedr   
_inet_ntopr   list_structunpackr   word_sepjoinr/   
ValueError)int_valdialectr*   r0   wordswordtokenss          r"   
int_to_strr@      s     DU"7+
??h
3D K z:;E:?@$g&&-@F@==(D K A U'STTUs"   'B #B B.B B B%c                     t        | t              }t        |j                  dd            }|j	                          |g dz   }dj                  |      S )z
    :param int_val: An unsigned integer.

    :return: The reverse DNS lookup for an IPv6 address in network byte
        order integer form.
    r   r(   )ip6arpar(   .)r@   r&   r5   replacereverser9   )r;   r*   r?   s      r"   int_to_arparG      sI     g|,D$,,sB'(F
NN))F88Fr!   c                 H    t        | dd      }t        j                  dg| 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)r   r6   pack)r;   r=   s     r"   r3   r3      s&     !R(E<<&&&r!   c                     t        t        j                  d|             }d}t        t	        |            D ]  \  }}|}|d|z  z  }||z  } |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.
    rK   r   rJ   )r5   r6   r7   	enumeratereversed)r0   r=   r;   inumr>   s         r"   r.   r.      s\     z23EGHUO, !3rAv~D.!
 Nr!   c                 ,    t        | t        t              S N)_valid_words	word_size	num_wordsr=   s    r"   r   r      s    y)44r!   c                 X    |t               d   }|t               d   }t        | ||      S )NrV   rU   )globals_int_to_words)r;   rV   rU   s      r"   r   r      s5    Ik*	Ik*	)Y77r!   c                 ,    t        | t        t              S rS   )_words_to_intrU   rV   rW   s    r"   r	   r	      s    	955r!   c                 ,    t        | t        t              S rS   )_valid_bitswidthr8   bitss    r"   r
   r
      s    tUH--r!   c                 ,    t        | t        t              S rS   )_bits_to_intr_   r8   r`   s    r"   r   r      s    eX..r!   c                 L    |t               d   }t        | t        t        |      S )Nr8   )rY   _int_to_bitsrU   rV   )r;   r8   s     r"   r   r      s%    9Z(Ix@@r!   c                 "    t        | t              S rS   )
_valid_binr_   bin_vals    r"   r   r      s    gu%%r!   c                 "    t        | t              S rS   )_int_to_binr_   )r;   s    r"   r   r          w&&r!   c                 "    t        | t              S rS   )_bin_to_intr_   rh   s    r"   r   r     rl   r!   )r   rS   )NN)=r   structr6   OPT_IMPORTSsocket_sockethas_ipv6r/   r   r   r)   r   r4   netaddr.fbsocketnetaddr.corer   netaddr.strategyr   rT   r   rZ   r	   r\   r
   r^   r   rc   r   re   r   rg   r   rk   r   rn   r_   rU   r8   familyfamily_nameversion	word_basemax_intrV   max_worddictrangeprefix_to_netmasknetmask_to_prefixprefix_to_hostmaskhostmask_to_prefixobjectr   r$   r&   r,   r1   r@   rG   r3   r.   )rP   s   0r"   <module>r      sT   +((# #K
 )   	 	  
   	 u*q. Y	 	>A 49!U1W4EFqaA%!)$q(	)*FH  49!U1W4EFqguqy!A%&*FH  */57*;<Qa!	
Q
 <>  */57*;<QqUQY!a <> 6  < &R <'&586./A&''U  ++ ++X G G = =s)   <F F!F&1F+F0FF