From 1dbb6df41738fa92b53b922ff462bd3ab7dcae2a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 22 Jun 2012 10:11:48 +0000 Subject: [PATCH] ipv4_get_netaddress: Allow passing a single IP address. --- functions.ipv4 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/functions.ipv4 b/functions.ipv4 index 10297985..aada214a 100644 --- a/functions.ipv4 +++ b/functions.ipv4 @@ -69,14 +69,19 @@ function ipv4_get_netaddress() { assert isset address local prefix=$(ip_get_prefix ${address}) - assert isset prefix + isset prefix || prefix="32" + + # Assume host-only address if no prefix has been given. + if [ "${prefix}" = "32" ]; then + echo "${address}/${prefix}" + return ${EXIT_OK} + fi local NETWORK eval $(ipcalc --network ${address}) assert isset NETWORK echo "${NETWORK}/${prefix}" - return ${EXIT_OK} } -- 2.47.3