From a1eb3943ca0c7536f392a8b355d527242ac12693 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 23 Sep 2018 17:30:29 +0200 Subject: [PATCH] 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 --- src/functions/functions.pppoe-server | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) 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} } -- 2.47.3