]> git.ipfire.org Git - people/ms/network.git/commitdiff
pppoe-server: Refactor pppoe_server_poolfile
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Sep 2018 15:30:29 +0000 (17:30 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Sep 2018 15:30:29 +0000 (17:30 +0200)
Due to output of other functions changed, this function
needed to be slightly rewritten.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.pppoe-server

index 5d65d24ecb89aae93471290f410ab7c0a5eb421b..a643d9f8e001df8a579d833a594169bf9208bc60 100644 (file)
@@ -185,22 +185,25 @@ pppoe_server_options() {
 }
 
 pppoe_server_poolfile() {
-       local file=${1}
+       local file="${1}"
        assert isset file
 
-       local subnet=${2}
+       local subnet="${2}"
        assert isset subnet
 
-       config_header "PPPoE server IP address pool file" > ${file}
+       (
+               config_header "PPPoE server IP address pool file"
+
+               i=0
+               for addr in $(ipv4_range_explicit "${subnet}"); do
+                       (( i++ ))
 
-       # The network address will be the gateway address.
-       local netaddr=$(ipv4_get_network ${subnet})
+                       # Skip the first address which is being used for the gateway
+                       [ ${i} -eq 1 ] && continue
 
-       local addr
-       for addr in $(ipv4_range_explicit ${subnet}); do
-               [ "${addr}" = "${netaddr}" ] && continue
-               print "${addr}"
-       done >> ${file}
+                       print "${addr}"
+               done
+       ) > ${file}
 
        return ${EXIT_OK}
 }