Add support for unicast ethernet faces to utility and helper methods.
Refs #5321
Change-Id: I2e28d092853fc21f59109cfbc23b946d30626a8c
diff --git a/minindn/apps/nlsr.py b/minindn/apps/nlsr.py
index 12a12d7..43da64f 100644
--- a/minindn/apps/nlsr.py
+++ b/minindn/apps/nlsr.py
@@ -30,7 +30,7 @@
from mininet.node import Switch
from minindn.apps.application import Application
-from minindn.util import scp, copyExistentFile
+from minindn.util import scp, copyExistentFile, MACToEther
from minindn.helpers.nfdc import Nfdc
from minindn.minindn import Minindn
@@ -41,7 +41,7 @@
SYNC_PSYNC = 'psync'
def __init__(self, node, logLevel='NONE', security=False, sync=SYNC_PSYNC,
- faceType='udp', nFaces=3, routingType=ROUTING_LINK_STATE, faceDict=None):
+ faceType=Nfdc.PROTOCOL_UDP, nFaces=3, routingType=ROUTING_LINK_STATE, faceDict=None):
Application.__init__(self, node)
try:
from mn_wifi.node import Node_wifi
@@ -92,7 +92,8 @@
warn('Check that each node has one radius value and one or two angle value(s).')
sys.exit(1)
- self.neighborIPs = []
+ self.neighborLocations = []
+ self.interfaceForNeighbor = dict()
possibleConfPaths = ['/usr/local/etc/ndn/nlsr.conf.sample', '/etc/ndn/nlsr.conf.sample']
copyExistentFile(node, possibleConfPaths, '{}/nlsr.conf'.format(self.homeDir))
@@ -107,8 +108,12 @@
Minindn.sleep(1)
def createFaces(self):
- for ip in self.neighborIPs:
- Nfdc.createFace(self.node, ip, self.faceType, isPermanent=True)
+ for location in self.neighborLocations:
+ if self.faceType == Nfdc.PROTOCOL_ETHER:
+ localIntf = self.interfaceForNeighbor[location]
+ Nfdc.createFace(self.node, location, self.faceType, localInterface=localIntf, isPermanent=True)
+ else:
+ Nfdc.createFace(self.node, location, self.faceType, isPermanent=True)
@staticmethod
def createKey(host, name, outputFile):
@@ -224,19 +229,27 @@
if node1 == self.node:
other = node2
- ip = other.IP(str(link.intf2))
+ if self.faceType == Nfdc.PROTOCOL_ETHER:
+ location = MACToEther(link.intf2.MAC())
+ else:
+ location = link.intf2.IP()
else:
other = node1
- ip = other.IP(str(link.intf1))
+ if self.faceType == Nfdc.PROTOCOL_ETHER:
+ location = MACToEther(link.intf1.MAC())
+ else:
+ location = link.intf1.IP()
linkCost = intf.params.get('delay', '10ms').replace('ms', '')
- self.neighborIPs.append(ip)
+ self.neighborLocations.append(location)
+ if self.faceType == Nfdc.PROTOCOL_ETHER:
+ self.interfaceForNeighbor[location] = intf
self.node.cmd('{} -a neighbors.neighbor \
<<<\'name {}{}-site/%C1.Router/cs/{} face-uri {}://{}\n link-cost {}\''
.format(self.infocmd, self.network, other.name, other.name,
- self.faceType, ip, linkCost))
+ self.faceType, location, linkCost))
def __editNeighborsSectionManual(self):