I&#39;d like to see more clear direction for this. Is it a string manipulation library, or an IP address library?<br>
<br>
There are ONLY TWO types of IP representations:<br>1. Network = 32 bit
number AND 32 bit mask. That is the binary AND. The mask needs to be preserved, but not the network portion. Any library should
return the ANDed result. Whether the number is <a href="http://192.186.1.1/24" target="_blank">192.186.1.1/24</a> or <a href="http://192.168.1.0/24" target="_blank">192.168.1.0/24</a>,
the result after &#39;and&#39; is the same. Add a strict=false in case people
need it for validation, better yet, add a validation helper function,
but always return the proper form.<br>
<br>
2. A host address is an IP address with no network info.  No mask information, ever.<br>
<br>
<br>
What about Broadcast / Network IDs?<br>
The &quot;Network-ID or Network Number&quot; and &quot;Broadcast&quot; are meaningless without context.<br>
1. A network number by itself it&#39;s just another address. Its use depends on context. When routing, it needs a mask. <br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">route 10.0.0.0 255.0.0.0 192.168.1.1<br>
</blockquote>
When writing firewall ACLs, it is a host.<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">access-list aclname permit ip any 192.168.1.2 255.255.255.254<br>
</blockquote>
Since both are valid, preference shouldn&#39;t be given. Instead add a helper for firstip.<br>
<br>
2. Same story with broadcast. Use depends on context. Add the lastip helper.<br>
<br>
<br>
What does iterating over a network mean?<br>
Iterating over the set of addresses in a network must return host
addresses. If it returns a network, then the address should be ANDed, but
that would return the same number for every iteration. Only returning hosts makes sense.<br>
<br>
We need to set a solid line between IP String manipulation and IP manipulation.<br>
If you want an IP with a mask that isn&#39;t a network, then you&#39;re not
doing IP address manipulation, you&#39;re doing string manipulation. There are many use cases for it, but it&#39;s a separate consideration to pure IP manipulation.<br>
<br>
If string manipulation is desirable, then add another standard library
called ipstring (or a separate class if you want it all jumbled in the
same import).  This way real network computing can be done without
weird quirks of representation.<br>
<br>
R.