o
    BŠ]g  ã                   @   sd   d dl Z d dlZd dlmZmZ d dlmZ d dlmZ ddgZ	G dd„ deƒZ
G dd„ deƒZdS )	é    N)ÚudpÚudp6)ÚAbstractTransportTarget)ÚPySnmpErrorÚUdp6TransportTargetÚUdpTransportTargetc                   @   ó$   e Zd ZdZejZejZdd„ Z	dS )r   a·  Creates UDP/IPv4 configuration entry and initialize socket API if needed.

    This object can be used for adding new entries to Local Configuration
    Datastore (LCD) managed by :py:class:`~pysnmp.hlapi.SnmpEngine`
    class instance.

    See :RFC:`1906#section-3` for more information on the UDP transport mapping.

    Parameters
    ----------
    transportAddr : tuple
        Indicates remote address in Python :py:mod:`socket` module format
        which is a tuple of FQDN, port where FQDN is a string representing
        either hostname or IPv4 address in quad-dotted form, port is an
        integer.
    timeout : int
        Response timeout in seconds.
    retries : int
        Maximum number of request retries, 0 retries means just a single
        request.
    tagList : str
        Arbitrary string that contains a list of tag values which are used
        to select target addresses for a particular operation
        (:RFC:`3413#section-4.1.4`).

    Examples
    --------
    >>> from pysnmp.hlapi.asyncio import UdpTransportTarget
    >>> UdpTransportTarget(('demo.snmplabs.com', 161))
    UdpTransportTarget(('195.218.195.228', 161), timeout=1, retries=5, tagList='')
    >>>

    c              	   C   ól   zt  |d |d t jt jt j¡d d d d… W S  t jy5   tdd dd„ |D ƒ¡t 	¡ d f ƒ‚w )	Nr   é   é   é   z%Bad IPv4/UDP transport address %s: %sú@c                 S   ó   g | ]}t |ƒ‘qS © ©Ústr©Ú.0Úxr   r   ú@/usr/lib/python3/dist-packages/pysnmp/hlapi/asyncio/transport.pyÚ
<listcomp>>   ó    z3UdpTransportTarget._resolveAddr.<locals>.<listcomp>)
ÚsocketÚgetaddrinfoZAF_INETÚ
SOCK_DGRAMÚIPPROTO_UDPÚgaierrorr   ÚjoinÚsysÚexc_info©ÚselfZtransportAddrr   r   r   Ú_resolveAddr5   ó$   
üüüüÿÿzUdpTransportTarget._resolveAddrN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú
domainNameÚtransportDomainZUdpAsyncioTransportÚprotoTransportr"   r   r   r   r   r      s
    !c                   @   r   )r   aÛ  Creates UDP/IPv6 configuration entry and initialize socket API if needed.

    This object can be used by
    :py:class:`~pysnmp.hlapi.asyncio.AsyncCommandGenerator` or
    :py:class:`~pysnmp.hlapi.asyncio.AsyncNotificationOriginator`
    and their derevatives for adding new entries to Local Configuration
    Datastore (LCD) managed by :py:class:`~pysnmp.hlapi.SnmpEngine`
    class instance.

    See :RFC:`1906#section-3`, :RFC:`2851#section-4` for more information
    on the UDP and IPv6 transport mapping.

    Parameters
    ----------
    transportAddr : tuple
        Indicates remote address in Python :py:mod:`socket` module format
        which is a tuple of FQDN, port where FQDN is a string representing
        either hostname or IPv6 address in one of three conventional forms
        (:RFC:`1924#section-3`), port is an integer.
    timeout : int
        Response timeout in seconds.
    retries : int
        Maximum number of request retries, 0 retries means just a single
        request.
    tagList : str
        Arbitrary string that contains a list of tag values which are used
        to select target addresses for a particular operation
        (:RFC:`3413#section-4.1.4`).

    Examples
    --------
    >>> from pysnmp.hlapi.asyncio import Udp6TransportTarget
    >>> Udp6TransportTarget(('google.com', 161))
    Udp6TransportTarget(('2a00:1450:4014:80a::100e', 161), timeout=1, retries=5, tagList='')
    >>> Udp6TransportTarget(('FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', 161))
    Udp6TransportTarget(('fedc:ba98:7654:3210:fedc:ba98:7654:3210', 161), timeout=1, retries=5, tagList='')
    >>> Udp6TransportTarget(('1080:0:0:0:8:800:200C:417A', 161))
    Udp6TransportTarget(('1080::8:800:200c:417a', 161), timeout=1, retries=5, tagList='')
    >>> Udp6TransportTarget(('::0', 161))
    Udp6TransportTarget(('::', 161), timeout=1, retries=5, tagList='')
    >>> Udp6TransportTarget(('::', 161))
    Udp6TransportTarget(('::', 161), timeout=1, retries=5, tagList='')
    >>>

    c              	   C   r	   )	Nr   r
   r   r   z%Bad IPv6/UDP transport address %s: %sr   c                 S   r   r   r   r   r   r   r   r   {   r   z4Udp6TransportTarget._resolveAddr.<locals>.<listcomp>)
r   r   ZAF_INET6r   r   r   r   r   r   r   r    r   r   r   r"   r   r#   z Udp6TransportTarget._resolveAddrN)
r$   r%   r&   r'   r   r(   r)   ZUdp6AsyncioTransportr*   r"   r   r   r   r   r   A   s
    -)r   r   Zpysnmp.carrier.asyncio.dgramr   r   Zpysnmp.hlapi.transportr   Zpysnmp.errorr   Ú__all__r   r   r   r   r   r   Ú<module>   s   1