]> git.ipfire.org Git - people/ms/network.git/commitdiff
ip: Allow detection of protocol for networks, too
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Tue, 30 May 2017 08:24:15 +0000 (10:24 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Tue, 30 May 2017 08:24:15 +0000 (10:24 +0200)
This is very convenient when we need to detect the protocol
of a network without splitting off the prefix first.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
src/functions/functions.ip

index 9572141bafbf7b950289daa083661b7017fc6f3d..e938a5355b475078067472274a5045d340394992 100644 (file)
@@ -41,9 +41,11 @@ ip_get_prefix() {
 
 ip_detect_protocol() {
        local address="${1}"
-
        assert isset address
 
+       # Remove prefix so that we can handle subnet, too
+       address=$(ip_split_prefix ${address})
+
        local protocol
        for protocol in ${IP_SUPPORTED_PROTOCOLS}; do
                if ${protocol}_is_valid "${address}"; then