inetaf / netaddr

Network address types

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proposal: add Count() or Len() methods

ortolot opened this issue · comments

Hello,

I think it would be useful to be able to get the number of IP addresses in ranges, prefixes and sets. That could take the form of Count() or Len() methods, I think.

For prefixes, the number of IP addresses would include all of them, including the min and max ones even if they could be a network and a broadcast address, as:

  • they are valid IP addresses,
  • tt is easy for the user to remove them from the count if needed,
  • including them makes it easier to add counts of multiple prefixes.

Right now, I think that, in order to count IP addresses in a range, I would have to convert its bounds into net.IPAddr and do arithmetics from there.

Regards,

--
Tanguy Ortolo