]>
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}
73 function hook_parse_cmdline
() {
77 function hook_port
() {
86 add|create|edit|rem|show
)
87 hook_port_
${action} "${zone}" $@
91 error
"Unrecognized argument: '${action}'"
99 function hook_port_add
() {
100 return ${EXIT_NOT_SUPPORTED}
103 function hook_port_edit
() {
104 return ${EXIT_NOT_SUPPORTED}
107 function hook_port_remove
() {
108 return ${EXIT_NOT_SUPPORTED}
111 function hook_port_show
() {
115 function hook_port_status
() {
116 return ${EXIT_NOT_SUPPORTED}
119 function hook_port_up
() {
123 function hook_port_down
() {
127 function hook_config
() {
137 create|edit|rem|show
)
138 hook_config_
${action} "${zone}" "$@"
142 error
"Unrecognized argument: '${action}'"
148 function hook_config_cmd
() {
155 local hook_config
="${3}"
156 assert isset hook_config
160 local hook_zone
="$(zone_get_hook "${zone}")"
161 if ! hook_zone_exists
"${hook_zone}"; then
162 log ERROR
"Hook '${hook}' does not exist."
166 #if ! hook_config_exists "${hook_zone}" "${hook_config}"; then
167 # log ERROR "Hook '${hook_config}' is not supported for zone '${zone}'."
171 hook_config_exec
"${hook_config}" "${cmd}" "${zone}" "$@"
174 function hook_config_create
() {
177 hook_config_cmd
"create" "$@"
180 function hook_config_edit
() {
181 hook_config_cmd
"edit" "$@"
184 function hook_config_remove
() {
185 hook_config_cmd
"remove" "$@"
188 function hook_config_show
() {
192 function hook_ppp_write_config
() {
195 # Arguments: <zone> <filename>
198 function hook_ppp_ip_pre_up
() {
203 if ! zone_exists
"${zone}"; then
204 log ERROR
"Zone '${zone}' does not exist."
208 ppp_common_ip_pre_up
"${zone}" "$@"
212 function hook_ppp_ipv4_up
() {
217 if ! zone_exists
"${zone}"; then
218 log ERROR
"Zone '${zone}' does not exist."
222 ppp_common_ipv4_up
"${zone}" "$@"
226 function hook_ppp_ipv4_down
() {
231 if ! zone_exists
"${zone}"; then
232 log ERROR
"Zone '${zone}' does not exist."
236 ppp_common_ipv4_down
"${zone}" "$@"
240 function hook_ppp_ipv6_up
() {
245 if ! zone_exists
"${zone}"; then
246 error
"Zone '${zone}' does not exist."
250 ppp_common_ipv6_up
"${zone}" "$@"
254 function hook_ppp_ipv6_down
() {
259 if ! zone_exists
"${zone}"; then
260 error
"Zone '${zone}' does not exist."
264 ppp_common_ipv6_down
"${zone}" "$@"