def adoptnetif( self, netif: CoreInterface, ifindex: int, hwaddr: str, addrlist: List[str] ) -> None: """ When a link message is received linking this node to another part of the emulation, no new interface is created; instead, adopt the GreTap netif as the node interface. """ netif.name = f"gt{ifindex}" netif.node = self self.addnetif(netif, ifindex) # use a more reasonable name, e.g. "gt0" instead of "gt.56286.150" if self.up: self.net_client.device_down(netif.localname) self.net_client.device_name(netif.localname, netif.name) netif.localname = netif.name if hwaddr: self.sethwaddr(ifindex, hwaddr) for addr in utils.make_tuple(addrlist): self.addaddr(ifindex, addr) if self.up: self.net_client.device_up(netif.localname)
def adopt_iface(self, iface: CoreInterface, iface_id: int, mac: str, ips: List[str]) -> None: """ When a link message is received linking this node to another part of the emulation, no new interface is created; instead, adopt the GreTap interface as the node interface. """ iface.name = f"gt{iface_id}" iface.node = self self.add_iface(iface, iface_id) # use a more reasonable name, e.g. "gt0" instead of "gt.56286.150" if self.up: self.net_client.device_down(iface.localname) self.net_client.device_name(iface.localname, iface.name) iface.localname = iface.name if mac: self.set_mac(iface_id, mac) for ip in ips: self.add_ip(iface_id, ip) if self.up: self.net_client.device_up(iface.localname)