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 PORT_PARENTS_VAR
="DEVICE"
28 DEVICE_MAC
=$
(mac_generate
)
32 assert ismac DEVICE_MAC
33 assert isinteger DEVICE_VID
35 if [ ${DEVICE_VID} -gt 4096 ]; then
36 error
"DEVICE_VID is greater than 4096."
41 for reserved
in 0 4095; do
42 if [ "${DEVICE_VID}" = "${reserved}" ]; then
43 error
"DEVICE_VID=${reserved} is reserved."
50 while [ $# -gt 0 ]; do
56 DEVICE_MAC
=${1#--mac=}
62 warning
"Unknown argument '${1}'"
68 local port
="${DEVICE}v${DEVICE_VID}"
70 config_write $
(port_file
${port}) ${HOOK_SETTINGS}
81 config_read $
(port_file
${port})
83 while [ $# -gt 0 ]; do
86 DEVICE_MAC
=${1#--mac=}
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
${DEVICE} ${DEVICE_VID} ${DEVICE_MAC}
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
${DEVICE_MAC})
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})"