updated newveth and newtuntap function to remove the net parameter, since it was not being used

This commit is contained in:
bharnden 2019-10-23 09:02:24 -07:00
parent 28d1803af6
commit 3dccd073f2
2 changed files with 9 additions and 11 deletions

View file

@ -634,13 +634,12 @@ class CoreNode(CoreNodeBase):
with self.lock:
return super(CoreNode, self).newifindex()
def newveth(self, ifindex=None, ifname=None, net=None):
def newveth(self, ifindex=None, ifname=None):
"""
Create a new interface.
:param int ifindex: index for the new interface
:param str ifname: name for the new interface
:param core.nodes.base.CoreNetworkBase net: network to associate interface with
:return: nothing
"""
with self.lock:
@ -692,13 +691,12 @@ class CoreNode(CoreNodeBase):
return ifindex
def newtuntap(self, ifindex=None, ifname=None, net=None):
def newtuntap(self, ifindex=None, ifname=None):
"""
Create a new tunnel tap.
:param int ifindex: interface index
:param str ifname: interface name
:param net: network to associate with
:return: interface index
:rtype: int
"""
@ -803,7 +801,7 @@ class CoreNode(CoreNodeBase):
with self.lock:
# TODO: emane specific code
if net.is_emane is True:
ifindex = self.newtuntap(ifindex=ifindex, ifname=ifname, net=net)
ifindex = self.newtuntap(ifindex, ifname)
# TUN/TAP is not ready for addressing yet; the device may
# take some time to appear, and installing it into a
# namespace after it has been bound removes addressing;
@ -815,7 +813,7 @@ class CoreNode(CoreNodeBase):
netif.addaddr(address)
return ifindex
else:
ifindex = self.newveth(ifindex=ifindex, ifname=ifname, net=net)
ifindex = self.newveth(ifindex, ifname)
if net is not None:
self.attachnet(ifindex, net)

View file

@ -60,7 +60,7 @@ class CoreNs3Node(CoreNode, ns.network.Node):
if not isinstance(net, CoreNs3Net):
return CoreNode.newnetif(self, net, addrlist, hwaddr, ifindex, ifname)
ifindex = self.newtuntap(ifindex=ifindex, ifname=ifname, net=net)
ifindex = self.newtuntap(ifindex, ifname)
self.attachnet(ifindex, net)
netif = self.netif(ifindex)
netif.sethwaddr(hwaddr)
@ -68,7 +68,7 @@ class CoreNs3Node(CoreNode, ns.network.Node):
netif.addaddr(addr)
addrstr = netif.addrlist[0]
(addr, mask) = addrstr.split('/')
addr, mask = addrstr.split('/')
tap = net._tapdevs[netif]
tap.SetAttribute(
"IpAddress",
@ -76,9 +76,9 @@ class CoreNs3Node(CoreNode, ns.network.Node):
)
tap.SetAttribute(
"Netmask",
ns.network.Ipv4MaskValue(ns.network.Ipv4Mask("/" + mask))
ns.network.Ipv4MaskValue(ns.network.Ipv4Mask(f"/{mask}"))
)
ns.core.Simulator.Schedule(ns.core.Time('0'), netif.install)
ns.core.Simulator.Schedule(ns.core.Time("0"), netif.install)
return ifindex
def getns3position(self):
@ -118,7 +118,7 @@ class CoreNs3Net(CoreNetworkBase):
type = "wlan"
def __init__(
self, session, _id=None, name=None, start=True, server=None, policy=None
self, session, _id=None, name=None, start=True, server=None
):
CoreNetworkBase.__init__(self, session, _id, name, start, server)
self.tapbridge = ns.tap_bridge.TapBridgeHelper()