EXIT_ERROR=1
EXIT_CONF_ERROR=2
EXIT_NOT_SUPPORTED=3
+EXIT_NOT_HANDLED=4
EXIT_COMMAND_NOT_FOUND=127
EXIT_ERROR_ASSERT=128
# The function is intended to create child ports and things
# like that.
function hook_hotplug() {
- exit ${EXIT_OK}
+ # If the hook does not handle the hotplug event, it
+ # must return EXIT_NOT_HANDLED.
+ exit ${EXIT_NOT_HANDLED}
}
# This function gets called when a device is plugged in
port_settings_read "${port}" ${HOOK_SETTINGS}
# Get the address of the phy.
- local phy_address=$(phy_get_address ${phy})
+ local phy_address=$(phy_get_address "${phy}")
# Check if the phy is the same we have
# read from the configuration file.
if [ "${PHY}" = "${phy_address}" ]; then
# Bring up the device.
port_up "${port}"
+
+ exit ${EXIT_OK}
fi
- exit ${EXIT_OK}
+ exit ${EXIT_NOT_HANDLED}
}
function hook_find_parent() {
if [ "${PHY}" = "${phy_address}" ]; then
wireless_create ${port} --phy="${phy_address}" --type="ap" \
--address="${ADDRESS}"
+
+ exit ${EXIT_OK}
fi
- exit ${EXIT_OK}
+ exit ${EXIT_NOT_HANDLED}
}
# Create configured child devices.
for port in $(ports_get_all); do
- port_cmd hotplug ${port} ${phy}
+ port_cmd hotplug "${port}" "${phy}"
+ ret=$?
+
+ case "${ret}" in
+ ${EXIT_OK})
+ log DEBUG "phy '${phy}' was handled by port '${port}'"
+ break
+ ;;
+ ${EXIT_NOT_HANDLED})
+ log DEBUG "phy '${phy}' was not handled by port '${port}'"
+ ;;
+ *)
+ log WARNING "Unknown exit code for port '${port}': ${ret}"
+ ;;
+ esac
done
;;