home *** CD-ROM | disk | FTP | other *** search
- /**
- * File: modules/Address.ycp
- * Package: yast2
- * Summary: Address manipulation routines
- * Authors: Michal Svec <msvec@suse.cz>
- * Flags: Stable
- *
- * $Id: Address.ycp 33224 2006-10-02 14:17:13Z jsrain $
- *
- * Address is a hostname (either FQ or simple, or IP address)
- */
-
- {
-
- module "Address";
- textdomain "base";
-
- import "Hostname";
- import "IP";
-
- global string ValidChars = Hostname::ValidChars+IP::ValidChars;
- global string ValidChars4 = Hostname::ValidChars+IP::ValidChars4;
- global string ValidChars6 = Hostname::ValidChars+IP::ValidChars6;
- global string ValidCharsMAC = "0123456789abcdefABCDEF:";
-
- /**
- * Return a description of a valid address (ip4 or name)
- * @return description
- */
- global define string Valid4() ``{
- return IP::Valid4() + "\n" + Hostname::ValidFQ();
- }
-
- /**
- * Check syntax of a network address (ip4 or name)
- * @param address an address
- * @return true if correct
- */
- global define boolean Check4(string address) ``{
- return IP::Check4(address) || Hostname::CheckFQ(address);
- }
-
- /**
- * Check syntax of a network address (ip6 or name)
- * @param address an address
- * @return true if correct
- */
- global define boolean Check6(string address) ``{
- return IP::Check6(address) || Hostname::CheckFQ(address);
- }
-
- /**
- * Check syntax of a network address (IP address or hostname)
- * @param address an address
- * @return true if correct
- */
- global define boolean Check(string address) ``{
- return Check4(address) || Check6(address);
- }
-
- /**
- * Describe a valid MAC address
- * @return string description of a valid MAC address
- */
- global define string ValidMAC() ``{
- //describe valid MAC address
- return _("A valid MAC address consists of six pairs of hexadecimal
- digits separated by colons.");
- }
-
- /**
- * Check syntax of MAC address
- * @param address MAC address
- * @return true if correct
- */
- global define boolean CheckMAC(string address) ``{
- if (address == nil || address == "")
- return false;
-
- string regexp = "[0-9a-fA-F]{2,2}";
- regexp = sformat ("(%1:){5,5}%1", regexp);
-
- return regexpmatch(address, regexp);
- }
-
- /* EOF */
- }
-