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 ###############################################################################
23 echo "HOOK=\"${HOOK}\""
27 # If the hook does not handle the hotplug event, it
28 # must return EXIT_NOT_HANDLED.
29 exit ${EXIT_NOT_HANDLED}
37 if ! hook_parse_cmdline $@
; then
41 if ! zone_settings_write
"${zone}"; then
42 log ERROR
"Could not write settings for zone ${zone}"
54 if ! zone_settings_read
"${zone}"; then
55 log ERROR
"Could not read settings for zone ${zone}"
59 if ! hook_parse_cmdline $@
; then
63 if ! zone_settings_write
"${zone}"; then
64 log ERROR
"Could not write settings for zone ${zone}"
80 if device_is_up
${zone}; then
96 # This hook does not support a discovery
97 exit ${DISCOVER_NOT_SUPPORTED}
101 hook_parse_cmdline
() {
114 add|create|edit|rem|show
)
115 hook_port_
${action} "${zone}" $@
119 error
"Unrecognized argument: '${action}'"
128 return ${EXIT_NOT_SUPPORTED}
132 return ${EXIT_NOT_SUPPORTED}
136 return ${EXIT_NOT_SUPPORTED}
140 return ${EXIT_NOT_SUPPORTED}
143 hook_default_port_create
() {
149 port_create
"${port}"
153 hook_default_port_create $@
156 hook_default_port_remove
() {
162 port_remove
"${port}"
166 hook_default_port_remove $@
187 new|destroy|edit|show
)
188 hook_config_
${action} "${zone}" "$@"
192 error
"Unrecognized argument: '${action}'"
205 local hook_config
="${3}"
206 assert isset hook_config
210 local hook_zone
="$(zone_get_hook "${zone}")"
211 if ! hook_zone_exists
"${hook_zone}"; then
212 log ERROR
"Hook '${hook}' does not exist."
216 #if ! hook_config_exists "${hook_zone}" "${hook_config}"; then
217 # log ERROR "Hook '${hook_config}' is not supported for zone '${zone}'."
221 hook_config_exec
"${hook_config}" "${cmd}" "${zone}" "$@"
227 hook_config_cmd
"new" "$@"
230 hook_config_destroy
() {
233 # The id must be the id and not the hid.
238 # Check if we get a valid id
239 if ! zone_config_id_is_valid
${zone} ${id}; then
240 log ERROR
"ID: ${id} is not a valid id for zone ${zone}"
243 local hook
=$
(zone_config_get_hook_from_id
${zone} ${id})
246 hook_config_cmd
"destroy" "${zone}" "${hook}" "${hook}.${id}" "$@"
252 # The id must be the id and not the hid.
257 # Check if we get a valid id
258 if ! zone_config_id_is_valid
${zone} ${id}; then
259 log ERROR
"ID: ${id} is not a valid id for zone ${zone}"
262 local hook
=$
(zone_config_get_hook_from_id
${zone} ${id})
265 hook_config_cmd
"edit" "${zone}" "${hook}" "${hook}.${id}" "$@"
272 hook_ppp_write_config
() {
275 # Arguments: <zone> <filename>
278 hook_ppp_ip_pre_up
() {
283 if ! zone_exists
"${zone}"; then
284 log ERROR
"Zone '${zone}' does not exist."
288 ppp_common_ip_pre_up
"${zone}" "$@"
297 if ! zone_exists
"${zone}"; then
298 log ERROR
"Zone '${zone}' does not exist."
302 ppp_common_ipv4_up
"${zone}" "$@"
306 hook_ppp_ipv4_down
() {
311 if ! zone_exists
"${zone}"; then
312 log ERROR
"Zone '${zone}' does not exist."
316 ppp_common_ipv4_down
"${zone}" "$@"
325 if ! zone_exists
"${zone}"; then
326 error
"Zone '${zone}' does not exist."
330 ppp_common_ipv6_up
"${zone}" "$@"
334 hook_ppp_ipv6_down
() {
339 if ! zone_exists
"${zone}"; then
340 error
"Zone '${zone}' does not exist."
344 ppp_common_ipv6_down
"${zone}" "$@"