Esempio n. 1
0
elif BSD:
    from scapy.arch.unix import read_routes, read_routes6, in6_getifaddr  # noqa: F401, E501

    if not conf.use_pcap or conf.use_dnet:
        from scapy.arch.bpf.core import *  # noqa F403
        from scapy.arch.bpf.supersocket import *  # noqa F403
        conf.use_bpf = True
elif SOLARIS:
    from scapy.arch.solaris import *  # noqa F403
elif WINDOWS:
    from scapy.arch.windows import *  # noqa F403

if conf.iface is None:
    conf.iface = scapy.consts.LOOPBACK_INTERFACE

_set_conf_sockets()  # Apply config


def get_if_addr6(iff):
    """
    Returns the main global unicast address associated with provided
    interface, in human readable form. If no global address is found,
    None is returned.
    """
    return next(
        (x[0]
         for x in in6_getifaddr() if x[2] == iff and x[1] == IPV6_ADDR_GLOBAL),
        None)


def get_if_raw_addr6(iff):
Esempio n. 2
0
    from scapy.arch.unix import read_routes, read_routes6, in6_getifaddr  # noqa: F401, E501

    if not conf.use_pcap or conf.use_dnet:
        from scapy.arch.bpf.core import *  # noqa F403
        from scapy.arch.bpf.supersocket import * # noqa F403
        conf.use_bpf = True
elif SOLARIS:
    from scapy.arch.solaris import *  # noqa F403
elif WINDOWS:
    from scapy.arch.windows import *  # noqa F403
    from scapy.arch.windows.native import *  # noqa F403

if conf.iface is None:
    conf.iface = scapy.consts.LOOPBACK_INTERFACE

_set_conf_sockets()  # Apply config


def get_if_addr6(iff):
    """
    Returns the main global unicast address associated with provided
    interface, in human readable form. If no global address is found,
    None is returned.
    """
    return next((x[0] for x in in6_getifaddr()
                 if x[2] == iff and x[1] == IPV6_ADDR_GLOBAL), None)


def get_if_raw_addr6(iff):
    """
    Returns the main global unicast address associated with provided