2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 .
/lib
/network
/header-zone
24 HOOK_SETTINGS
="HOOK STP STP_FORWARD_DELAY STP_HELLO STP_MAXAGE MAC MTU"
37 assert isinteger STP_HELLO
38 assert isinteger STP_FORWARD_DELAY
42 function _parse_cmdline
() {
43 while [ $# -gt 0 ]; do
49 STP_HELLO
=${1#--stp-hello=}
51 --stp-forward-delay=*)
52 STP_FORWARD_DELAY
=${1#--stp-forward-delay=}
61 warning
"Ignoring unknown option '${1}'"
72 config_read
${ZONE_DIR}/${zone}/settings
74 if ! device_exists
${zone}; then
78 [ -n "${MAC}" ] && device_set_address ${zone} ${MAC}
79 [ -n "${MTU}" ] && device_set_mtu ${zone} ${MTU}
85 if [ -n "${STP_FORWARD_DELAY}" ]; then
86 brctl setfd
${zone} ${STP_FORWARD_DELAY}
89 if [ -n "${STP_HELLO}" ]; then
90 brctl sethello
${zone} ${STP_HELLO}
93 if [ -n "${STP_MAXAGE}" ]; then
94 brctl setmaxage
${zone} ${STP_MAXAGE}
100 device_set_up
${zone}
103 zone_ports_up
${zone}
105 # XXX Do we need this?
106 # Wait until bridge is forwarding
107 # which is needed by dhcp client
108 #if enabled STP; then
109 # bridge_is_forwarding ${zone}
112 zone_configs_up
${zone}
114 event_interface_up
${zone}
123 if ! device_is_up
${zone}; then
124 warning
"Zone '${zone}' is not up"
128 event_interface_down
${zone}
130 zone_configs_down
${zone}
131 zone_ports_down
${zone}
133 device_set_down
${zone}
142 cli_status_headline
${zone}
144 # Exit if zone is down
145 if ! zone_is_up
${zone}; then
150 cli_headline
" Spanning Tree Protocol information:"
151 echo " Bridge ID : $(stp_bridge_id ${zone})"
152 echo " Designated root : $(stp_designated_root ${zone})"
153 echo " Path cost : $(stp_pathcost ${zone})"
156 # Topology information
157 printf " Topology changing : %6s\n" $
(stp_topology_change
${zone})
158 printf " Topology change time : %6s\n" $
(stp_topology_change_time
${zone})
159 printf " Topology change count : %6s\n" $
(stp_topology_change_count
${zone})
161 cli_headline
" Ports:"
162 zone_ports_cmd status
${zone}
164 cli_headline
" Configurations:"
165 zone_configs_cmd status
${zone}
171 function _addport
() {
176 if ! hook_exists port
${hook}; then
177 error
"Hook does not exist '${hook}'"
181 port_hook
${hook} add
${zone}