ipv4_network_int64

Description

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-mashsize 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:

Value

Mask

Explanation

8.8.4.4

255.0.0.0

Class A

10.0.0.0

255.0.0.0

Private 10.x.y.z

10.0.0.0/16

255.255.0.0

Mask /16

127.0.0.1

255.0.0.0

Class A

127.0.0.1/24

255.255.255.0

Mask /24

128.1.2.3

255.255.0.0

Class B

172.30.2.3

255.240.0.0

Private 172.{16-31}.x.y

192.168.0.3

255.255.0.0

Private 192.168.x.y

200.1.2.3

255.255.255.0

Class C

Return type

int64

Domain

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

Categories

Usage

ipv4_network_int64(ipv4)

Argument

Type

Optional

Repeatable

Restrictions

ipv4

string

no

no

none

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.4

134217728

10.0.0.1

167772160

10.0.0.1/16

167772160

127.0.0.1

2130706432

127.0.0.1/24

2130706432

128.1.2.3

2147549184

172.30.2.3

2887647232

192.168.0.3

3232235520

200.1.2.3

3355509248

1.2.3.300

null

1.2.3.4.5

null

1.2.3

null

localhost

null