summaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-02-16 11:50:22 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-02-16 11:50:22 +0000
commitce72a70117e7c04466dd5ddde008d9c718c5f09c (patch)
tree5ecdf853fe8994bf67dee90bb29dc9919e0c889f /package
parent167702283be513e96391b3f64dff151a4999104e (diff)
base-files: add macaddr_{add,2bin,setbit_la} helpers
Signed-off-by: Gabor Juhos <juhosg@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35614 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r--package/base-files/Makefile2
-rwxr-xr-xpackage/base-files/files/lib/functions.sh24
2 files changed, 25 insertions, 1 deletions
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 26fa1b723..789b5f679 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/version.mk
PKG_NAME:=base-files
-PKG_RELEASE:=132
+PKG_RELEASE:=133
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
PKG_BUILD_DEPENDS:=opkg/host
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 2022e8a3a..a488f4dc0 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -274,6 +274,30 @@ mtd_get_mac_binary() {
dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"'
}
+macaddr_add() {
+ local mac=$1
+ local val=$2
+ local oui=${mac%:*:*:*}
+ local nic=${mac#*:*:*:}
+
+ nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
+ echo $oui:$nic
+}
+
+macaddr_setbit_la()
+{
+ local mac=$1
+
+ printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:}
+}
+
+macaddr_2bin()
+{
+ local mac=$1
+
+ echo -ne \\x${mac//:/\\x}
+}
+
strtok() { # <string> { <variable> [<separator>] ... }
local tmp
local val="$1"