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
32 assert isinteger DEVICE_VID
34 if [ ${DEVICE_VID} -gt 4096 ]; then
35 error
"DEVICE_VID is greater than 4096."
40 for reserved
in 0 4095; do
41 if [ "${DEVICE_VID}" = "${reserved}" ]; then
42 error
"DEVICE_VID=${reserved} is reserved."
53 while [ $# -gt 0 ]; do
56 DEVICE_MAC
=${1#--mac=}
62 warning
"Unknown argument '${1}'"
68 DEVICE
=$
(macify
${device})
72 config_write $
(zone_dir
${zone})/port.${HOOK}.$(device_hash ${device}).${DEVICE_VID} ${HOOK_SETTINGS}
80 error
"TODO - edit mac addres"
89 config_read $
(zone_dir
${zone})/${port}
91 if ! device_exists $
(devicify
${DEVICE_MAC}); then
92 device_virtual_create
${DEVICE} ${DEVICE_VID} ${DEVICE_MAC}
95 local device
=$
(devicify
${DEVICE_MAC})
97 # Set same MTU to device that the bridge has got
98 device_set_mtu
${device} $
(device_get_mtu
${zone})
100 bridge_attach_device
${zone} ${device}
109 config_read $
(zone_dir
${zone})/${port}
111 local device
=$
(devicify
${DEVICE_MAC})
113 if ! device_exists
${device}; then
114 error
"Device '${DEVICE_MAC}' does not exist."
118 bridge_detach_device
${zone} ${device}
120 device_virtual_remove
${device}
129 config_read $
(zone_dir
${zone})/${port}
131 local device
=$
(devicify
${DEVICE_MAC})
133 printf " %-10s - " "${device}"
134 if ! device_is_up
${device}; then
135 echo -ne "${COLOUR_DOWN} DOWN ${COLOUR_NORMAL}"
137 local state
=$
(stp_port_state
${zone} ${device})
138 local colour
="COLOUR_STP_${state}"
139 printf "${!colour}%10s${COLOUR_NORMAL}" ${state}
142 echo -n " - DSR
: $
(stp_port_designated_root
${zone} ${device})"
143 echo -n " - Cost
: $
(stp_port_pathcost
${zone} ${device})"