def in6_ifaceidtomac(ifaceid):
 try:
  ifaceid = inet_pton(socket.AF_INET6, ('::' + ifaceid))[8:16]
 except:
  return None
 if (ifaceid[3:5] != '\xff\xfe'):
  return None
 first = struct.unpack('B', ifaceid[:1])[0]
 ulbit = (2 * [1, '-', 0][(first & 2)])
 first = struct.pack('B', ((first & 253) | ulbit))
 oui = (first + ifaceid[1:3])
 end = ifaceid[5:]
 l = map((lambda x: ('%.02x' % struct.unpack('B', x)[0])), list((oui + end)))
 return ':'.join(l)

def in6_ifaceidtomac ( ifaceid ) : try : ifaceid = inet_pton ( socket . AF_INET6 , ( '::' + ifaceid ) ) [ 8 : 16 ] except : return None if ( ifaceid [ 3 : 5 ] != '\xff\xfe' ) : return None first = struct . unpack ( 'B' , ifaceid [ : 1 ] ) [ 0 ] ulbit = ( 2 * [ 1 , '-' , 0 ] [ ( first & 2 ) ] ) first = struct . pack ( 'B' , ( ( first & 253 ) | ulbit ) ) oui = ( first + ifaceid [ 1 : 3 ] ) end = ifaceid [ 5 : ] l = map ( ( lambda x : ( '%.02x' % struct . unpack ( 'B' , x ) [ 0 ] ) ) , list ( ( oui + end ) ) ) return ':' . join ( l )
extract the mac address from provided iface id .