You just need to pass the CIDR number to the SUB.
I recieved the data in this format <IP ADDRESS>/<CIDR> so I needed to filter and rebuild with split and filter. Have a look and let me know what you think.
sub Action_Mask
j = 0
for j = 0 to lineRule - 1
redim arrText(ubound(arrOUTBound))
arrText(j) = arrBound(5,j)
strText = arrText(j) outputArray = filter(array(strText),"/")
if join(outputArray) <> "" then
netArray = split(strText ,"/")
for each w in netArray
if len(w) = 2 then
CIDR2Mask(w)
else
strIP = w & "/"
end if
strIP = strIP & strPassMask
strPassMask = EMPTY
next
arrBound(5,j) = strIP
strIP = empty
else
end if
if strText = "" then
strText = "*"
end if
next
END SUB SUB CIDR2Mask(strPassCIDR)
DIM full_octets, partial_octet, strMask
DIM intCalc, intCIDR, i
intCIDR = strPassCIDR
' Calculate the Full and Partial Octets
full_octets = intCIDR \ 8
partial_octet = intCIDR MOD 8
strMask = "255"
i = 0
for i = 0 to 4
if i < full_octets then
strMask = strMask & ".255"
else if i = full_octets then
intCalc = (256 - 2^(8 - partial_octet))
strMask = strMask & "." & intCalc
else
strMask = strMask & ".0"
end if
end if
i = i + 1
NEXT
strPassMask = strMask
END SUB
INPUT DATA EXAMPLE: 172.16.20.0/22
OUTPUT DATA EXAMPLE: 172.16.20.0/255.255.252.0
I converted this C# script from here:
http://code.google.com/p/mats-tools/source/browse/trunk/cidr2mask.sh?spec=svn2&r=2 I don't know who wrote the origional code but Many Props to you for doing so.
Dan Pallone II
"I became insane, with long intervals of horrible sanity."
—
Edgar Allan Poe
<message edited by dpallone on Friday, May 13, 2011 2:41 AM>