[package] iproute2: update to 3.2.0 and package 'ss'
[openwrt.git] / package / switch / files / switch.sh
1 #!/bin/sh
2 # Copyright (C) 2006-2010 OpenWrt.org
3
4 setup_switch_hw() {
5 local dev="$1"
6 local enable reset evlan
7
8 config_get_bool enable "$dev" enable 1
9 config_get_bool evlan "$dev" enable_vlan 1
10 config_get_bool reset "$dev" reset 1
11
12 local proc="/proc/switch/$dev"
13 [ -d "$proc" ] && {
14 ifconfig "$dev" up
15 echo "$reset" > "$proc/reset"
16 echo "$evlan" > "$proc/enable_vlan"
17 [ -f "$proc/enable" ] && echo "$enable" > "$proc/enable"
18 }
19
20 local vlan
21 for vlan in `seq 0 15`; do
22 proc="/proc/switch/$dev/vlan/$vlan/ports"
23 [ -f "$proc" ] && echo "" > "$proc"
24 done
25 }
26
27 setup_switch_vlan() {
28 local s="$1"
29 local dev vlan ports
30
31 config_get dev "$s" device
32 config_get vlan "$s" vlan
33 config_get ports "$s" ports
34
35 [ -n "$dev" ] && [ -n "$vlan" ] && {
36 ports="${ports%\*}"
37
38 [ "$_vlan_pvid_set" = 1 ] || {
39 ports="$ports*"
40 _vlan_pvid_set=1
41 }
42
43 local proc="/proc/switch/$dev/vlan/$vlan/ports"
44 [ -f "$proc" ] && echo "$ports" > "$proc"
45 }
46 }
47
48 setup_switch() {
49 _vlan_pvid_set=0
50 config_load network
51 config_foreach setup_switch_hw switch
52 config_foreach setup_switch_vlan switch_vlan
53 }
This page took 0.045228 seconds and 5 git commands to generate.