From: Michael Tremer Date: Sun, 23 Sep 2018 15:30:29 +0000 (+0200) Subject: pppoe-server: Refactor pppoe_server_poolfile X-Git-Tag: 010~21 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a1eb3943ca0c7536f392a8b355d527242ac12693;p=network.git pppoe-server: Refactor pppoe_server_poolfile Due to output of other functions changed, this function needed to be slightly rewritten. Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.pppoe-server b/src/functions/functions.pppoe-server index 5d65d24e..a643d9f8 100644 --- a/src/functions/functions.pppoe-server +++ b/src/functions/functions.pppoe-server @@ -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} }