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_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 load(self): from scapy.fields import FlagValue data = {} ips = in6_getifaddr() for ifname, index in _get_ifindex_list(): try: ifflags = _get_if_flags(ifname) mac = scapy.utils.str2mac(get_if_raw_hwaddr(ifname)[1]) ip = inet_ntop(socket.AF_INET, get_if_raw_addr(ifname)) except Scapy_Exception: continue ifflags = FlagValue(ifflags, _iff_flags) if_data = { "name": ifname, "network_name": ifname, "description": ifname, "flags": ifflags, "index": index, "ip": ip, "ips": [x[0] for x in ips if x[2] == ifname] + [ip], "mac": mac } data[ifname] = NetworkInterface(self, if_data) return data