parse-ip() Function (SLAX and XSLT) and parse_ip() (Python)
Namespaces
http://xml.juniper.net/junos/commit-scripts/1.0
Python Syntax
result = jcs.parse_ip("ipaddress/(prefix-length | netmask)")
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')"/>
Description
Parse an IPv4 or IPv6 address.
Parameters
ipaddress |
IPv4 or IPv6 address. |
netmask |
Netmask defining the network portion of the address. |
prefix-length |
Prefix length defining the number of bits used in the network portion of the address. |
Return Value
result |
An array containing the following information. In SLAX and XSLT scripts, the array index starts at 1. In Python scripts, the array index begins at 0.
|
Usage Examples
The following two SLAX examples parse an IPv4 address and an IPv6 address and detail the resulting output:
var $addr = jcs:parse-ip("10.1.2.10/255.255.255.0");
$addr[1]
contains the host address10.1.2.10
.$addr[2]
contains the protocol familyinet
.$addr[3]
contains the prefix length24
.$addr[4]
contains the network address10.1.2.0
.$addr[5]
contains the netmask for IPv4255.255.255.0
.
var $addr = jcs:parse-ip("2001:DB8::c50:8a:800:200C:417A/32");
$addr[1]
contains the host address2001:db8:0:c50:8a:800:200c:417a
.$addr[2]
contains the protocol familyinet6
.$addr[3]
contains the prefix length32
.$addr[4]
contains the network address2001:db8::
.$addr[5]
is blank for IPv6 (""
).
The following Python statement parses an IPv4 address.
The values in the addr
array are shown.
Note that the array index begins at 0.
addr = jcs.parse_ip('10.1.2.10/255.255.255.0')
$addr[0]
contains the host address10.1.2.10
.$addr[1]
contains the protocol familyinet
.$addr[2]
contains the prefix length24
.$addr[3]
contains the network address10.1.2.0
.$addr[4]
contains the netmask for IPv4255.255.255.0
.
Release Information
Function introduced in Junos OS Release 9.0.
Support for Python added in Junos OS Release 16.1R1.