]>
git.ipfire.org Git - people/stevee/network.git/blob - functions.firewall-zones
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
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 FIREWALL_ZONE_SETTINGS
="MASQUERADE POLICY"
25 function firewall_zone_create
() {
29 # Do nothing if the zone configuration already exists.
30 firewall_zone_exists
${zone} && return ${EXIT_OK}
32 # Write defaults to the file.
34 firewall_zone_read
${zone}
35 firewall_zone_write
${zone}
41 function firewall_zone_config
() {
45 print
"$(zone_dir ${zone})/fwsettings"
49 function firewall_zone_exists
() {
50 local file=$
(firewall_zone_config $@
)
52 [ -r "${file}" ] && return ${EXIT_TRUE} || return ${EXIT_FALSE}
55 function firewall_zone_defaults() {
62 # Don't masquerade by default (IPv4 only).
66 function firewall_zone_read() {
70 local file=$(firewall_zone_config ${zone})
73 # Load default settings.
74 firewall_zone_defaults ${zone}
76 config_read ${file} ${FIREWALL_ZONE_SETTINGS}
80 function firewall_zone_write() {
84 local file=$(firewall_zone_config ${zone})
87 config_write ${file} ${FIREWALL_ZONE_SETTINGS}
91 function firewall_zone_print() {
96 firewall_zone_read ${zone}
97 config_print ${FIREWALL_ZONE_SETTINGS}
103 function firewall_zone_edit() {
107 assert firewall_zone_exists ${zone}
110 # Read current settings.
111 firewall_zone_read ${zone}
113 while [ $# -gt 0 ]; do
116 MASQUERADE=$(cli_get_val ${1})
119 POLICY=$(cli_get_val ${1})
122 warning "Unknown option
: ${1}"
128 # Write updated settings.
129 firewall_zone_write ${zone}
133 function firewall_zone_reset() {
137 local file=$(firewall_zone_config ${zone})
140 # Remove the configuration file.
144 firewall_zone_create ${zone}