]> git.ipfire.org Git - people/stevee/network.git/blobdiff - functions.config
Split firewall in a IPv6 and IPv4 component.
[people/stevee/network.git] / functions.config
index 8e1ab95d0139a3a67a78cc29ff895fc64487e589..11e924669331c792b701c6a9ed643ea61da155c2 100644 (file)
 #                                                                             #
 ###############################################################################
 
-# Load all global configuration files.
-function config_read_globals() {
-       network_config_read
-       firewall_config_read
-}
-
 function config_read() {
        local file=${1}
        assert isset file
@@ -224,15 +218,60 @@ function network_config_print() {
        config_print ${NETWORK_CONFIG_FILE_PARAMS}
 }
 
+function firewall_config_file() {
+       local protocol="${1}"
+       assert isset protocol
+
+       local file
+       case "${protocol}" in
+               ipv6)
+                       file="${FIREWALL6_CONFIG_FILE}"
+                       ;;
+               ipv4)
+                       file="${FIREWALL4_CONFIG_FILE}"
+                       ;;
+       esac
+       assert isset file
+
+       print "${file}"
+       return ${EXIT_OK}
+}
+
+function firewall_config_env() {
+       local protocol="${1}"
+       assert isset protocol
+
+       case "${protocol}" in
+               ipv6)
+                       file="${FIREWALL6_CONFIG_FILE}"
+                       params="${FIREWALL6_CONFIG_PARAMS}"
+                       ;;
+               ipv4)
+                       file="${FIREWALL4_CONFIG_FILE}"
+                       params="${FIREWALL4_CONFIG_PARAMS}"
+                       ;;
+       esac
+       assert isset file
+       assert isset params
+}
+
 function firewall_config_read() {
-       config_read ${FIREWALL_CONFIG_FILE} ${FIREWALL_CONFIG_PARAMS}
+       local file params
+       firewall_config_env "$@"
+
+       config_read "${file}" "${params}"
 }
 
 function firewall_config_write() {
-       config_write ${FIREWALL_CONFIG_FILE} \
-               ${FIREWALL_CONFIG_PARAMS}
+       local file params
+       firewall_config_env "$@"
+
+       config_write "${file}" "${params}"
 }
 
 function firewall_config_print() {
-       config_print ${FIREWALL_CONFIG_PARAMS}
+       local file params
+       firewall_config_env "$@"
+
+       config_print "${params}"
 }