hpimdm/Main.py
def list_routing_state(ipv4=False, ipv6=False):
    """
    List HPIM-DM state (all state machines of each tree, regarding each interface)
    """
    if ipv4 and kernel is not None:
        routes = kernel.routing.values()
        vif_indexes = kernel.vif_index_to_name_dic.keys()
        dict_index_to_name = kernel.vif_index_to_name_dic
    elif ipv6 and kernel_v6 is not None:
        routes = kernel_v6.routing.values()
        vif_indexes = kernel_v6.vif_index_to_name_dic.keys()
        dict_index_to_name = kernel_v6.vif_index_to_name_dic
    else:
        routes = []
        vif_indexes = []
        dict_index_to_name = {}

    routing_entries = []
    for a in list(routes):
        for b in list(a.values()):
            routing_entries.append(b)

    t = PrettyTable(['SourceIP', 'GroupIP', 'TreeState', 'Interface', 'InterestState', 'AssertState', 'LocalMembership', "Is Forwarding?"])
    for entry in routing_entries:
        ip = entry.source_ip
        group = entry.group_ip
        upstream_if_index = entry.inbound_interface_index
        tree_state = str(entry._tree_state)

        for index in vif_indexes:
            interface_state = entry.interface_state[index]
            interface_name = dict_index_to_name[index]
            local_membership = str(interface_state._local_membership_state)
            try:
                if index != upstream_if_index:
                    assert_state = str(interface_state._assert_state)
                    prune_state = str(interface_state._downstream_node_interest_state)
                    is_forwarding = interface_state.is_forwarding()
                else:
                    assert_state = "--"
                    prune_state = "--"
                    is_forwarding = "root"
            except:
                prune_state = "-"
                assert_state = "-"
                is_forwarding = "-"

            t.add_row([ip, group, tree_state, interface_name, prune_state, assert_state, local_membership, is_forwarding])
    return str(t)

    List HPIM-DM state (all state machines of each tree, regarding each interface)
    
List HPIM-DM state (all state machines of each tree, regarding each interface)
List HPIM - DM state ( all state machines of each tree regarding each interface )
def list_routing_state(ipv4=False, ipv6=False):
    if ipv4 and kernel is not None:
        routes = kernel.routing.values()
        vif_indexes = kernel.vif_index_to_name_dic.keys()
        dict_index_to_name = kernel.vif_index_to_name_dic
    elif ipv6 and kernel_v6 is not None:
        routes = kernel_v6.routing.values()
        vif_indexes = kernel_v6.vif_index_to_name_dic.keys()
        dict_index_to_name = kernel_v6.vif_index_to_name_dic
    else:
        routes = []
        vif_indexes = []
        dict_index_to_name = {}
    routing_entries = []
    for a in list(routes):
        for b in list(a.values()):
            routing_entries.append(b)
    t = PrettyTable(['SourceIP', 'GroupIP', 'TreeState', 'Interface', 'InterestState', 'AssertState', 'LocalMembership', "Is Forwarding?"])
    for entry in routing_entries:
        ip = entry.source_ip
        group = entry.group_ip
        upstream_if_index = entry.inbound_interface_index
        tree_state = str(entry._tree_state)
        for index in vif_indexes:
            interface_state = entry.interface_state[index]
            interface_name = dict_index_to_name[index]
            local_membership = str(interface_state._local_membership_state)
            try:
                if index != upstream_if_index:
                    assert_state = str(interface_state._assert_state)
                    prune_state = str(interface_state._downstream_node_interest_state)
                    is_forwarding = interface_state.is_forwarding()
                else:
                    assert_state = "--"
                    prune_state = "--"
                    is_forwarding = "root"
            except:
                prune_state = "-"
                assert_state = "-"
                is_forwarding = "-"
            t.add_row([ip, group, tree_state, interface_name, prune_state, assert_state, local_membership, is_forwarding])
    return str(t)
def list_routing_state ( ipv4 = False , ipv6 = False ) : if ipv4 and kernel is not None : routes = kernel . routing . values ( ) vif_indexes = kernel . vif_index_to_name_dic . keys ( ) dict_index_to_name = kernel . vif_index_to_name_dic elif ipv6 and kernel_v6 is not None : routes = kernel_v6 . routing . values ( ) vif_indexes = kernel_v6 . vif_index_to_name_dic . keys ( ) dict_index_to_name = kernel_v6 . vif_index_to_name_dic else : routes = [ ] vif_indexes = [ ] dict_index_to_name = { } routing_entries = [ ] for a in list ( routes ) : for b in list ( a . values ( ) ) : routing_entries . append ( b ) t = PrettyTable ( [ 'SourceIP' , 'GroupIP' , 'TreeState' , 'Interface' , 'InterestState' , 'AssertState' , 'LocalMembership' , "Is Forwarding?" ] ) for entry in routing_entries : ip = entry . source_ip group = entry . group_ip upstream_if_index = entry . inbound_interface_index tree_state = str ( entry . _tree_state ) for index in vif_indexes : interface_state = entry . interface_state [ index ] interface_name = dict_index_to_name [ index ] local_membership = str ( interface_state . _local_membership_state ) try : if index != upstream_if_index : assert_state = str ( interface_state . _assert_state ) prune_state = str ( interface_state . _downstream_node_interest_state ) is_forwarding = interface_state . is_forwarding ( ) else : assert_state = "--" prune_state = "--" is_forwarding = "root" except : prune_state = "-" assert_state = "-" is_forwarding = "-" t . add_row ( [ ip , group , tree_state , interface_name , prune_state , assert_state , local_membership , is_forwarding ] ) return str ( t )
List HPIM-DM state (all state machines of each tree, regarding each interface)
List HPIM - DM state ( all state machines of each tree regarding each interface )
"""
    List HPIM-DM state (all state machines of each tree, regarding each interface)
    """
ipv4
ipv6