]>
git.ipfire.org Git - people/stevee/network.git/blob - src/header-zone
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_create
() {
31 settings_read $
(zone_dir
${zone})/settings
35 settings_write $
(zone_dir
${zone})/settings
${HOOK_SETTINGS}
40 function hook_edit
() {
44 function hook_remove
() {
48 function hook_status
() {
52 if device_is_up
${zone}; then
63 function hook_down
() {
67 function hook_discover
() {
68 # This hook does not support a discovery
69 exit ${DISCOVER_NOT_SUPPORTED}
72 # The default help function.
73 function hook_help
() {
74 # If no man page has been configured, we print an error message.
75 if [ -z "${HOOK_MANPAGE}" ]; then
76 error
"There is no help available for hook '${HOOK}'. Exiting."
80 cli_show_man
${HOOK_MANPAGE}
84 function hook_parse_cmdline
() {
88 function hook_port
() {
97 add|create|edit|rem|show
)
98 hook_port_
${action} "${zone}" $@
102 error
"Unrecognized argument: '${action}'"
110 function hook_port_add
() {
111 return ${EXIT_NOT_SUPPORTED}
114 function hook_port_edit
() {
115 return ${EXIT_NOT_SUPPORTED}
118 function hook_port_remove
() {
119 return ${EXIT_NOT_SUPPORTED}
122 function hook_port_show
() {
126 function hook_port_status
() {
127 return ${EXIT_NOT_SUPPORTED}
130 function hook_port_up
() {
134 function hook_port_down
() {
138 function hook_config
() {
148 create|edit|rem|show
)
149 hook_config_
${action} "${zone}" "$@"
153 error
"Unrecognized argument: '${action}'"
159 function hook_config_cmd
() {
166 local hook_config
="${3}"
167 assert isset hook_config
171 local hook_zone
="$(zone_get_hook "${zone}")"
172 if ! hook_zone_exists
"${hook_zone}"; then
173 log ERROR
"Hook '${hook}' does not exist."
177 #if ! hook_config_exists "${hook_zone}" "${hook_config}"; then
178 # log ERROR "Hook '${hook_config}' is not supported for zone '${zone}'."
182 hook_config_exec
"${hook_config}" "${cmd}" "${zone}" "$@"
185 function hook_config_create
() {
188 hook_config_cmd
"create" "$@"
191 function hook_config_edit
() {
192 hook_config_cmd
"edit" "$@"
195 function hook_config_remove
() {
196 hook_config_cmd
"remove" "$@"
199 function hook_config_show
() {
203 function hook_ppp_write_config
() {
206 # Arguments: <zone> <filename>
209 function hook_ppp_ip_pre_up
() {
214 if ! zone_exists
"${zone}"; then
215 log ERROR
"Zone '${zone}' does not exist."
219 ppp_common_ip_pre_up
"${zone}" "$@"
223 function hook_ppp_ipv4_up
() {
228 if ! zone_exists
"${zone}"; then
229 log ERROR
"Zone '${zone}' does not exist."
233 ppp_common_ipv4_up
"${zone}" "$@"
237 function hook_ppp_ipv4_down
() {
242 if ! zone_exists
"${zone}"; then
243 log ERROR
"Zone '${zone}' does not exist."
247 ppp_common_ipv4_down
"${zone}" "$@"
251 function hook_ppp_ipv6_up
() {
256 if ! zone_exists
"${zone}"; then
257 error
"Zone '${zone}' does not exist."
261 ppp_common_ipv6_up
"${zone}" "$@"
265 function hook_ppp_ipv6_down
() {
270 if ! zone_exists
"${zone}"; then
271 error
"Zone '${zone}' does not exist."
275 ppp_common_ipv6_down
"${zone}" "$@"