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_MODE"
25 HOOK_SETTINGS
="${HOOK_SETTINGS} STP_PRIORITY MAC MTU"
35 STP_PRIORITY
=512 # XXX check out better value
40 assert isoneof STP_MODE stp rstp
41 assert isinteger STP_HELLO
42 assert isinteger STP_FORWARD_DELAY
43 assert isinteger STP_PRIORITY
47 function _parse_cmdline
() {
48 while [ $# -gt 0 ]; do
54 STP_MODE
=${1#--stp-mode=}
57 STP_HELLO
=${1#--stp-hello=}
59 --stp-forward-delay=*)
60 STP_FORWARD_DELAY
=${1#--stp-forward-delay=}
63 STP_PRIORITY
=${1#--stp-priority=}
72 warning
"Ignoring unknown option '${1}'"
83 config_read
${ZONE_DIR}/${zone}/settings
85 if ! device_exists
${zone}; then
89 [ -n "${MAC}" ] && device_set_address ${zone} ${MAC}
90 [ -n "${MTU}" ] && device_set_mtu ${zone} ${MTU}
96 if [ -n "${STP_FORWARD_DELAY}" ]; then
97 brctl setfd
${zone} ${STP_FORWARD_DELAY}
100 if [ -n "${STP_HELLO}" ]; then
101 brctl sethello
${zone} ${STP_HELLO}
104 if [ -n "${STP_MAXAGE}" ]; then
105 brctl setmaxage
${zone} ${STP_MAXAGE}
108 if [ -n "${STP_PRIORITY}" ]; then
109 brctl setbridgeprio
${zone} ${STP_PRIORITY}
115 device_set_up
${zone}
117 # XXX Currently, there is a bug (in the linux kernel?) that we need to
118 # set our bridges to promisc mode.
119 device_set_promisc
${zone} on
122 zone_ports_up
${zone}
123 zone_configs_up
${zone}
125 event_interface_up
${zone}
134 if ! device_is_up
${zone}; then
135 warning
"Zone '${zone}' is not up"
139 event_interface_down
${zone}
141 zone_configs_down
${zone}
142 zone_ports_down
${zone}
144 # XXX See remark in _up().
145 device_set_promisc
${zone} off
147 device_set_down
${zone}
156 cli_status_headline
${zone}
158 # Exit if zone is down
159 if ! zone_is_up
${zone}; then
164 # XXX Add bridge stp priority here
165 # brctl does not give any information about that
167 cli_headline
" Spanning Tree Protocol information:"
168 printf "${DEVICE_PRINT_LINE1}" "ID:" $
(stp_bridge_get_id
${zone})
169 printf "${DEVICE_PRINT_LINE1}" "Priority:" $
(stp_bridge_get_priority
${zone})
171 if stp_bridge_is_root
${zone}; then
172 echo -e " ${COLOUR_BOLD}This bridge is root.${COLOUR_NORMAL}"
174 printf "${DEVICE_PRINT_LINE1}" "Designated root:" $
(stp_bridge_get_designated_root
${zone})
175 printf "${DEVICE_PRINT_LINE1}" "Root path cost:" $
(stp_bridge_get_root_path_cost
${zone})
179 # Topology information
180 printf "${DEVICE_PRINT_LINE1}" "Topology changing:" $
(stp_bridge_get_topology_change_detected
${zone})
181 printf "${DEVICE_PRINT_LINE1}" "Topology change time:" $
(beautify_time $
(stp_bridge_get_topology_change_timer
${zone}))
182 printf "${DEVICE_PRINT_LINE1}" "Topology change count:" $
(stp_bridge_get_topology_change_count
${zone})
184 cli_headline
" Ports:"
185 zone_ports_status
${zone}
187 cli_headline
" Configurations:"
188 zone_configs_cmd status
${zone}