2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2014 IPFire Network Development Team #
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 hotplug_assert_in_hotplug_event
() {
23 assert
[ -n "${IN_HOTPLUG_EVENT}" ]
27 hotplug_assert_in_hotplug_event
32 hotplug_propagate_all_ports
() {
33 hotplug_assert_in_hotplug_event
35 # Create configured child devices.
37 for port
in $
(ports_get_all
); do
38 port_hotplug_event
"${port}"
41 # Log warning for crashed hooks
43 ${EXIT_OK}|
${EXIT_NOT_HANDLED})
47 log WARNING
"Unknown exit code for port '${port}': ${ret}"
53 hotplug_propagate_all_zones
() {
54 hotplug_assert_in_hotplug_event
57 for zone
in $
(zones_get_all
); do
58 zone_hotplug_event
"${zone}"
61 # Log warning for crashed hooks
63 ${EXIT_OK}|
${EXIT_NOT_HANDLED})
67 log WARNING
"Unknown exit code for zone '${zone}': ${ret}"
73 hotplug_event_port_is_interface
() {
74 hotplug_assert_in_hotplug_event
79 [ "${port}" = "${INTERFACE}" ]
82 hotplug_event_interface_is_slave_of_port
() {
83 hotplug_assert_in_hotplug_event
88 # Return false if INTERFACE is not set
89 isset INTERFACE ||
return ${EXIT_FALSE}
91 local slaves
="$(port_get_slaves "${port}")"
92 list_match
"${INTERFACE}" ${slaves}
95 hotplug_event_interface_is_port_of_zone
() {
96 hotplug_assert_in_hotplug_event
101 # Return false if INTERFACE is not set
102 isset INTERFACE ||
return ${EXIT_FALSE}
104 local ports
="$(zone_get_ports "${zone}")"
105 list_match
"${INTERFACE}" ${ports}
108 hotplug_event_port_uses_phy
() {
109 hotplug_assert_in_hotplug_event
114 # Return false if PHY is not set
115 isset PHY ||
return ${EXIT_FALSE}
117 # Returns true if port uses PHY
118 port_uses_phy
"${port}" "${PHY}"