Example #1
0
    def is_ipv4_format(cls, candidate):
        """
        Validating the IPv4 address format.

        @param candidate: candidate string to validate
        @str candidate: str

        @return: True if correct IPv4 format
        @rtype: bool
        """
        if "." in candidate :
            if len(candidate.split(".")) == 4 :
                for num in candidate.split(".") :
                    if not isdigit(num) :
                        return False
                return True
        return False
Example #2
0
    def is_ipv4_format(cls, candidate):
        """
        Validating the IPv4 address format.

        @param candidate: candidate string to validate
        @str candidate: str

        @return: True if correct IPv4 format
        @rtype: bool
        """
        if "." in candidate:
            if len(candidate.split(".")) == 4:
                for num in candidate.split("."):
                    if not isdigit(num):
                        return False
                return True
        return False
Example #3
0
    def netmask_validate(cls, netmask):
        """
        Check of netmask format

        @param netmask: checked netmask
        @type netmask: str

        @return: True if netmask is valid
        @rtype: bool
        """
        if not NetUtils.is_ipv4_format(netmask) :
            return False
        for element in netmask.split("."):
            if not isdigit(element):
                return False
            if int(element) not in SUBNET_BITS :
                return False
        return True
Example #4
0
    def netmask_validate(cls, netmask):
        """
        Check of netmask format

        @param netmask: checked netmask
        @type netmask: str

        @return: True if netmask is valid
        @rtype: bool
        """
        if not NetUtils.is_ipv4_format(netmask):
            return False
        for element in netmask.split("."):
            if not isdigit(element):
                return False
            if int(element) not in SUBNET_BITS:
                return False
        return True