def in6_get_common_plen(a, b):
 def matching_bits(byte1, byte2):
  for i in xrange(8):
   cur_mask = (128 >> i)
   if ((byte1 & cur_mask) != (byte2 & cur_mask)):
    return i
  return 8
 tmpA = inet_pton(socket.AF_INET6, a)
 tmpB = inet_pton(socket.AF_INET6, b)
 for i in xrange(16):
  mbits = matching_bits(ord(tmpA[i]), ord(tmpB[i]))
  if (mbits != 8):
   return ((8 * i) + mbits)
 return 128

def in6_get_common_plen ( a , b ) : def matching_bits ( byte1 , byte2 ) : for i in xrange ( 8 ) : cur_mask = ( 128 >> i ) if ( ( byte1 & cur_mask ) != ( byte2 & cur_mask ) ) : return i return 8 tmpA = inet_pton ( socket . AF_INET6 , a ) tmpB = inet_pton ( socket . AF_INET6 , b ) for i in xrange ( 16 ) : mbits = matching_bits ( ord ( tmpA [ i ] ) , ord ( tmpB [ i ] ) ) if ( mbits != 8 ) : return ( ( 8 * i ) + mbits ) return 128
return common prefix length of ipv6 addresses a and b .