ldap_crans: valeur "<automatique>" pour champ mac
Et on vire l'ipv6 dans ce cas.
This commit is contained in:
parent
5c9e740f73
commit
ff88440f2e
3 changed files with 22 additions and 3 deletions
|
@ -24,7 +24,11 @@ import netaddr
|
|||
|
||||
def mac_to_ipv6(ipv6_prefix, mac_address):
|
||||
"""Convert a MAC address (EUI48) to an IPv6 (prefix::EUI64)."""
|
||||
if mac_address == '<automatique>':
|
||||
return ''
|
||||
|
||||
if type(mac_address) in [str, unicode]:
|
||||
mac_address = netaddr.EUI(mac_address)
|
||||
addr = int(mac_address.bits(netaddr.mac_bare), 2)
|
||||
ip6addr = (((addr >> 24) ^ (1 << 17)) << 40) | (0xFFFE << 24) | (addr & 0xFFFFFF)
|
||||
n = netaddr.IPNetwork(ipv6_prefix)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue