forked from freifunk-franken/firmware
Adrian Schmutzler
858930547b
The SPDX license identifier provides a standardized way for specifying licenses that is both human- and machine-readable. It is used upstream both in OpenWrt and the Linux kernel. Replace licenses in our repository by those identifiers. The full-text licenses corresponding to these identifiers are provided in the LICENSES folder. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Acked-by: Fabian Bläse <fabian@blaese.de>
43 lines
945 B
Plaintext
43 lines
945 B
Plaintext
# SPDX-License-Identifier: GPL-3.0-only
|
|
#
|
|
# Copyright 2017 Adrian Schmutzler
|
|
|
|
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
|
|
}
|