parse_ip

Description

Parse an IPv4 or IPv6 network address into relevant attributes.

When the input is an IPv(4/6) address, returns a JSON object containing the following attributes - family (either “4” or “6”), host (passed host IP), ip_fields (Array of 4 32-bit integers each representing 32 bits from the given IP), ip_type (always “inet”), netmask_prefix_length (Always null). When the address is an IPv4 address, an attribute ipv4 (integer representation of the address) is also added, when it’s an IPv6 address, an attribute hex_ipv6 (integer representation of the address in hexadecimal) is also added.

When the input is an IPv4 subnet mask, along with the above attributes, the following are also returned - ipv4_range_start (integer representation of the least IP address in the given range) , ipv4_range_end (integer representation of the highest IP address in the given range), netmask_prefix_length (length of the subnet mask). When the input is an IPv6 subnet mask, these attributes are prefixed with “hex_ipv6” instead of “ipv4” and the corresponding values are in hexadecimal.

Return type

object

Domain

This is a scalar function (calculates a single output value for a single input row.)

Categories

Usage

parse_ip(arg)

Argument

Type

Optional

Repeatable

Restrictions

arg

ipv4 or string

no

no

none

Examples

make_col ip:parse_ip(@.x)

Creates a column named ‘ip’ containing the returned JSON object

make_col ip:parse_ip('10.1.2.3')

Creates a column named ‘ip’ containing the following object:

{
  "family": 4,
  "host": "10.1.2.3",
  "ip_fields": [
    167838211,
    0,
    0,
    0
  ],
  "ip_type": "inet",
  "ipv4": 167838211,
  "netmask_prefix_length": null
}

Aliases

parseip (deprecated)