OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 18... | Line 18... | |||
18 | |
18 | |
|
19 | [ -d /dev/mtd ] && PREFIX=/dev/mtd/ |
19 | [ -d /dev/mtd ] && PREFIX=/dev/mtd/ |
|
20 | echo "${INDEX:+$PREFIX$INDEX}" |
20 | echo "${INDEX:+$PREFIX$INDEX}" |
|
Line 21... | Line 21... | |||
21 | } |
21 | } |
|
- | 22 | |
||
22 | |
23 | mtd_get_mac_ascii() |
|
23 | mtd_get_mac_ascii() { |
24 | { |
|
24 | local mtdname="$1" |
25 | local mtdname="$1" |
|
25 | local key="$2" |
26 | local key="$2" |
|
Line 36... | Line 37... | |||
36 | |
37 | |
|
37 | # "canonicalize" mac |
38 | # "canonicalize" mac |
|
38 | [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty" |
39 | [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty" |
|
Line 39... | Line -... | |||
39 | } |
- | ||
40 | |
- | ||
41 | mtd_get_mac_text() { |
- | ||
42 | local mtdname=$1 |
- | ||
43 | local offset=$2 |
- | ||
44 | local part |
- | ||
45 | local mac_dirty |
- | ||
46 | |
- | ||
47 | part=$(find_mtd_part "$mtdname") |
- | ||
48 | if [ -z "$part" ]; then |
- | ||
49 | echo "mtd_get_mac_text: partition $mtdname not found!" >&2 |
- | ||
50 | return |
- | ||
51 | fi |
- | ||
52 | |
- | ||
53 | if [ -z "$offset" ]; then |
- | ||
54 | echo "mtd_get_mac_text: offset missing!" >&2 |
- | ||
55 | return |
- | ||
56 | fi |
- | ||
57 | |
- | ||
58 | mac_dirty=$(dd if="$part" bs=1 skip="$offset" count=17 2>/dev/null) |
- | ||
59 | |
- | ||
60 | # "canonicalize" mac |
- | ||
61 | [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty" |
- | ||
62 | } |
40 | } |
|
63 | |
41 | |
|
64 | mtd_get_mac_binary() { |
42 | mtd_get_mac_binary() { |
|
65 | local mtdname="$1" |
43 | local mtdname="$1" |
|
Line 107... | Line 85... | |||
107 | |
85 | |
|
108 | nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/') |
86 | nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/') |
|
109 | echo $oui:$nic |
87 | echo $oui:$nic |
|
Line 110... | Line 88... | |||
110 | } |
88 | } |
|
- | 89 | |
||
111 | |
90 | macaddr_setbit_la() |
|
Line 112... | Line 91... | |||
112 | macaddr_setbit_la() { |
91 | { |
|
113 | local mac=$1 |
92 | local mac=$1 |
|
Line 114... | Line 93... | |||
114 | |
93 | |
|
- | 94 | printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:} |
||
115 | printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:} |
95 | } |
|
Line 116... | Line 96... | |||
116 | } |
96 | |
|
117 | |
97 | macaddr_2bin() |
|
Line 118... | Line 98... | |||
118 | macaddr_2bin() { |
98 | { |
|
- | 99 | local mac=$1 |
||
119 | local mac=$1 |
100 | |
|
120 | |
101 | echo -ne \\x${mac//:/\\x} |
|
Line 121... | Line 102... | |||
121 | echo -ne \\x${mac//:/\\x} |
102 | } |
|
122 | } |
103 | |