Document toolboxDocument toolbox

To IPv4 (isip4)

Description

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

How does it work in the search window?

Select Create field 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 field is boolean.

Example

In the demo.ecommerce.data table, we want to know if the clientIpAddress field 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 field on the query toolbar and select the Is IPv4 operation.

The arguments needed to create the new field are:

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

Click Create field.

How does it work in LINQ?

When using the search window interface to manually introduce the argument instead of using a field, 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 field. 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 field.

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