source: trunk/package/switch/files/switch.sh @ 19909

Last change on this file since 19909 was 19909, checked in by jow, 7 years ago

[package] switch:

eliminate the asterisk from the switch port configuration and set it
automatically on the first vlan, this aligns the broadcom vlan config
with the swconfig format

  • Property svn:eol-style set to native
File size: 930 bytes
Line 
1#!/bin/sh
2# Copyright (C) 2006-2009 OpenWrt.org
3
4setup_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                echo "$reset"  > "$proc/reset"
15                echo "$evlan"  > "$proc/enable_vlan"
16                echo "$enable" > "$proc/enable"
17        }
18}
19
20setup_switch_vlan() {
21        local s="$1"
22        local dev vlan ports
23
24        config_get dev   "$s" device
25        config_get vlan  "$s" vlan
26        config_get ports "$s" ports
27
28        [ -n "$dev" ] && [ -n "$vlan" ] && {
29                ports="${ports%\*}"
30
31                [ "$_vlan_pvid_set" = 1 ] || {
32                        ports="$ports*"
33                        _vlan_pvid_set=1
34                }
35
36                local proc="/proc/switch/$dev/vlan/$vlan/ports"
37                [ -f "$proc" ] && echo "$ports" > "$proc"
38        }
39}
40
41setup_switch() {
42        _vlan_pvid_set=0
43        config_load network
44        config_foreach setup_switch_hw switch
45        config_foreach setup_switch_vlan switch_vlan
46}
Note: See TracBrowser for help on using the repository browser.