import netifaces


def list_interfaces():
    broadcast_interfaces = {}

    interfaces = netifaces.interfaces()

    for entry in interfaces:
        try:
            entry_data = netifaces.ifaddresses(entry)[netifaces.AF_INET][0]

            if 'broadcast' in entry_data:
                broadcast_interfaces[entry] = entry_data
        except KeyError:
            pass

    return broadcast_interfaces


def get_iface_addr(interface):
    ip = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr']
    broadcast_ip = netifaces.ifaddresses(interface)[netifaces.AF_INET][0][
        'broadcast']

    return ip, broadcast_ip


def main():
    bcast_list = list_interfaces()
    print()
    print(bcast_list)


if __name__ == '__main__':
    main()