import network
import math

class Ipv4Net(network.Network):
    
    def __init__(self, net_id, netmask):
        self.netmask = netmask
        self.network_id = net_id

    @property
    def network_id(self):
        return self._netid

    @network_id.setter
    def network_id(self, addr):
        self._netid = addr & self.netmask

    @property
    def netmask(self):
        return self._mask

    @netmask.setter
    def netmask(self, addr):
        # TODO: Bug test
        if math.log(addr + 1, 2) % 1 == 0:
            self._mask = addr
        else:
            raise ValueError("Improper value for netmask %s, must be address \
                             with only consecutive bits" %addr)


    # do i even need these functions or should I instead use something like pop/set/builtins etc
    def addhost(self, host):
        # TODO: make sure it's isinstance(ipv4) etc etc
        pass

    def delhost(self, host):
        # TODO: everything o_o
        pass





__all__ = ['Ipv4Net']
import network
import math

class Ipv4Net(network.Network):
    
    def __init__(self, net_id, netmask):
        self.netmask = netmask
        self.network_id = net_id

    @property
    def network_id(self):
        return self._netid

    @network_id.setter
    def network_id(self, addr):
        self._netid = addr & self.netmask

    @property
    def netmask(self):
        return self._mask

    @netmask.setter
    def netmask(self, addr):
        # TODO: Bug test
        cidr = int(math.log(addr + 1, 2))
        if 2**cidr != addr + 1:
            raise ValueError("Improper value for netmask %s, must be address \
                             with only consecutive bits" %addr)
        else:
            self._mask = addr

    # do i even need these functions or should I instead use something like pop/set/builtins etc
    def addhost(self, host):
        # TODO: make sure it's isinstance(ipv4) etc etc
        pass

    def delhost(self, host):
        # TODO: everything o_o
        pass





__all__ = ['Ipv4Net']
Revert "Minor tweak to make netmask checking more flashy :V"
Revert "Minor tweak to make netmask checking more flashy :V"

This reverts commit 6a1bfc3ae8dda1932555a7aada3dd5f0e792507f.
