IP Calculator Final Version
Bob Sneidar
bobsneidar at iotecdigital.com
Mon Jan 26 19:22:25 EST 2015
Oh thanks Alex I will check for those. I though they would be covered in the part that checks that each octet is a number between 0 and 255.
As far as the CIDR depth, it is true that technically you can have a CIDR of 32, but it is not a network that can be used. That would leave no usable addresses, and the subnet and broadcast addresses would not be assignable. A CIDR of 31 has 2 addresses, neither of them usable by a node, as they would have to be the subnet address and the broadcast address.
The highest CIDR that has any node assignable addresses is 30. That has only 2 usable addresses, and is typically used as the WAN subnet for a single IP router, the other being the gateway address.
A CIDR of 0 has no subnet mask, and therefore cannot be used except for a multicast network where everything is a node, there is no universal broadcast address and no routing is possible.
For the sake of accuracy, I will expand the range to 0 to 32. It will be up to the calling function to then determine if their subnet is usable.
Bob S
On Jan 26, 2015, at 12:14 , Alex Tweedly <alex at tweedly.net<mailto:alex at tweedly.net>> wrote:
A couple of error cases that aren't caught gracefully
192.168.1/24.1
192.168..1/24
One that is accepted and shouldn't be
192.168.1.1/24. (note the trailing ".")
Also, not sure why you limit CIDRDepth to between 1 and 30. RFC 4632 specifically says between 0 and 3 - and indeed host routes (/32s) are common enough, as is default route.
Thanks again for contributing this Bob.
-- Alex.
More information about the use-livecode
mailing list