def in6_getRandomizedIfaceId(ifaceid, previous=None):
 s = ''
 if (previous is None):
  d = ''.join(map(chr, range(256)))
  for i in range(8):
   s += random.choice(d)
  previous = s
 s = (inet_pton(socket.AF_INET6, ('::' + ifaceid))[8:] + previous)
 import md5
 s = md5.new(s).digest()
 (s1, s2) = (s[:8], s[8:])
 s1 = (chr((ord(s1[0]) | 4)) + s1[1:])
 s1 = inet_ntop(socket.AF_INET6, (('\xff' * 8) + s1))[20:]
 s2 = inet_ntop(socket.AF_INET6, (('\xff' * 8) + s2))[20:]
 return (s1, s2)

def in6_getRandomizedIfaceId ( ifaceid , previous = None ) : s = '' if ( previous is None ) : d = '' . join ( map ( chr , range ( 256 ) ) ) for i in range ( 8 ) : s += random . choice ( d ) previous = s s = ( inet_pton ( socket . AF_INET6 , ( '::' + ifaceid ) ) [ 8 : ] + previous ) import md5 s = md5 . new ( s ) . digest ( ) ( s1 , s2 ) = ( s [ : 8 ] , s [ 8 : ] ) s1 = ( chr ( ( ord ( s1 [ 0 ] ) | 4 ) ) + s1 [ 1 : ] ) s1 = inet_ntop ( socket . AF_INET6 , ( ( '\xff' * 8 ) + s1 ) ) [ 20 : ] s2 = inet_ntop ( socket . AF_INET6 , ( ( '\xff' * 8 ) + s2 ) ) [ 20 : ] return ( s1 , s2 )
implements the interface id generation algorithm described in rfc 3041 .