Revision f11dbe81 mininet/util.py

View differences:

mininet/util.py
192 192
        cmdOutput = srcNode.cmd( cmd )
193 193
    else:
194 194
        cmdOutput = quietRun( cmd )
195
    if output:
195
    if cmdOutput:
196 196
        if printError:
197 197
            error( '*** Error: moveIntf: ' + intf +
198 198
                   ' not successfully moved to ' + dstNode.name + '\n' )
......
249 249
    chStr = ':'.join( pieces )
250 250
    return chStr
251 251

  
252
def generateMac( self ):
253
    newMac = True
254
    while True:
255
        macList = [ 0x00 ]
256
        for i in xrange ( 0, 5 ):
257
            macList.append( random.randint( 0x00, 0xff ) )
258
        mac = ':'.join( map(lambda x: "%02x" % x, macList ) )
259
        for node in self.switches + self.hosts:
260
            for intf in node.ports:
261
                if intf.mac == mac:
262
                    newMac = False
263
                    break
264
        if newMac:
265
            return mac
266

  
252 267
def macColonHex( mac ):
253 268
    """Generate MAC colon-hex string from unsigned int.
254 269
       mac: MAC address as unsigned int
255 270
       returns: macStr MAC colon-hex string"""
256
    return _colonHex( mac, 6 )
271
    if mac < 2**24:
272
        return 'A4:23:05:' + _colonHex( mac, 3 )
273
    else:
274
        return _colonHex( mac, 6 )
257 275

  
258 276
def ipStr( ip ):
259 277
    """Generate IP address string from an unsigned int.

Also available in: Unified diff