YaST2 Developers Documentation: yast2

yast2

modules/IP.ycp
IP manipulation routines
  • Michal Svec

This module has an unstable interface.

Imports

  • Netmask

Global Functions

global Valid4 () -> string

Describe a valid IPv4 address

Return value:
describtion a valid IPv4 address
global Check4 (string ip) -> boolean

Check syntax of IPv4 address

Parameters:
ip IPv4 address
Return value:
true if correct
global Valid6 () -> string

Describe a valid IPv6 address

Return value:
describtion a valid IPv4 address
global Check6 (string ip) -> boolean

Check syntax of IPv6 address

Parameters:
ip IPv6 address
Return value:
true if correct
global UndecorateIPv6 (string ip) -> string

If param contains IPv6 in one of its various forms, extracts it.

if ip is closed in [ ] or contain % then it can be special case of IPv6 syntax, so extract ipv6 (see description later) and continue with check.

IPv6 syntax: - pure ipv6 blob (e.g. f008::1) - ipv6 blob with link local suffix (e.g. f008::1%eth0) - dtto in square brackets (e.g. [f008::1%eth0] )

Parameters:
ip a buffer with address
Return value:
IPv6 part of ip param, unchanged ip param otherwise
global Check (string ip) -> boolean

Check syntax of IP address

Parameters:
ip IP address
Return value:
true if correct
global ValidNetwork () -> string

Returns string of valid network definition. Both IPv4 and IPv6.

Return value:
describing the valid network.
global ToInteger (string ip) -> integer

Convert IPv4 address from string to integer

Parameters:
ip IPv4 address
Return value:
ip address as integer
global ToString (integer ip) -> string

Convert IPv4 address from integer to string

Parameters:
ip IPv4 address
Return value:
ip address as string
global ToHex (string ip) -> string

Converts IPv4 address from string to hex format

Parameters:
ip IPv4 address as string in "ipv4" format
Return value:
representing IP in Hex
Example
 IP::ToHex("192.168.1.1") -> "0xC0A80101"
 IP::ToHex("10.10.0.1") -> "0x0A0A0001"
global ComputeNetwork (string ip, string mask) -> string

Compute IPv4 network address from ip4 address and network mask.

Parameters:
ip IPv4 address
mask netmask
Return value:
computed subnet
global ComputeBroadcast (string ip, string mask) -> string

Compute IPv4 broadcast address from ip4 address and network mask.

Parameters:
ip IPv4 address
mask netmask
Return value:
computed broadcast
global IPv4ToBits (string ipv4) -> string

Converts IPv4 into its 32 bit binary representation.

Parameters:
ipv4
Return value:
binary
Example

     IPv4ToBits("80.25.135.2")    -> "01010000000110011000011100000010"
     IPv4ToBits("172.24.233.211") -> "10101100000110001110100111010011"
See
BitsToIPv4()
global BitsToIPv4 (string bits) -> string

Converts 32 bit binary number to its IPv4 repserentation.

Parameters:
bits
Return value:
ipv4
Example

     BitsToIPv4("10111100000110001110001100000101") -> "188.24.227.5"
     BitsToIPv4("00110101000110001110001001100101") -> "53.24.226.101"
See
IPv4ToBits()
global CheckNetwork4 (string network) -> boolean

Checks the given IPv4 network entry.

Parameters:
network
Example

   CheckNetwork("192.168.0.0/255.255.255.0") -> true
   CheckNetwork("192.168.1.22") -> true
   CheckNetwork("172.55.0.0/33") -> false
See
CheckNetwork for details. CheckNetwork6 for IPv6 version of the same function.
global CheckNetwork6 (string network) -> boolean

Checks the given IPv6 network entry.

Parameters:
network
Example

   CheckNetwork("2001:db8:0::1/64") -> true
   CheckNetwork("2001:db8:0::1") -> true
   CheckNetwork("::1/257") -> false
See
CheckNetwork for details. CheckNetwork4 for IPv4 version of the same function.
global CheckNetwork (string network) -> boolean

Checks the given network entry which can be defined in several formats: - Single IPv4 or IPv6, e.g., 192.168.0.1 or 2001:db8:0::1 - IP/Netmask, e.g., 192.168.0.0/255.255.255.0 or 2001:db8:0::1/ffff:ffff::0 - IP/CIDR, e.g., 192.168.0.0/20 or 2001:db8:0::1/56

Parameters:
network
Example

  CheckNetwork("192.168.0.1") -> true
  CheckNetwork("192.168.0.0/20") -> true
  CheckNetwork("192.168.0.0/255.255.255.0") -> true
  CheckNetwork("0/0") -> true
  CheckNetwork("::1/128") -> true
  CheckNetwork("2001:db8:0::1") -> true
  CheckNetwork("2001:db8:0::1/64") -> true
  CheckNetwork("2001:db8:0::1/ffff:ffff::0") -> true
  CheckNetwork("2001:db8:0::xyz") -> false
  CheckNetwork("::1/257") -> false
  CheckNetwork("172.55.0.0/33") -> false
  CheckNetwork("172.55.0.0/125.85.5.5") -> false