
    ui                     x    S r SSKrSSKrSSKr\R
                  r\R                  rS rS rS r	S r
S rS	S jrg)
z*Generic Internet address helper functions.    Nc                     U [         :X  a  [        R                  R                  U5      $ U [        :X  a   [        R
                  R                  US5      $ [        e)a  Convert the textual form of a network address into its binary form.

*family* is an ``int``, the address family.

*text* is a ``str``, the textual address.

Raises ``NotImplementedError`` if the address family specified is not
implemented.

Returns a ``bytes``.
T)AF_INETdnsipv4	inet_atonAF_INET6ipv6NotImplementedError)familytexts     ?/home/kodi/.kodi/addons/script.module.dnspython/lib/dns/inet.py	inet_ptonr   !   sF     xx!!$''	8	xx!!$--!!    c                     U [         :X  a  [        R                  R                  U5      $ U [        :X  a  [        R
                  R                  U5      $ [        e)a  Convert the binary form of a network address into its textual form.

*family* is an ``int``, the address family.

*address* is a ``bytes``, the network address in binary form.

Raises ``NotImplementedError`` if the address family specified is not
implemented.

Returns a ``str``.
)r   r   r   	inet_ntoar   r	   r
   )r   addresss     r   	inet_ntopr   6   sD     xx!!'**	8	xx!!'**!!r   c                      [         R                  R                  U 5        [        $ ! [         a>     [         R
                  R                  U S5        [        s $ ! [         a    [        ef = ff = f)zDetermine the address family of a textual-form network address.

*text*, a ``str``, the textual address.

Raises ``ValueError`` if the address family cannot be determined
from the input.

Returns an ``int``.
T)r   r   r   r   	Exceptionr	   r   
ValueErrorr   s    r   af_for_addressr   K   s`    4  	HHtT*O 			s    $' 
A/%AA/A++A/c                     [         R                  R                  U 5      S   nUS:  =(       a    US:*  $ ! [         a@     [         R                  R                  U S5      S   nUS:H  s $ ! [         a    [
        ef = ff = f)zIs the textual-form network address a multicast address?

*text*, a ``str``, the textual address.

Raises ``ValueError`` if the address family cannot be determined
from the input.

Returns a ``bool``.
r         T   )r   r   r   r   r	   r   )r   firsts     r   is_multicastr   a   s    ""4(+|,, 	HH&&tT215EC< 			s!   25 
A? 'A*'A?*A;;A?c                      [         R                  R                  U 5        g! [         a5     [         R                  R                  U S5         g! [         a      gf = ff = f)zoIs the specified string an IPv4 or IPv6 address?

*text*, a ``str``, the textual address.

Returns a ``bool``.
TF)r   r   r   r   r	   r   s    r   
is_addressr    w   sY    4  	HHtT* 			s&   " 
A! A
AA!AA!c                    U u  p#Uc  [        U5      nU[        :X  a  X#4$ U[        :X  ae  UR                  S5      nUS:  a  X#SS4$ USU nX$S-   S nUR	                  5       (       a  XSS[        U5      4$  XSS[        R                  " U5      4$ [        SU 35      e! [         a.    [        R                  n[        R                  " X#US9tGt pnU	s $ f = f)aA  Given a "high-level" address tuple, i.e.
an (address, port) return the appropriate "low-level" address tuple
suitable for use in socket calls.

If an *af* other than ``None`` is provided, it is assumed the
address in the high-level tuple is valid and has that af.  If af
is ``None``, then af_for_address will be called.

N%r      )flagszunknown address family )r   r   r   findisdigitintsocketif_nametoindexAttributeErrorAI_NUMERICHOSTgetaddrinfor
   )

high_tupleafr   portiaddrpartscopeai_flags_tups
             r   low_level_address_tupler6      s     MG	zG$	W}	xLLq51a((2A;A==??As5z22	Av'<'<U'CDD "$;B4"@AA  	,,H$00hOOYqJ	s   6B 5CC)N)__doc__r(   dns.ipv4r   dns.ipv6r   r   r   r   r   r   r    r6    r   r   <module>r;      sF   $ 1    ..??"*"*,,& Br   