def in6_mactoifaceid(mac, ulbit=None):
 if (len(mac) != 17):
  return None
 m = ''.join(mac.split(':'))
 if (len(m) != 12):
  return None
 first = int(m[0:2], 16)
 if ((ulbit is None) or (not ((ulbit == 0) or (ulbit == 1)))):
  ulbit = [1, '-', 0][(first & 2)]
 ulbit *= 2
 first = ('%.02x' % ((first & 253) | ulbit))
 eui64 = (((((((first + m[2:4]) + ':') + m[4:6]) + 'FF:FE') + m[6:8]) + ':') + m[8:12])
 return eui64.upper()

def in6_mactoifaceid ( mac , ulbit = None ) : if ( len ( mac ) != 17 ) : return None m = '' . join ( mac . split ( ':' ) ) if ( len ( m ) != 12 ) : return None first = int ( m [ 0 : 2 ] , 16 ) if ( ( ulbit is None ) or ( not ( ( ulbit == 0 ) or ( ulbit == 1 ) ) ) ) : ulbit = [ 1 , '-' , 0 ] [ ( first & 2 ) ] ulbit *= 2 first = ( '%.02x' % ( ( first & 253 ) | ulbit ) ) eui64 = ( ( ( ( ( ( ( first + m [ 2 : 4 ] ) + ':' ) + m [ 4 : 6 ] ) + 'FF:FE' ) + m [ 6 : 8 ] ) + ':' ) + m [ 8 : 12 ] ) return eui64 . upper ( )
compute the interface id in modified eui-64 format associated to the ethernet address provided as input .