# filter addresses from /proc/net/if_inet6 belonging to given ifaces
(lambda ifaces:
    [
        str(import_module("ipaddress").IPv6Address(int(line[0], 16)))
        for line in map(str.split, open('/proc/net/if_inet6'))
        if line[5] in ifaces
            and not int(line[4], 16) & (0x40 | 0x20)
            # address is neither tentative nor deprecated
    ]
)(
    # generate the list of ifaces
    [ batadv_dev ] +
    list(map(
        lambda s: s[len('/sys/class/net/{}/upper_'.format(batadv_dev)):],
        import_module('glob').glob('/sys/class/net/{}/upper_*'.format(batadv_dev))
    ))
)
