echo "${INDEX:+$PREFIX$INDEX}"
}
+get_mac_ascii() {
+ local part="$1"
+ local key="$2"
+ local mac_dirty
+
+ mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
+
+ # "canonicalize" mac
+ [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
+}
+
mtd_get_mac_ascii() {
local mtdname="$1"
local key="$2"
local part
- local mac_dirty
part=$(find_mtd_part "$mtdname")
if [ -z "$part" ]; then
return
fi
- mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
-
- # "canonicalize" mac
- [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
+ get_mac_ascii "$part" "$key"
}
mtd_get_mac_encrypted_arcadyan() {
echo $macaddr
}
+mtd_get_mac_uci_config_ubi() {
+ local volumename="$1"
+
+ . /lib/upgrade/nand.sh
+
+ local ubidev=$(nand_attach_ubi $CI_UBIPART)
+ local part=$(nand_find_volume $ubidev $volumename)
+
+ cat "/dev/$part" | sed -n 's/^\s*option macaddr\s*'"'"'\?\([0-9A-F:]\+\)'"'"'\?/\1/Ip'
+}
+
mtd_get_mac_text() {
- local mtdname=$1
- local offset=$(($2))
+ local mtdname="$1"
+ local offset=$((${2:-0}))
+ local length="${3:-17}"
local part
- local mac_dirty
part=$(find_mtd_part "$mtdname")
if [ -z "$part" ]; then
return
fi
- if [ -z "$offset" ]; then
- echo "mtd_get_mac_text: offset missing!" >&2
- return
- fi
-
- mac_dirty=$(dd if="$part" bs=1 skip="$offset" count=17 2>/dev/null)
+ [ $((offset + length)) -le $(mtd_get_part_size "$mtdname") ] || return
- # "canonicalize" mac
- [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
+ macaddr_canonicalize $(dd bs=1 if="$part" skip="$offset" count="$length" 2>/dev/null)
}
mtd_get_mac_binary() {
done < /proc/mtd
}
+mmc_get_mac_ascii() {
+ local part_name="$1"
+ local key="$2"
+ local part
+
+ part=$(find_mmc_part "$part_name")
+ if [ -z "$part" ]; then
+ echo "mmc_get_mac_ascii: partition $part_name not found!" >&2
+ return
+ fi
+
+ get_mac_ascii "$part" "$key"
+}
+
mmc_get_mac_binary() {
local part_name="$1"
local offset="$2"
echo "$(macaddr_unsetbit_mc "$(macaddr_setbit_la "${randsrc}")")"
}
-macaddr_2bin() {
- local mac=$1
-
- echo -ne \\x${mac//:/\\x}
-}
-
macaddr_canonicalize() {
local mac="$1"
local canon=""