Changeset 35614


Ignore:
Timestamp:
2013-02-16T12:50:22+01:00 (5 years ago)
Author:
juhosg
Message:

base-files: add macaddr_{add,2bin,setbit_la} helpers

Signed-off-by: Gabor Juhos <juhosg@…>

Location:
trunk/package/base-files
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/base-files/Makefile

    r35612 r35614  
    1212 
    1313PKG_NAME:=base-files 
    14 PKG_RELEASE:=132 
     14PKG_RELEASE:=133 
    1515 
    1616PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ 
  • trunk/package/base-files/files/lib/functions.sh

    r35612 r35614  
    273273 
    274274        dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"' 
     275} 
     276 
     277macaddr_add() { 
     278        local mac=$1 
     279        local val=$2 
     280        local oui=${mac%:*:*:*} 
     281        local nic=${mac#*:*:*:} 
     282 
     283        nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/') 
     284        echo $oui:$nic 
     285} 
     286 
     287macaddr_setbit_la() 
     288{ 
     289        local mac=$1 
     290 
     291        printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:} 
     292} 
     293 
     294macaddr_2bin() 
     295{ 
     296        local mac=$1 
     297 
     298        echo -ne \\x${mac//:/\\x} 
    275299} 
    276300 
Note: See TracChangeset for help on using the changeset viewer.