hpimdm/Main.py
def list_enabled_interfaces(ipv4=False, ipv6=False):
    """
    List all interfaces of the machine (enabled and not enabled for HPIM-DM and IGMP)
    """
    if ipv4:
        t = PrettyTable(['Interface', 'IP', 'HPIM/IGMP Enabled', 'HPIM security', 'IGMP State'])
        family = netifaces.AF_INET
        hpim_interfaces = interfaces
        membership_interfaces = igmp_interfaces
    elif ipv6:
        t = PrettyTable(['Interface', 'IP', 'HPIM/MLD Enabled', 'HPIM security', 'MLD State'])
        family = netifaces.AF_INET6
        hpim_interfaces = interfaces_v6
        membership_interfaces = mld_interfaces
    else:
        return "Unknown IP family"

    for interface in netifaces.interfaces():
        try:
            # TODO: fix same interface with multiple ips
            ip = netifaces.ifaddresses(interface)[family][0]['addr']
            hpim_enabled = interface in hpim_interfaces
            membership_enabled = interface in membership_interfaces
            enabled = str(hpim_enabled) + "/" + str(membership_enabled)
            hpim_protection = "-"
            if hpim_enabled and hpim_interfaces[interface].is_security_enabled():
                hpim_protection = str(hpim_interfaces[interface].security_id) + ": " + \
                                  hpim_interfaces[interface].hash_function.__name__
            membership_state = "-"
            if membership_enabled:
                membership_state = membership_interfaces[interface].interface_state.print_state()
            t.add_row([interface, ip, enabled, hpim_protection, membership_state])
        except Exception:
            continue
    print(t)
    return str(t)

    List all interfaces of the machine (enabled and not enabled for HPIM-DM and IGMP)
    
List all interfaces of the machine (enabled and not enabled for HPIM-DM and IGMP)
List all interfaces of the machine ( enabled and not enabled for HPIM - DM and IGMP )
def list_enabled_interfaces(ipv4=False, ipv6=False):
    if ipv4:
        t = PrettyTable(['Interface', 'IP', 'HPIM/IGMP Enabled', 'HPIM security', 'IGMP State'])
        family = netifaces.AF_INET
        hpim_interfaces = interfaces
        membership_interfaces = igmp_interfaces
    elif ipv6:
        t = PrettyTable(['Interface', 'IP', 'HPIM/MLD Enabled', 'HPIM security', 'MLD State'])
        family = netifaces.AF_INET6
        hpim_interfaces = interfaces_v6
        membership_interfaces = mld_interfaces
    else:
        return "Unknown IP family"
    for interface in netifaces.interfaces():
        try:
            ip = netifaces.ifaddresses(interface)[family][0]['addr']
            hpim_enabled = interface in hpim_interfaces
            membership_enabled = interface in membership_interfaces
            enabled = str(hpim_enabled) + "/" + str(membership_enabled)
            hpim_protection = "-"
            if hpim_enabled and hpim_interfaces[interface].is_security_enabled():
                hpim_protection = str(hpim_interfaces[interface].security_id) + ": " + \
                                  hpim_interfaces[interface].hash_function.__name__
            membership_state = "-"
            if membership_enabled:
                membership_state = membership_interfaces[interface].interface_state.print_state()
            t.add_row([interface, ip, enabled, hpim_protection, membership_state])
        except Exception:
            continue
    print(t)
    return str(t)
def list_enabled_interfaces ( ipv4 = False , ipv6 = False ) : if ipv4 : t = PrettyTable ( [ 'Interface' , 'IP' , 'HPIM/IGMP Enabled' , 'HPIM security' , 'IGMP State' ] ) family = netifaces . AF_INET hpim_interfaces = interfaces membership_interfaces = igmp_interfaces elif ipv6 : t = PrettyTable ( [ 'Interface' , 'IP' , 'HPIM/MLD Enabled' , 'HPIM security' , 'MLD State' ] ) family = netifaces . AF_INET6 hpim_interfaces = interfaces_v6 membership_interfaces = mld_interfaces else : return "Unknown IP family" for interface in netifaces . interfaces ( ) : try : ip = netifaces . ifaddresses ( interface ) [ family ] [ 0 ] [ 'addr' ] hpim_enabled = interface in hpim_interfaces membership_enabled = interface in membership_interfaces enabled = str ( hpim_enabled ) + "/" + str ( membership_enabled ) hpim_protection = "-" if hpim_enabled and hpim_interfaces [ interface ] . is_security_enabled ( ) : hpim_protection = str ( hpim_interfaces [ interface ] . security_id ) + ": " + hpim_interfaces [ interface ] . hash_function . __name__ membership_state = "-" if membership_enabled : membership_state = membership_interfaces [ interface ] . interface_state . print_state ( ) t . add_row ( [ interface , ip , enabled , hpim_protection , membership_state ] ) except Exception : continue print ( t ) return str ( t )
List all interfaces of the machine (enabled and not enabled for HPIM-DM and IGMP)
List all interfaces of the machine ( enabled and not enabled for HPIM - DM and IGMP )
"""
    List all interfaces of the machine (enabled and not enabled for HPIM-DM and IGMP)
    """ # TODO: fix same interface with multiple ips
ipv4
ipv6