]>
git.ipfire.org Git - people/arne_f/network.git/blob - hooks/ports/virtual
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-port
24 HOOK_SETTINGS
="HOOK ADDRESS PARENT TAG"
26 PORT_PARENTS_VAR
="PARENT"
28 ADDRESS
=$
(mac_generate
)
35 if [ ${TAG} -gt 4096 ]; then
36 error
"TAG is greater than 4096."
41 for reserved
in 0 4095; do
42 if [ "${TAG}" = "${reserved}" ]; then
43 error
"TAG=${reserved} is reserved."
50 while [ $# -gt 0 ]; do
62 warning
"Unknown argument '${1}'"
68 local port
="${PARENT}v${TAG}"
70 config_write $
(port_file
${port}) ${HOOK_SETTINGS}
81 config_read $
(port_file
${port})
83 while [ $# -gt 0 ]; do
89 warning
"Unknown argument '${1}'"
95 config_write $
(port_file
${port}) ${HOOK_SETTINGS}
105 config_read $
(port_file
${port})
107 if ! device_exists
${port}; then
108 virtual_create
${PARENT} ${TAG} ${ADDRESS}
119 config_read $
(port_file
${port})
121 if ! device_exists
${port}; then
125 virtual_remove
${port}
134 config_read $
(zone_dir
${zone})/${port}
136 local device
=$
(devicify
${ADDRESS})
138 printf " %-10s - " "${device}"
139 if ! device_is_up
${device}; then
140 echo -ne "${COLOUR_DOWN} DOWN ${COLOUR_NORMAL}"
142 local state
=$
(stp_port_state
${zone} ${device})
143 local colour
="COLOUR_STP_${state}"
144 printf "${!colour}%10s${COLOUR_NORMAL}" ${state}
147 echo -n " - DSR
: $
(stp_port_designated_root
${zone} ${device})"
148 echo -n " - Cost
: $
(stp_port_pathcost
${zone} ${device})"