Revert "better mac matching"

This reverts commit ac5c4b5693.
alfred-data
Nils Schneider 2012-08-20 22:59:32 +02:00
parent ac5c4b5693
commit ac10d7aabc
1 changed files with 13 additions and 32 deletions

View File

@ -284,19 +284,9 @@ class NodeDB:
if data[2]:
node.name = data[2]
# 1043nd, vpn, wlan, br-wan
# compares two MACs and decides whether they are
# similar and could be from the same node
def is_similar(a, b):
# a is the base address
# b is some mac of the host
# b = 00:00:00:00:00:+1 x
# |2:00:00:+1:00:+1 x
# |2:00:00:00:00:+1 x
# |2:00:00:00:00:+2
# |2:00:00:+1:00:00
if a == b:
return True
@ -306,29 +296,20 @@ def is_similar(a, b):
except ValueError:
return False
x = mac_a
x[5] += 1
if mac_b == x:
return True
x[0] |= 2
if mac_b == x:
return True
x[3] += 1
if mac_b == x:
return True
x = mac_a
x[0] |= 2
x[5] += 2
if mac_b == x:
return True
x = mac_a
x[0] |= 2
x[3] += 1
if mac_b == x:
return True
# first byte must only differ in bit 2
if mac_a[0] | 2 == mac_b[0] | 2:
# count different bytes
c = [x for x in zip(mac_a[1:], mac_b[1:]) if x[0] != x[1]]
else:
return False
# no more than two additional bytes must differ
if len(c) <= 2:
delta = 0
if len(c) > 0:
delta = sum(abs(i[0] -i[1]) for i in c)
# These addresses look pretty similar!
return delta < 8