From: Michael Tremer Date: Mon, 14 Sep 1981 16:12:37 +0000 (+0000) Subject: Make versioning of IP protocols more modular. X-Git-Tag: 001~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e617226b861355a131c175456f7781e8f321b9dc;p=network.git Make versioning of IP protocols more modular. --- diff --git a/functions.ip b/functions.ip index f95265e9..a0dad1a1 100644 --- a/functions.ip +++ b/functions.ip @@ -19,6 +19,9 @@ # # ############################################################################### +# A list of supported versions of the IP protocol +IP_SUPPORTED_PROTOCOLS="" + function ip_split_prefix() { local address=${1} @@ -41,7 +44,7 @@ function ip_detect_protocol() { assert isset address local protocol - for protocol in ipv4 ipv6; do + for protocol in ${IP_SUPPORTED_PROTOCOLS}; do if ${protocol}_is_valid ${address}; then echo "${protocol}" return ${EXIT_OK} @@ -50,3 +53,11 @@ function ip_detect_protocol() { return ${EXIT_ERROR} } + +function ip_protocol_is_supported() { + local proto=${1} + + assert isset proto + + listmatch ${proto} ${IP_SUPPORTED_PROTOCOLS} +} diff --git a/functions.ipv4 b/functions.ipv4 index 74c524a4..a29fc397 100644 --- a/functions.ipv4 +++ b/functions.ipv4 @@ -19,6 +19,8 @@ # # ############################################################################### +IP_SUPPORTED_PROTOCOLS="${IP_SUPPORTED_PROTOCOLS} ipv4" + function ipv4_split_prefix() { ip_split_prefix $@ } diff --git a/functions.ipv6 b/functions.ipv6 index 73a774bb..b733d0ca 100644 --- a/functions.ipv6 +++ b/functions.ipv6 @@ -19,6 +19,8 @@ # # ############################################################################### +IP_SUPPORTED_PROTOCOLS="${IP_SUPPORTED_PROTOCOLS} ipv6" + function ipv6_init() { log INFO "Initializing IPv6 networking."