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 # - All functions in this scope must start with an underline (_) to not
24 # conflict with any functions that were defined somewhere else.
27 .
/lib
/network
/functions
31 while [ $# -gt 0 ]; do
34 error
"Unrecognized option: ${1}"
43 # If action argument was given, we will exit.
44 [ -n "${action}" ] && break
48 # Returns a soft error if a function was not implemented, yet.
50 function _notimplemented
() {
51 warning
"'$@' was not implemented."
52 exit ${EXIT_CONF_ERROR}
56 echo "HOOK=\"${HOOK}\""
63 config_read
${ZONE_DIR}/${zone}/settings
67 config_write
${ZONE_DIR}/${zone}/settings ${HOOK_SETTINGS}
83 if device_is_up
${zone}; then
98 function _discover
() {
99 # This hook does not support a discovery
100 exit ${DISCOVER_NOT_SUPPORTED}
104 function _parse_cmdline
() {
116 create|edit|rem|show
)
117 _port_
${action} ${zone} $@
121 error
"Unrecognized argument: '${action}'"
129 # This function is not a public one
130 function __portcmd
() {
136 local hook_zone
=$
(zone_get_hook
${zone})
138 if ! hook_zone_exists
${hook_zone}; then
139 error
"Hook '${hook}' does not exist."
143 if ! hook_zone_port_exists
${hook_zone} ${hook_port}; then
144 error
"Hook '${hook_port}' is not supported for zone '${zone}'."
148 hook_zone_port_exec
${hook_zone} ${hook_port} ${cmd} ${zone} $@
151 function _port_create
() {
155 function _port_edit
() {
159 function _port_rem
() {
160 _notimplemented _port_rem
163 function _port_show
() {
164 _notimplemented _port_show
175 create|edit|rem|show
)
176 _config_
${action} ${zone} $@
180 error
"Unrecognized argument: '${action}'"
188 # This function is not a public one
189 function __configcmd
() {
192 local hook_config
=${3}
195 local hook_zone
=$
(zone_get_hook
${zone})
197 if ! hook_zone_exists
${hook_zone}; then
198 error
"Hook '${hook}' does not exist."
202 if ! hook_config_exists
${hook_zone} ${hook_config}; then
203 error
"Hook '${hook_config}' is not supported for zone '${zone}'."
207 hook_zone_config_exec
${hook_zone} ${hook_config} ${cmd} ${zone} $@
210 function _config_create
() {
211 __configcmd create $@
214 function _config_edit
() {
218 function _config_rem
() {
219 _notimplemented _config_rem
222 function _config_show
() {
223 _notimplemented _config_show
226 function _ppp-ip-pre-up
() {
230 if ! zone_exists
${zone}; then
231 error
"Zone '${zone}' does not exist."
235 ppp_common_ip_pre_up
${zone} $@
240 function _ppp-ip-up
() {
244 if ! zone_exists
${zone}; then
245 error
"Zone '${zone}' does not exist."
249 ppp_common_ip_up
${zone} $@
254 function _ppp-ip-down
() {
258 if ! zone_exists
${zone}; then
259 error
"Zone '${zone}' does not exist."
263 ppp_common_ip_down
${zone} $@
270 create|discover|down|edit|info|rem|status|up
)
275 if ! hook_zone_has_ports
${HOOK}; then
276 error
"Hook '${HOOK}' does not support ports."
284 if ! hook_zone_has_configs
${HOOK}; then
285 error
"Hook '${HOOK}' does not support configurations."
292 ppp-ip-pre-up|ppp-ip-up|ppp-ip-down
)
298 error
"Hook did not exit properly."