def __init__(self, net: LLNetBase): self.net = net self.local_proto_eth = ARPContext() #Local address maps self.other_proto_eth = ARPContext() #Other address maps self.forwarding_table = ForwardingTable(net) #Forwarding table self.my_ips = [intf.ipaddr for intf in net.interfaces()] #Local IPs #Load context-provided forwarding table info self.forwarding_table.load_file("forwarding_table.txt") #Cache IP->MAC mapping for local interfaces for intf in net.interfaces(): self.local_proto_eth[intf.ipaddr] = intf.ethaddr
def __init__(self, net: LLNetBase): self._net_ = net self.table = {} #Populate table based on net object for intf in net.interfaces(): net_prfx = IPv4Address(int(intf.ipaddr) & int(intf.netmask)) network = "{}/{}".format(net_prfx, intf.netmask) mac_addr = intf.ethaddr self.add_entry(network, None, mac_addr)
def __init__(self, net: LLNetBase, size=5): self._net_ = net self.table = {} self.index = [None for i in range(size)] self.i_ptr = 0 self.size = size #Populate table based on net object for intf in net.interfaces(): net_prfx = IPv4Address(int(intf.ipaddr) & int(intf.netmask)) network = "{}/{}".format(net_prfx, intf.netmask) mac_addr = intf.ethaddr self.add_entry(network, None, mac_addr, True)