Closed hpshelton closed 3 years ago
StartAddress
works as intended when commenting out the final mask addressBytes[addressBytes.Length - 1] |= 0x01
and EndAddress
works as intended when commenting out addressBytes[addressBytes.Length - 1] &= 0xFE
.
https://docs.netgate.com/pfsense/en/latest/network/cidr.html has helpful documentation about support for /31
and asserts that systems supporting RFC 3021 should return two useable host addresses.
thanks for reporting this, fixed and pushed to the repo. will be published in the next release which will be in a couple of hours
When parsing CIDR address notation to generate a
NetworkAddress
type, theAddress
andSubnetMask
properties store the intended values. However, the logic forStartAddress
andEndAddress
attempt to exclude the lowest (original network) IP and the highest (broadcast) IP. This works for large subnet masks, but is improperly executed when using a small mask to request a small number of IP addresses per this sample program:Note that
StartAddress
andEndAddress
are reversed for the/31
case.At a high level, these results are counter-intuitive to begin with as when requesting a
/30
, one would expect 4 IP addresses when only 2 are provided. When requesting a/31
, intuitively 2 IP addresses would be provided. Seemingly returning the full range without truncation would be a better behavior than having both '/31' and '/30' returning 2 IP addresses.