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 STP_PRIORITY"
25 HOOK_SETTINGS
="${HOOK_SETTINGS} MAC MTU"
34 STP_PRIORITY
=512 # XXX check out better value
39 assert isinteger STP_HELLO
40 assert isinteger STP_FORWARD_DELAY
41 assert isinteger STP_PRIORITY
45 function _parse_cmdline
() {
46 while [ $# -gt 0 ]; do
52 STP_HELLO
=${1#--stp-hello=}
54 --stp-forward-delay=*)
55 STP_FORWARD_DELAY
=${1#--stp-forward-delay=}
58 STP_PRIORITY
=${1#--stp-priority=}
67 warning
"Ignoring unknown option '${1}'"
78 config_read
${ZONE_DIR}/${zone}/settings
80 if ! device_exists
${zone}; then
84 [ -n "${MAC}" ] && device_set_address ${zone} ${MAC}
85 [ -n "${MTU}" ] && device_set_mtu ${zone} ${MTU}
91 if [ -n "${STP_FORWARD_DELAY}" ]; then
92 brctl setfd
${zone} ${STP_FORWARD_DELAY}
95 if [ -n "${STP_HELLO}" ]; then
96 brctl sethello
${zone} ${STP_HELLO}
99 if [ -n "${STP_MAXAGE}" ]; then
100 brctl setmaxage
${zone} ${STP_MAXAGE}
103 if [ -n "${STP_PRIORITY}" ]; then
104 brctl setbridgeprio
${zone} ${STP_PRIORITY}
107 brctl stp
${zone} off
110 device_set_up
${zone}
113 zone_ports_up
${zone}
115 # XXX Do we need this?
116 # Wait until bridge is forwarding
117 # which is needed by dhcp client
118 #if enabled STP; then
119 # bridge_is_forwarding ${zone}
122 zone_configs_up
${zone}
124 event_interface_up
${zone}
133 if ! device_is_up
${zone}; then
134 warning
"Zone '${zone}' is not up"
138 event_interface_down
${zone}
140 zone_configs_down
${zone}
141 zone_ports_down
${zone}
143 device_set_down
${zone}
152 cli_status_headline
${zone}
154 # Exit if zone is down
155 if ! zone_is_up
${zone}; then
160 # XXX Add bridge stp priority here
161 # brctl does not give any information about that
163 cli_headline
" Spanning Tree Protocol information:"
164 echo " Bridge ID : $(stp_bridge_id ${zone})"
165 echo " Designated root : $(stp_designated_root ${zone})"
166 echo " Path cost : $(stp_pathcost ${zone})"
169 # Topology information
170 printf " Topology changing : %6s\n" $
(stp_topology_change
${zone})
171 printf " Topology change time : %6s\n" $
(beautify_time $
(stp_topology_change_time
${zone}))
172 printf " Topology change count : %6s\n" $
(stp_topology_change_count
${zone})
174 cli_headline
" Ports:"
175 zone_ports_cmd status
${zone}
177 cli_headline
" Configurations:"
178 zone_configs_cmd status
${zone}
184 function _addport
() {
189 if ! hook_exists port
${hook}; then
190 error
"Hook does not exist '${hook}'"
194 port_hook
${hook} add
${zone}