]>
git.ipfire.org Git - people/stevee/network.git/blob - hooks/zones/bridge.ports/ethernet
1b7d92b1e8f2fda33249b8905c6f732219da297b
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 .
/usr
/lib
/network
/header-port
24 HOOK_SETTINGS
="COST PRIORITY"
26 function hook_check
() {
28 for i
in COST PRIORITY
; do
43 if ! port_exists
${port}; then
44 error
"Port '${port}' does not exist."
48 config_read $
(zone_dir
${zone})/ports
/${port}
50 while [ $# -gt 0 ]; do
53 PRIORITY
=${1#--priority=}
62 config_write $
(zone_dir
${zone})/ports/${port} ${HOOK_SETTINGS}
67 function hook_edit
() {
71 function hook_remove
() {
78 assert zone_exists
${zone}
80 if ! listmatch
${port} $
(zone_get_ports
${zone}); then
81 error
"Port '${port}' does not belong to '${zone}'."
82 error
"Won't remove anything."
86 if port_exists
${port}; then
87 ( _down
${zone} ${port} )
90 rm -f $
(zone_dir
${zone})/ports
/${port}
102 assert zone_exists
${zone}
103 assert port_exists
${port}
107 # Set same MTU to device that the bridge has got
108 device_set_mtu
${port} $
(device_get_mtu
${zone})
110 bridge_attach_device
${zone} ${port}
112 # XXX must set cost and prio here
117 function hook_down
() {
124 assert zone_exists
${zone}
125 assert port_exists
${port}
127 bridge_detach_device
${zone} ${port}
134 function hook_status
() {
138 # Do nothing for devices which are not up and running.
139 device_exists
${port} ||
exit ${EXIT_OK}
143 # Check if the device is down.
144 if ! device_is_up
${port}; then
145 status
=${MSG_DEVICE_STATUS_DOWN}
147 # Check if the device has no carrier.
148 elif ! device_has_carrier
${port}; then
149 status
=${MSG_DEVICE_STATUS_NOCARRIER}
151 # Check for STP information.
152 elif stp_is_enabled
${zone}; then
153 local state
=$
(stp_port_get_state
${zone} ${port})
154 state
="MSG_STP_${state}"
157 status
="${status} - DSR: $(stp_port_get_designated_root ${zone} ${port})"
158 status
="${status} - Cost: $(stp_port_get_cost ${zone} ${port})"
160 status
=${MSG_DEVICE_STATUS_UP}
162 cli_statusline
3 "${port}" "${status}"