forked from freifunk-franken/firmware
Adrian Schmutzler
0092713196
The owipcalc tool provides an "add" algorithm which can be used to concateneted IPv6 addresses from prefix and suffix. Since it's available upstream and our string manipulation is ugly, let's replace our IP concatenation with that tool. The package consists of a single .c file with about 1000 lines resulting in about 4 kB for the ipk package. This patch does _not_ introduce any conceptual changes yet. Thus, the "wrong" IPv6 prefix from KeyXchange will be expected in the same format, it is just healed for the new code for now. The change allows to get rid of some bloat, i.e. some quite trivial custom functions on the way. This also drops the ipTidyColon() function, as owipcalc seems to return the collapsed version by default. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Reviewed-by: Fabian Bläse <fabian@blaese.de>
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
|
|
}
|