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 ###############################################################################
22 function hook_info
() {
23 echo "HOOK=\"${HOOK}\""
26 function hook_hotplug
() {
27 # If the hook does not handle the hotplug event, it
28 # must return EXIT_NOT_HANDLED.
29 exit ${EXIT_NOT_HANDLED}
32 function hook_create
() {
37 settings_read $
(zone_dir
${zone})/settings
41 settings_write $
(zone_dir
${zone})/settings
${HOOK_SETTINGS}
46 function hook_edit
() {
50 function hook_remove
() {
54 function hook_status
() {
58 if device_is_up
${zone}; then
69 function hook_down
() {
73 function hook_discover
() {
74 # This hook does not support a discovery
75 exit ${DISCOVER_NOT_SUPPORTED}
79 function hook_parse_cmdline
() {
83 function hook_port
() {
92 add|create|edit|rem|show
)
93 hook_port_
${action} "${zone}" $@
97 error
"Unrecognized argument: '${action}'"
105 function hook_port_add
() {
106 return ${EXIT_NOT_SUPPORTED}
109 function hook_port_edit
() {
110 return ${EXIT_NOT_SUPPORTED}
113 function hook_port_destroy
() {
114 return ${EXIT_NOT_SUPPORTED}
117 function hook_port_show
() {
121 function hook_port_status
() {
122 return ${EXIT_NOT_SUPPORTED}
125 function hook_default_port_create
() {
131 port_create
"${port}"
134 function hook_port_create
() {
135 hook_default_port_create $@
138 function hook_default_port_remove
() {
144 port_remove
"${port}"
147 function hook_port_remove
() {
148 hook_default_port_remove $@
151 function hook_port_up
() {
155 function hook_port_down
() {
159 function hook_config
() {
169 create|edit|rem|show
)
170 hook_config_
${action} "${zone}" "$@"
174 error
"Unrecognized argument: '${action}'"
180 function hook_config_cmd
() {
187 local hook_config
="${3}"
188 assert isset hook_config
192 local hook_zone
="$(zone_get_hook "${zone}")"
193 if ! hook_zone_exists
"${hook_zone}"; then
194 log ERROR
"Hook '${hook}' does not exist."
198 #if ! hook_config_exists "${hook_zone}" "${hook_config}"; then
199 # log ERROR "Hook '${hook_config}' is not supported for zone '${zone}'."
203 hook_config_exec
"${hook_config}" "${cmd}" "${zone}" "$@"
206 function hook_config_create
() {
209 hook_config_cmd
"create" "$@"
212 function hook_config_edit
() {
213 hook_config_cmd
"edit" "$@"
216 function hook_config_remove
() {
217 hook_config_cmd
"remove" "$@"
220 function hook_config_show
() {
224 function hook_ppp_write_config
() {
227 # Arguments: <zone> <filename>
230 function hook_ppp_ip_pre_up
() {
235 if ! zone_exists
"${zone}"; then
236 log ERROR
"Zone '${zone}' does not exist."
240 ppp_common_ip_pre_up
"${zone}" "$@"
244 function hook_ppp_ipv4_up
() {
249 if ! zone_exists
"${zone}"; then
250 log ERROR
"Zone '${zone}' does not exist."
254 ppp_common_ipv4_up
"${zone}" "$@"
258 function hook_ppp_ipv4_down
() {
263 if ! zone_exists
"${zone}"; then
264 log ERROR
"Zone '${zone}' does not exist."
268 ppp_common_ipv4_down
"${zone}" "$@"
272 function hook_ppp_ipv6_up
() {
277 if ! zone_exists
"${zone}"; then
278 error
"Zone '${zone}' does not exist."
282 ppp_common_ipv6_up
"${zone}" "$@"
286 function hook_ppp_ipv6_down
() {
291 if ! zone_exists
"${zone}"; then
292 error
"Zone '${zone}' does not exist."
296 ppp_common_ipv6_down
"${zone}" "$@"