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 DEVICE DEVICE_MAC DEVICE_VID"
26 DEVICE_MAC
=$
(mac_generate
)
30 assert ismac DEVICE_MAC
31 assert isinteger DEVICE_VID
33 if [ ${DEVICE_VID} -gt 4096 ]; then
34 error
"DEVICE_VID is greater than 4096."
39 for reserved
in 0 4095; do
40 if [ "${DEVICE_VID}" = "${reserved}" ]; then
41 error
"DEVICE_VID=${reserved} is reserved."
48 while [ $# -gt 0 ]; do
54 DEVICE_MAC
=${1#--mac=}
60 warning
"Unknown argument '${1}'"
66 local port
="${DEVICE}v${DEVICE_VID}"
68 config_write $
(port_file
${port}) ${HOOK_SETTINGS}
79 config_read $
(port_file
${port})
81 while [ $# -gt 0 ]; do
84 DEVICE_MAC
=${1#--mac=}
87 warning
"Unknown argument '${1}'"
93 config_write $
(port_file
${port}) ${HOOK_SETTINGS}
103 config_read $
(port_file
${port})
105 if ! device_exists
${port}; then
106 virtual_create
${DEVICE} ${DEVICE_VID} ${DEVICE_MAC}
117 config_read $
(port_file
${port})
119 if ! device_exists
${port}; then
123 virtual_remove
${port}
132 config_read $
(zone_dir
${zone})/${port}
134 local device
=$
(devicify
${DEVICE_MAC})
136 printf " %-10s - " "${device}"
137 if ! device_is_up
${device}; then
138 echo -ne "${COLOUR_DOWN} DOWN ${COLOUR_NORMAL}"
140 local state
=$
(stp_port_state
${zone} ${device})
141 local colour
="COLOUR_STP_${state}"
142 printf "${!colour}%10s${COLOUR_NORMAL}" ${state}
145 echo -n " - DSR
: $
(stp_port_designated_root
${zone} ${device})"
146 echo -n " - Cost
: $
(stp_port_pathcost
${zone} ${device})"