]>
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_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_remove
() {
114 return ${EXIT_NOT_SUPPORTED}
117 function hook_port_show
() {
121 function hook_port_status
() {
122 return ${EXIT_NOT_SUPPORTED}
125 function hook_port_up
() {
129 function hook_port_down
() {
133 function hook_config
() {
143 create|edit|rem|show
)
144 hook_config_
${action} "${zone}" "$@"
148 error
"Unrecognized argument: '${action}'"
154 function hook_config_cmd
() {
161 local hook_config
="${3}"
162 assert isset hook_config
166 local hook_zone
="$(zone_get_hook "${zone}")"
167 if ! hook_zone_exists
"${hook_zone}"; then
168 log ERROR
"Hook '${hook}' does not exist."
172 #if ! hook_config_exists "${hook_zone}" "${hook_config}"; then
173 # log ERROR "Hook '${hook_config}' is not supported for zone '${zone}'."
177 hook_config_exec
"${hook_config}" "${cmd}" "${zone}" "$@"
180 function hook_config_create
() {
183 hook_config_cmd
"create" "$@"
186 function hook_config_edit
() {
187 hook_config_cmd
"edit" "$@"
190 function hook_config_remove
() {
191 hook_config_cmd
"remove" "$@"
194 function hook_config_show
() {
198 function hook_ppp_write_config
() {
201 # Arguments: <zone> <filename>
204 function hook_ppp_ip_pre_up
() {
209 if ! zone_exists
"${zone}"; then
210 log ERROR
"Zone '${zone}' does not exist."
214 ppp_common_ip_pre_up
"${zone}" "$@"
218 function hook_ppp_ipv4_up
() {
223 if ! zone_exists
"${zone}"; then
224 log ERROR
"Zone '${zone}' does not exist."
228 ppp_common_ipv4_up
"${zone}" "$@"
232 function hook_ppp_ipv4_down
() {
237 if ! zone_exists
"${zone}"; then
238 log ERROR
"Zone '${zone}' does not exist."
242 ppp_common_ipv4_down
"${zone}" "$@"
246 function hook_ppp_ipv6_up
() {
251 if ! zone_exists
"${zone}"; then
252 error
"Zone '${zone}' does not exist."
256 ppp_common_ipv6_up
"${zone}" "$@"
260 function hook_ppp_ipv6_down
() {
265 if ! zone_exists
"${zone}"; then
266 error
"Zone '${zone}' does not exist."
270 ppp_common_ipv6_down
"${zone}" "$@"