Commit 9473430c authored by Antoine Kaufmann's avatar Antoine Kaufmann Committed by Antoine Kaufmann
Browse files

experiments: add connect_nic to NetSim

So far NIC sims would directly modify the NetSim's list, not giving the
opportunity for subclasses to override. This istead adds a method for this.
parent 33eac66e
...@@ -141,7 +141,7 @@ class NICSim(PCIDevSim): ...@@ -141,7 +141,7 @@ class NICSim(PCIDevSim):
def set_network(self, net: NetSim) -> None: def set_network(self, net: NetSim) -> None:
"""Connect this NIC to a network simulator.""" """Connect this NIC to a network simulator."""
self.network = net self.network = net
net.nics.append(self) net.connect_nic(self)
def basic_args(self, env: ExpEnv, extra: tp.Optional[str] = None) -> str: def basic_args(self, env: ExpEnv, extra: tp.Optional[str] = None) -> str:
cmd = ( cmd = (
...@@ -200,6 +200,9 @@ class NetSim(Simulator): ...@@ -200,6 +200,9 @@ class NetSim(Simulator):
def full_name(self) -> str: def full_name(self) -> str:
return 'net.' + self.name return 'net.' + self.name
def connect_nic(self, nic: NICSim) -> None:
self.nics.append(nic)
def connect_network(self, net: NetSim) -> None: def connect_network(self, net: NetSim) -> None:
"""Connect this network to the listening peer `net`""" """Connect this network to the listening peer `net`"""
net.net_listen.append(self) net.net_listen.append(self)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment