def cidr_to_netmask(cidr):
    """
    Convert cidr to netmask

    Notes:
        http://www.linuxquestions.org/questions/blog/bittner-195120/cidr-to-netmask-conversion-with-python-convert-short-netmask-to-long-dotted-format-3147/

    Args:
        cidr (int): cidr value

    Returns:
        string: netmask (ie 255.255.255.0)
    """
    mask = ''
    if not isinstance(cidr, int) or cidr<0 or cidr>32: # pragma: no cover
            return None
    
    for t in range(4):
        if cidr > 7:
            mask += '255.'
        else:
            dec = 255 - (2**(8 - cidr) - 1)
            mask += str(dec) + '.' 
        cidr -= 8
        if cidr < 0:
            cidr = 0 
    
    return mask[:-1]