/31 network is still incorrect
Opened this issue · 0 comments
realvitya commented
Cygwin ~ $ ic 1.1.1.1/31
first host: 1.1.1.1/31
last host.: 1.1.1.2
The bug report for this initially:#17 The fix is not correct as seen above.
This may be a fix for the above bug:
def host_first(self):
if (self.version() == 4 and self.mask > 30) or \
(self.version() == 6 and self.mask > 126):
-return self
+return self.network()
...
def host_last(self):
"""Last available host in this subnet."""
if (self.version() == 4 and self.mask == 32) or \
...
elif (self.version() == 4 and self.mask == 31) or \
(self.version() == 6 and self.mask == 127):
-return IP(int(self) + 1, version=self.version())
+return IP(int(self.network()) + 1, version=self.version())