Document toolboxDocument toolbox

Is IPv4 (isip4)

Description

Creates a Boolean column that returns true if a specified IPv6 is carrying an IPv4.

How does it work in the search window?

Select Create column in the search window toolbar, then select the Is IPv4 operation. You need to specify one argument:

Argument

Data type

Argument

Data type

IPv6 to test mandatory

ip6

The data type of the values in the new column is boolean.

Example

In the demo.ecommerce.data table, we want to know if the clientIpAddress column is carrying an IPv4. To do it, we need to transform it first into IPv6 format using the To IPv6 (ip6) operation. Then, click Create column on the query toolbar and select the Is IPv4 operation.

The arguments needed to create the new column are:

  • IPv6 →  clientIpAddressIPv6 column obtained from the previous conversion operation.

Click Create column and you will see the following result:

How does it work in LINQ?

When using the search window interface to manually introduce the argument instead of using a column, the To IPv6 (ip6) operation will be transparently performed to convert the string specified into an ip6 data type. This means that you will not notice that such an intermediate step exists. 

Though this conversion is implicit while using the search window interface, it must be explicitly done when writing the query in LINQ, as shown in the second example below.

Use the operator select... as...  and add the operation syntax to create the new column. This is the syntax for the Is IPv4 operation:

  • isip4(ip6)

Example

You can copy the following LINQ script and try the above example on the demo.ecommerce.data table. 

from demo.ecommerce.data select ip6(clientIpAddress) as clientIpAddressIpv6, isip4(clientIpAddressIpv6) as Ipv6IsIpv4

You can copy the following LINQ script to see how the string conversion must be explicitly performed in LINQ when specifying the argument instead of using a column.

from demo.ecommerce.data select isip4(ip6("2001:db8:85a3::8a2e:370:7334")) as Ipv6IsIpv4