forked from freifunk-franken/firmware
42 lines
919 B
Plaintext
42 lines
919 B
Plaintext
# Copyright 2017 Adrian Schmutzler
|
|
# License GPLv3
|
|
|
|
ipMacSuffix() {
|
|
# Returns the lower 64 bits of an IPv6 address (0:aabb:ccdd:eeff)
|
|
# based on the provided MAC address (aa:bb:cc:bb:ee:ff)
|
|
#
|
|
# Argument: MAC address (with colons)
|
|
|
|
[ $# -ne "1" ] && return 1
|
|
|
|
local mac=$1
|
|
|
|
echo "$mac" | awk -F: '{ print "0:"$1$2":"$3$4":"$5$6 }'
|
|
return 0
|
|
}
|
|
|
|
ipEUISuffix() {
|
|
# Returns the EUI (interface ID, a8bb:ccff:fedd:eeff)
|
|
# based on the provided MAC address (aa:bb:cc:bb:ee:ff)
|
|
#
|
|
# Argument: MAC address (with colons)
|
|
|
|
[ $# -ne "1" ] && return 1
|
|
|
|
local mac=$1
|
|
|
|
echo "$mac" | awk -F: '{ printf("%02x%s:%sff:fe%s:%s%s\n", xor(("0x"$1),2), $2, $3, $4, $5, $6) }'
|
|
return 0
|
|
}
|
|
|
|
macFlipLocalBit() {
|
|
# Returns given MAC-address with locally administered bit flipped
|
|
#
|
|
# Argument: MAC-address
|
|
|
|
local mac=$1
|
|
|
|
echo "$mac" | awk -F: '{ printf("%02x:%s:%s:%s:%s:%s\n", xor(("0x"$1),2), $2, $3, $4, $5, $6) }'
|
|
return 0
|
|
}
|