OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 25... | Line 25... | |||
25 | json_close_object |
25 | json_close_object |
|
Line 26... | Line 26... | |||
26 | |
26 | |
|
27 | json_select "$1" |
27 | json_select "$1" |
|
Line 28... | Line 28... | |||
28 | } |
28 | } |
|
29 | |
29 | |
|
30 | ucidef_set_interface() { |
- | ||
31 | local network=$1; shift |
- | ||
32 | |
- | ||
33 | [ -z "$network" ] && return |
- | ||
34 | |
- | ||
35 | json_select_object network |
- | ||
36 | json_select_object "$network" |
- | ||
37 | |
30 | _ucidef_set_interface() { |
|
38 | while [ -n "$1" ]; do |
31 | local name="$1" |
|
39 | local opt=$1; shift |
- | ||
40 | local val=$1; shift |
- | ||
Line -... | Line 32... | |||
- | 32 | local iface="$2" |
||
41 | |
33 | local proto="$3" |
|
42 | [ -n "$opt" -a -n "$val" ] || break |
- | ||
Line 43... | Line 34... | |||
43 | |
34 | |
|
44 | json_add_string "$opt" "$val" |
35 | json_select_object "$name" |
|
- | 36 | json_add_string ifname "$iface" |
||
- | 37 | |
||
- | 38 | if ! json_is_a protocol string || [ -n "$proto" ]; then |
||
45 | done |
39 | case "$proto" in |
|
46 | |
40 | static|dhcp|none|pppoe) : ;; |
|
47 | if ! json_is_a protocol string; then |
41 | *) |
|
- | 42 | case "$name" in |
||
- | 43 | lan) proto="static" ;; |
||
48 | case "$network" in |
44 | wan) proto="dhcp" ;; |
|
- | 45 | *) proto="none" ;; |
||
- | 46 | esac |
||
49 | lan) json_add_string protocol static ;; |
47 | ;; |
|
Line 50... | Line 48... | |||
50 | wan) json_add_string protocol dhcp ;; |
48 | esac |
|
51 | *) json_add_string protocol none ;; |
- | ||
52 | esac |
49 | |
|
Line 53... | Line 50... | |||
53 | fi |
50 | json_add_string protocol "$proto" |
|
54 | |
51 | fi |
|
55 | json_select .. |
52 | |
|
Line 67... | Line 64... | |||
67 | json_add_string name "$1" |
64 | json_add_string name "$1" |
|
68 | json_select .. |
65 | json_select .. |
|
69 | } |
66 | } |
|
Line 70... | Line 67... | |||
70 | |
67 | |
|
- | 68 | ucidef_set_interface_lan() { |
||
71 | ucidef_set_interface_lan() { |
69 | json_select_object network |
|
- | 70 | _ucidef_set_interface lan "$@" |
||
72 | ucidef_set_interface "lan" ifname "$1" protocol "${2:-static}" |
71 | json_select .. |
|
Line 73... | Line 72... | |||
73 | } |
72 | } |
|
- | 73 | |
||
74 | |
74 | ucidef_set_interface_wan() { |
|
- | 75 | json_select_object network |
||
75 | ucidef_set_interface_wan() { |
76 | _ucidef_set_interface wan "$@" |
|
Line 76... | Line 77... | |||
76 | ucidef_set_interface "wan" ifname "$1" protocol "${2:-dhcp}" |
77 | json_select .. |
|
77 | } |
78 | } |
|
78 | |
79 | |
|
Line -... | Line 80... | |||
- | 80 | ucidef_set_interfaces_lan_wan() { |
||
79 | ucidef_set_interfaces_lan_wan() { |
81 | local lan_if="$1" |
|
80 | local lan_if="$1" |
82 | local wan_if="$2" |
|
- | 83 | |
||
- | 84 | json_select_object network |
||
- | 85 | _ucidef_set_interface lan "$lan_if" |
||
- | 86 | _ucidef_set_interface wan "$wan_if" |
||
- | 87 | json_select .. |
||
- | 88 | } |
||
- | 89 | |
||
81 | local wan_if="$2" |
90 | ucidef_set_interface_raw() { |
|
Line 82... | Line 91... | |||
82 | |
91 | json_select_object network |
|
83 | ucidef_set_interface_lan "$lan_if" |
92 | _ucidef_set_interface "$@" |
|
84 | ucidef_set_interface_wan "$wan_if" |
93 | json_select .. |
|
Line 174... | Line 183... | |||
174 | json_get_var devices ifname |
183 | json_get_var devices ifname |
|
175 | if ! list_contains devices "$device"; then |
184 | if ! list_contains devices "$device"; then |
|
176 | devices="${devices:+$devices }$device" |
185 | devices="${devices:+$devices }$device" |
|
177 | fi |
186 | fi |
|
178 | json_select .. |
187 | json_select .. |
|
179 | json_select .. |
- | ||
Line 180... | Line 188... | |||
180 | |
188 | |
|
- | 189 | _ucidef_set_interface "$role" "$devices" |
||
181 | ucidef_set_interface "$role" ifname "$devices" |
190 | json_select .. |
|
182 | done |
191 | done |
|
Line 183... | Line 192... | |||
183 | } |
192 | } |
|
184 | |
193 | |
|
Line 289... | Line 298... | |||
289 | |
298 | |
|
290 | ucidef_set_interface_macaddr() { |
299 | ucidef_set_interface_macaddr() { |
|
291 | local network="$1" |
300 | local network="$1" |
|
Line -... | Line 301... | |||
- | 301 | local macaddr="$2" |
||
- | 302 | |
||
- | 303 | json_select_object network |
||
- | 304 | |
||
- | 305 | json_select "$network" |
||
- | 306 | [ $? -eq 0 ] || { |
||
- | 307 | json_select .. |
||
- | 308 | return |
||
292 | local macaddr="$2" |
309 | } |
|
- | 310 | |
||
- | 311 | json_add_string macaddr "$macaddr" |
||
- | 312 | json_select .. |
||
293 | |
313 | |
|
Line 294... | Line 314... | |||
294 | ucidef_set_interface "$network" macaddr "$macaddr" |
314 | json_select .. |
|
295 | } |
315 | } |
|
296 | |
316 | |
|
Line 440... | Line 460... | |||
440 | |
460 | |
|
441 | ucidef_set_led_switch() { |
461 | ucidef_set_led_switch() { |
|
442 | local trigger_name="$4" |
462 | local trigger_name="$4" |
|
443 | local port_mask="$5" |
463 | local port_mask="$5" |
|
444 | local speed_mask="$6" |
- | ||
Line 445... | Line 464... | |||
445 | local mode="$7" |
464 | local speed_mask="$6" |
|
Line 446... | Line 465... | |||
446 | |
465 | |
|
447 | _ucidef_set_led_common "$1" "$2" "$3" |
466 | _ucidef_set_led_common "$1" "$2" "$3" |
|
448 | |
- | ||
449 | json_add_string trigger "$trigger_name" |
467 | |
|
450 | json_add_string type switch |
468 | json_add_string trigger "$trigger_name" |
|
451 | json_add_string mode "$mode" |
469 | json_add_string type switch |
|
Line 452... | Line 470... | |||
452 | json_add_string port_mask "$port_mask" |
470 | json_add_string port_mask "$port_mask" |