public inbox for network@lists.ipfire.org
 help / color / mirror / Atom feed
* Split the cmd line parsing in the config hooks in seperated functions
@ 2017-07-19  8:52 Jonatan Schlag
  2017-07-19  8:52 ` [PATCH 1/4] pppoe-server: create hook_parse_cmdline function Jonatan Schlag
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jonatan Schlag @ 2017-07-19  8:52 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

Hi the following patches just do what is stated in the subject. 
If anything else could be improved (I know some code which is touched here and could be improved) i would like to do this when this patchset is merged. 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] pppoe-server: create hook_parse_cmdline function
  2017-07-19  8:52 Split the cmd line parsing in the config hooks in seperated functions Jonatan Schlag
@ 2017-07-19  8:52 ` Jonatan Schlag
  2017-07-19  8:52 ` [PATCH 2/4] ipv6-static: " Jonatan Schlag
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jonatan Schlag @ 2017-07-19  8:52 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1371 bytes --]

This patch just split the parsing of the cmd line
into a separate function to allowing an edit with the generic hook_edit function.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/pppoe-server | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/hooks/configs/pppoe-server b/src/hooks/configs/pppoe-server
index 22e0906..b4d2538 100644
--- a/src/hooks/configs/pppoe-server
+++ b/src/hooks/configs/pppoe-server
@@ -48,15 +48,7 @@ hook_check_config_settings() {
 	done
 }
 
-hook_new() {
-	local zone=${1}
-	shift
-
-	if zone_config_hook_is_configured ${zone} "pppoe-server"; then
-		log ERROR "You can configure the pppoe-server hook only once for a zone"
-		return ${EXIT_ERROR}
-	fi
-
+hook_parse_cmdline() {
 	while [ $# -gt 0 ]; do
 		case "${1}" in
 			--dns-server=*)
@@ -102,6 +94,21 @@ hook_new() {
 		esac
 		shift
 	done
+}
+
+hook_new() {
+	local zone=${1}
+	shift
+
+	if zone_config_hook_is_configured ${zone} "pppoe-server"; then
+		log ERROR "You can configure the pppoe-server hook only once for a zone"
+		return ${EXIT_ERROR}
+	fi
+
+	if ! hook_parse_cmdline $@; then
+		# Return an error if the parsing of the cmd line fails
+		return ${EXIT_ERROR}
+	fi
 
 	zone_config_settings_write "${zone}" "${HOOK}"
 
-- 
2.6.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/4] ipv6-static: create hook_parse_cmdline function
  2017-07-19  8:52 Split the cmd line parsing in the config hooks in seperated functions Jonatan Schlag
  2017-07-19  8:52 ` [PATCH 1/4] pppoe-server: create hook_parse_cmdline function Jonatan Schlag
@ 2017-07-19  8:52 ` Jonatan Schlag
  2017-07-19  8:52 ` [PATCH 3/4] ipv6-auto: " Jonatan Schlag
  2017-07-19  8:52 ` [PATCH 4/4] ipv4-static: " Jonatan Schlag
  3 siblings, 0 replies; 5+ messages in thread
From: Jonatan Schlag @ 2017-07-19  8:52 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

This patch just split the parsing of the cmd line
into a separate function to allowing an edit with the generic hook_edit function.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/ipv6-static | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/hooks/configs/ipv6-static b/src/hooks/configs/ipv6-static
index f43ef7e..4c1d7df 100644
--- a/src/hooks/configs/ipv6-static
+++ b/src/hooks/configs/ipv6-static
@@ -33,10 +33,7 @@ hook_check_config_settings() {
 	fi
 }
 
-hook_new() {
-	local zone=${1}
-	shift
-
+hook_parse_cmdline() {
 	while [ $# -gt 0 ]; do
 		case "${1}" in
 			--address=*)
@@ -58,6 +55,16 @@ hook_new() {
 	if [ -n "${GATEWAY}" ]; then
 		GATEWAY=$(ipv6_format "${GATEWAY}")
 	fi
+}
+
+hook_new() {
+	local zone=${1}
+	shift
+
+	if ! hook_parse_cmdline $@; then
+		# Return an error if the parsing of the cmd line fails
+		return ${EXIT_ERROR}
+	fi
 
 	zone_config_settings_write "${zone}" "${HOOK}"
 
-- 
2.6.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/4] ipv6-auto: create hook_parse_cmdline function
  2017-07-19  8:52 Split the cmd line parsing in the config hooks in seperated functions Jonatan Schlag
  2017-07-19  8:52 ` [PATCH 1/4] pppoe-server: create hook_parse_cmdline function Jonatan Schlag
  2017-07-19  8:52 ` [PATCH 2/4] ipv6-static: " Jonatan Schlag
@ 2017-07-19  8:52 ` Jonatan Schlag
  2017-07-19  8:52 ` [PATCH 4/4] ipv4-static: " Jonatan Schlag
  3 siblings, 0 replies; 5+ messages in thread
From: Jonatan Schlag @ 2017-07-19  8:52 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]

This patch just split the parsing of the cmd line
into a separate function to allowing an edit with the generic hook_edit function.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/ipv6-auto | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/hooks/configs/ipv6-auto b/src/hooks/configs/ipv6-auto
index c362797..375e585 100644
--- a/src/hooks/configs/ipv6-auto
+++ b/src/hooks/configs/ipv6-auto
@@ -30,14 +30,8 @@ hook_check_config_settings() {
 	assert isbool PRIVACY_EXTENSIONS
 }
 
-hook_new() {
-	local zone="${1}"
-	shift
-
-	if zone_config_hook_is_configured ${zone} "ipv6-auto"; then
-		log ERROR "You can configure the ipv6-auto hook only once for a zone"
-		return ${EXIT_ERROR}
-	fi
+hook_parse_cmdline() {
+	local arg
 
 	while read arg; do
 		case "${arg}" in
@@ -52,6 +46,21 @@ hook_new() {
 				;;
 		esac
 	done <<< "$(args $@)"
+}
+
+hook_new() {
+	local zone="${1}"
+	shift
+
+	if zone_config_hook_is_configured ${zone} "ipv6-auto"; then
+		log ERROR "You can configure the ipv6-auto hook only once for a zone"
+		return ${EXIT_ERROR}
+	fi
+
+	if ! hook_parse_cmdline $@; then
+		# Return an error if the parsing of the cmd line fails
+		return ${EXIT_ERROR}
+	fi
 
 	zone_config_settings_write "${zone}" "${HOOK}"
 
-- 
2.6.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 4/4] ipv4-static: create hook_parse_cmdline function
  2017-07-19  8:52 Split the cmd line parsing in the config hooks in seperated functions Jonatan Schlag
                   ` (2 preceding siblings ...)
  2017-07-19  8:52 ` [PATCH 3/4] ipv6-auto: " Jonatan Schlag
@ 2017-07-19  8:52 ` Jonatan Schlag
  3 siblings, 0 replies; 5+ messages in thread
From: Jonatan Schlag @ 2017-07-19  8:52 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1235 bytes --]

This patch just split the parsing of the cmd line
into a separate function to allowing an edit with the generic hook_edit function.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/ipv4-static | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/hooks/configs/ipv4-static b/src/hooks/configs/ipv4-static
index c395200..36629e0 100644
--- a/src/hooks/configs/ipv4-static
+++ b/src/hooks/configs/ipv4-static
@@ -35,12 +35,9 @@ hook_check_config_settings() {
 	fi
 }
 
-hook_new() {
-	local zone="${1}"
-	assert zone_exists "${zone}"
-	shift
-
+hook_parse_cmdline() {
 	local arg
+
 	while read -r arg; do
 		local key="$(cli_get_key "${arg}")"
 		local val="$(cli_get_val "${arg}")"
@@ -105,6 +102,18 @@ hook_new() {
 	if ! isset GATEWAY && zone_is_nonlocal "${zone}"; then
 		warning "You did not configure a gateway for a non-local zone"
 	fi
+}
+
+hook_new() {
+	local zone="${1}"
+	shift
+
+	assert zone_exists "${zone}"
+
+	if ! hook_parse_cmdline $@; then
+		# Return an error if the parsing of the cmd line fails
+		return ${EXIT_ERROR}
+	fi
 
 	zone_config_settings_write "${zone}" "${HOOK}"
 
-- 
2.6.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-19  8:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-19  8:52 Split the cmd line parsing in the config hooks in seperated functions Jonatan Schlag
2017-07-19  8:52 ` [PATCH 1/4] pppoe-server: create hook_parse_cmdline function Jonatan Schlag
2017-07-19  8:52 ` [PATCH 2/4] ipv6-static: " Jonatan Schlag
2017-07-19  8:52 ` [PATCH 3/4] ipv6-auto: " Jonatan Schlag
2017-07-19  8:52 ` [PATCH 4/4] ipv4-static: " Jonatan Schlag

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox