1. Get ip and netmask from input
if no NetMask then NetMask = 32
2. ipnumber = ip1*16777216 + ip2 * 65536 + ip3 * 256 + ip4
(this is 丑小鸭's MakeDWord and Denis2's FOR Loop )
3. get InFileIPnumber and InFileMask from the file = 'ips.txt'
using the same why above
if InFileMask > NetMask then show "not found"
(both of you two forgot this la. actually you don't need to calculate
InFileMask > NetMask :)
4. ipnumber = ipnumber / 2 ** ( 32 - InFileMask )
inFileIPNumber = inFileIPNumber / 2 ** ( 32- InFileMask )
if (ipnumber == ipFileIPNumber) then show "FOUND!"
I think it is the simplest algorithm.
So language is not important. The way to do it really is.
Enjoy. :-)
if no NetMask then NetMask = 32
2. ipnumber = ip1*16777216 + ip2 * 65536 + ip3 * 256 + ip4
(this is 丑小鸭's MakeDWord and Denis2's FOR Loop )
3. get InFileIPnumber and InFileMask from the file = 'ips.txt'
using the same why above
if InFileMask > NetMask then show "not found"
(both of you two forgot this la. actually you don't need to calculate
InFileMask > NetMask :)
4. ipnumber = ipnumber / 2 ** ( 32 - InFileMask )
inFileIPNumber = inFileIPNumber / 2 ** ( 32- InFileMask )
if (ipnumber == ipFileIPNumber) then show "FOUND!"
I think it is the simplest algorithm.
So language is not important. The way to do it really is.
Enjoy. :-)