2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 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 .
/usr
/lib
/network
/functions
24 # Read network settings
28 LOG_FACILITY
="network-hotplug"
30 log DEBUG
"Called with ACTION='${ACTION}', INTERFACE='${INTERFACE}'."
32 # Check if the udev environment variables are properly set.
34 assert isset INTERFACE
36 # Check, if the device is a physical network interface and
37 # if we can handle it.
38 if device_exists
${INTERFACE}; then
39 if ! device_is_ethernet
${INTERFACE}; then
40 log DEBUG
"Called for interface '${INTERFACE}' which is a virtual interface. Exiting."
47 # Check, if there is a configuration for that device.
48 if port_exists
${INTERFACE}; then
51 # Create new configuration for _real_ network devices.
53 type=$
(device_get_type
${INTERFACE})
55 # If the given device was not configured,
56 # we create an initial configuration.
58 port_create ethernet
${INTERFACE}
61 # Handle batman-adv and wireless devices.
62 batman-adv|batman-adv-port|wireless
)
63 # Load regulatory domain for wireless devices
64 wireless_init_reg_domain
66 # Save the phy of this device for later.
67 phy
=$
(phy_get
${INTERFACE})
70 # Remove the unconfigured wireless device.
71 wireless_remove
${INTERFACE}
73 # Create configured child devices.
74 for port
in $
(ports_get_all
); do
75 port_cmd hotplug
"${port}" "${phy}"
80 log DEBUG
"phy '${phy}' was handled by port '${port}'"
84 log DEBUG
"phy '${phy}' was not handled by port '${port}'"
87 log WARNING
"Unknown exit code for port '${port}': ${ret}"
93 # Do nothing for all the rest.
95 log DEBUG
"Don't create a port configuration for device '${INTERFACE}' of type '${type}'."
101 zone
=$
(port_zone
${port})
103 # Check, if the device is configured in a zone.
104 # If not, there is nothing to do.
105 isset zone ||
exit ${EXIT_OK}
107 # If the zone is already up or enabled for auto-start,
108 # we add the device to the zone.
109 if zone_is_up
"${zone}" || zone_is_enabled
"${zone}"; then
115 # After the interface has been removed/unplugged,
116 # there are often daemons (like hostapd) which need
118 port_exists
${INTERFACE} && port_down
${INTERFACE}