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 zone_settings_read
"${zone}"
41 zone_settings_write
"${zone}"
58 if device_is_up
${zone}; then
74 # This hook does not support a discovery
75 exit ${DISCOVER_NOT_SUPPORTED}
79 hook_parse_cmdline
() {
92 add|create|edit|rem|show
)
93 hook_port_
${action} "${zone}" $@
97 error
"Unrecognized argument: '${action}'"
106 return ${EXIT_NOT_SUPPORTED}
110 return ${EXIT_NOT_SUPPORTED}
114 return ${EXIT_NOT_SUPPORTED}
118 return ${EXIT_NOT_SUPPORTED}
121 hook_default_port_create
() {
127 port_create
"${port}"
131 hook_default_port_create $@
134 hook_default_port_remove
() {
140 port_remove
"${port}"
144 hook_default_port_remove $@
165 create|edit|rem|show
)
166 hook_config_
${action} "${zone}" "$@"
170 error
"Unrecognized argument: '${action}'"
183 local hook_config
="${3}"
184 assert isset hook_config
188 local hook_zone
="$(zone_get_hook "${zone}")"
189 if ! hook_zone_exists
"${hook_zone}"; then
190 log ERROR
"Hook '${hook}' does not exist."
194 #if ! hook_config_exists "${hook_zone}" "${hook_config}"; then
195 # log ERROR "Hook '${hook_config}' is not supported for zone '${zone}'."
199 hook_config_exec
"${hook_config}" "${cmd}" "${zone}" "$@"
202 hook_config_create
() {
205 hook_config_cmd
"create" "$@"
209 hook_config_cmd
"edit" "$@"
212 hook_config_remove
() {
213 hook_config_cmd
"remove" "$@"
220 hook_ppp_write_config
() {
223 # Arguments: <zone> <filename>
226 hook_ppp_ip_pre_up
() {
231 if ! zone_exists
"${zone}"; then
232 log ERROR
"Zone '${zone}' does not exist."
236 ppp_common_ip_pre_up
"${zone}" "$@"
245 if ! zone_exists
"${zone}"; then
246 log ERROR
"Zone '${zone}' does not exist."
250 ppp_common_ipv4_up
"${zone}" "$@"
254 hook_ppp_ipv4_down
() {
259 if ! zone_exists
"${zone}"; then
260 log ERROR
"Zone '${zone}' does not exist."
264 ppp_common_ipv4_down
"${zone}" "$@"
273 if ! zone_exists
"${zone}"; then
274 error
"Zone '${zone}' does not exist."
278 ppp_common_ipv6_up
"${zone}" "$@"
282 hook_ppp_ipv6_down
() {
287 if ! zone_exists
"${zone}"; then
288 error
"Zone '${zone}' does not exist."
292 ppp_common_ipv6_down
"${zone}" "$@"