ipv4_network_int64

ipv4_network_int64(ipv4: string) -> int64

Converts IPv4 network addresses to integer representation.

Given an IPv4 network address string in dotted-quad format, convert the address to an integer representing the address in big-endian (network) byte order, masked either to the slash-masksize mask, or to the natural class A, B, C, or private network format.

CIDR formatting (in which the dotted-quad address is followed by a slash and a netmask size component) is supported.

Using this function you can decode CIDR network addresses, as well as classic "class" and "private" subnet addresses.

Masks formats, and derived masks, are:

ValueMaskExplanation
8.8.4.4255.0.0.0Class A
10.0.0.0255.0.0.0Private 10.x.y.z
10.0.0.0/16255.255.0.0Mask /16
127.0.0.1255.0.0.0Class A
127.0.0.1/24255.255.255.0Mask /24
128.1.2.3255.255.0.0Class B
172.30.2.3255.240.0.0Private 172.-15.x.y
192.168.0.3255.255.0.0Private 192.168.x.y
200.1.2.3255.255.255.0Class C

Domain

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

Categories

Examples

make_col ipint:ipv4_network_int64(ipstr)

Assuming there's a string input column with IP addresses, outputs the corresponding network addresses as integers in network byte order.

ipstr (input)ipint (output)
8.8.4.4134217728
10.0.0.1167772160
10.0.0.1/16167772160
127.0.0.12130706432
127.0.0.1/242130706432
128.1.2.32147549184
172.30.2.32887647232
192.168.0.33232235520
200.1.2.33355509248
1.2.3.300null
1.2.3.4.5null
1.2.3null
localhostnull