Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All
     

    Related Documentation

     

    parse-ip() Function (jcs Namespace)

    Namespaces

    http://xml.juniper.net/junos/commit-scripts/1.0

    SLAX Syntax

    var $result = jcs:parse-ip("ipaddress/(prefix-length | netmask)");

    XSLT Syntax

    <xsl:variable name="result" select="jcs:parse-ip('ipaddress/(prefix-length | netmask')"/>

    Release Information

    Function introduced in Junos OS Release 9.0.

    Description

    Parse an IPv4 or IPv6 address.

    Parameters

    ipaddress
    —

    IPv4 or IPv6 address.

    netmask
    —

    Netmask defining the network prefix portion of the address.

    prefix-length
    —

    Prefix length defining the number of bits used in the network prefix portion of the address.

    Return Value

    result
    —

    An array containing:

    • Host IP address (or NULL in the case of an error)
    • Protocol family (inet for IPv4 or inet6 for IPv6)
    • Prefix length
    • Network address
    • Network mask in dotted decimal notation for IPv4 addresses (left blank for IPv6 addresses)

    Usage Examples

    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("2001:DB8::c50:8a:800:200C:417A/32");
    • $addr[1] contains the host address 2001:db8:0:c50:8a:800:200c:417a.
    • $addr[2] contains the protocol family inet6.
    • $addr[3] contains the prefix length 32.
    • $addr[4] contains the network address 2001:db8::.
    • $addr[5] is blank for IPv6 ("").
     

    Related Documentation

     

    Published: 2013-03-05