Skip to content
Snippets Groups Projects
Commit fb2f6523 authored by Bob Lantz's avatar Bob Lantz
Browse files

Changed mininet.link() to support multiple links.

It should also probably be renamed to something like:
configLinks(src, dst, status).
parent 178a3d84
No related branches found
No related tags found
No related merge requests found
......@@ -521,16 +521,11 @@ def link( self, status, src, dst ):
elif dst not in self.nameToNode:
error( 'dst not in network: %s\n' % dst )
else:
srcNode = self.nameToNode[ src ]
dstNode = self.nameToNode[ dst ]
srcID = int( src[ 1: ] )
dstID = int( dst[ 1: ] )
if self.topo.port( srcID, dstID ) is None:
srcNode, dstNode = self.nameToNode[ src ], self.nameToNode[ dst ]
connections = srcNode.connectionsTo( dstNode )
if len( connections ) == 0:
error( 'src and dst not connected: %s %s\n' % ( src, dst) )
else:
srcPort, dstPort = self.topo.port( srcID, dstID )
srcIntf = srcNode.intfs[ srcPort ]
dstIntf = dstNode.intfs[ dstPort ]
for srcIntf, dstIntf in connections:
result = srcNode.cmd( [ 'ifconfig', srcIntf, status ] )
if result:
error( 'link src status change failed: %s\n' % result )
......
......@@ -261,6 +261,16 @@ def registerIntf( self, intf, dstNode, dstIntf ):
"Register connection of intf to dstIntf on dstNode."
self.connection[ intf ] = ( dstNode, dstIntf )
def connectionsTo( self, node):
"Return [(srcIntf, dstIntf)..] for connections to dstNode."
# We could optimize this if it is important
connections = []
for intf in self.connection.keys():
dstNode, dstIntf = self.connection[ intf ]
if dstNode == node:
connections.append( ( intf, dstIntf ) )
return connections
# This is a symmetric operation, but it makes sense to put
# the code here since it is tightly coupled to routines in
# this class. For a more symmetric API, you can use
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment