jcs:parse-ip() Function
Syntax
var $result = jcs:parse-ip("ipaddress/(prefix-length | netmask)")Description
Evaluate an IPv4 or IPv6 address.
Parameters
- ipaddress—IPv4 or IPv6 address.
- prefix-length—Prefix length defining the number of bits used in the network prefix portion of the address.
- netmask—Netmask defining the network prefix portion of the address.
Return Value
- $result—An array containing:
- Host address (or NULL in the case of an error)
- Protocol family (inet for IPv4 or inet6 for IPv6)
- Prefix length
- Network address
- Netmask (for IPv4 address; left blank for IPv6 addresses)
In the following examples, an IPv4 address and an IPv6 address are parsed and the resulting output is detailed:
var $addr = jcs:parse-ip("10.1.2.10/255.255.255.0");- $addr[1] contains the host address 10.1.2.10.
- $addr[2] contains the protocol family inet.
- $addr[3] contains the prefix length 24.
- $addr[4] contains the network address 10.1.2.0.
- $addr[5] contains the netmask for IPv4 255.255.255.0.
var $addr = jcs:parse-ip("080:0:0:0:8:800:200C:417A/100");- $addr[1] contains the host address 80::8:800:200C:417A.
- $addr[2] contains the protocol family inet6.
- $addr[3] contains the prefix length 100.
- $addr[4] contains the network address 80::8:800:2000:0.
- $addr[5] is blank for IPv6 ("").
Hide Navigation Pane
Show Navigation Pane
Download
SHA1