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 ###############################################################################
22 function firewall_cli
() {
27 # Parse the command line
28 while [ $# -gt 0 ]; do
32 log DEBUG
"Enabled debugging mode"
39 [ -n "${action}" ] && break
42 # Process the given action
45 firewall_start
"${protocol}" "$@"
49 firewall_stop
"${protocol}" "$@"
53 firewall_show
"${protocol}" "$@"
57 firewall_cli_panic
"${protocol}" "$@"
61 firewall_cli_config
"${protocol}" $@
74 error
"Invalid command given: ${action}"
76 exit ${EXIT_CONF_ERROR}
83 function firewall_cli_panic
() {
88 if cli_help_requested $@
; then
89 cli_show_man firewall-panic
94 while [ $# -gt 0 ]; do
97 if ip_is_valid
${1}; then
98 admin_hosts
="${admin_hosts} ${1}"
100 warning
"Invalid IP address: ${1}"
107 firewall_panic
${admin_hosts}
110 function firewall_cli_config
() {
111 local protocol
="${1}"
112 assert isset protocol
115 if cli_help_requested $@
; then
116 cli_usage root-config
120 if [ -n "${1}" ]; then
122 firewall_config_write
"${protocol}"
124 firewall_config_print
"${protocol}"
128 function firewall_cli_zone
() {
129 local protocol
="${1}"
130 assert isset protocol
133 if cli_help_requested $@
; then
134 cli_show_man firewall-zone
138 if zone_name_is_valid
${1}; then
143 # Check if the given zone exists.
144 if ! zone_exists
${zone}; then
145 error
"Zone '${zone}' does not exist."
146 cli_run_help firewall zone
151 # Process the given action.
154 firewall_cli_zone_edit
${zone} $@
157 firewall_cli_zone_status
${zone} $@
160 # Print the raw configuration settings.
162 firewall_zone_print
${zone} $@
167 error
"Unrecognized action: ${action}"
168 cli_run_help firewall zone
179 firewall_zone_reset $@
184 error
"Unrecognized action: ${action}"
185 cli_run_help firewall zone
193 # Show firewall zone conifguration.
194 function firewall_cli_zone_status
() {
199 firewall_zone_read
${zone}
201 cli_headline
1 "Zone ${zone} (policy ${POLICY})"
202 cli_print_fmt1
1 "Masquerade" "$(cli_print_bool ${MASQUERADE})"
210 # Edit firewall zone configuration.
211 function firewall_cli_zone_edit
() {
212 firewall_zone_edit
"$@"