def mac2eui64(mac, prefix=None):
 eui64 = re.sub('[.:-]', '', mac).lower()
 eui64 = ((eui64[0:6] + 'fffe') + eui64[6:])
 eui64 = (hex((int(eui64[0:2], 16) | 2))[2:].zfill(2) + eui64[2:])
 if (prefix is None):
  return ':'.join(re.findall('.{4}', eui64))
 else:
  try:
   net = ipaddress.ip_network(prefix, strict=False)
   euil = int('0x{0}'.format(eui64), 16)
   return '{0}/{1}'.format(net[euil], net.prefixlen)
  except:
   return

def mac2eui64 ( mac , prefix = None ) : eui64 = re . sub ( '[.:-]' , '' , mac ) . lower ( ) eui64 = ( ( eui64 [ 0 : 6 ] + 'fffe' ) + eui64 [ 6 : ] ) eui64 = ( hex ( ( int ( eui64 [ 0 : 2 ] , 16 ) | 2 ) ) [ 2 : ] . zfill ( 2 ) + eui64 [ 2 : ] ) if ( prefix is None ) : return ':' . join ( re . findall ( '.{4}' , eui64 ) ) else : try : net = ipaddress . ip_network ( prefix , strict = False ) euil = int ( '0x{0}' . format ( eui64 ) , 16 ) return '{0}/{1}' . format ( net [ euil ] , net . prefixlen ) except : return
convert a mac address to a eui64 identifier or .