Key

• This line was added.
• This line was removed.
• Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next

D toc

Excerpt

Computes a four-octet internet protocol (IP) address from a 32-bit integer input.

Source value must be a valid integer within the range specified by the formula below. A valid IPv4 address is in the following format:

Code Block
`aaa.bbb.ccc.ddd`
Info

NOTE: IPv6 addresses are not supported.

The formula used to compute the integer equivalent of an IP address is the following:

`(aaa * 2563) + (bbb * 2562) + (ccc * 256) + (ddd)`

So, the formula to compute this IP address is the following:

Inputaaabbbcccddd
X

aaa = floor(Input / (256 3 ))

remainderA = Input - aaa

bbb = floor(remainderA / (256 2 ))

remainderB = remainderA - bbb

ccc = floor(remainderB / 256)

remainderC = remainderB - ccc

ddd = remainderC

Output value:

`Output = aaa + '.' + bbb + '.' + ccc + '.' + ddd`

D s lang vs sql

D s
snippet Basic

Numeric literal example:

D lang syntax
RawWrangle true ref true derive type:single value: ipfromint('16909060') as:'ip_addr'

ipfromint('16909060')

Output: Returns the IP address `1.2.3.4`

Column reference example:

D lang syntax
RawWrangle true ref true derive type:single value: ipfromint(IpInt) as: 'ip_addr'

ipfromint(IpInt)

Output: Returns the values of the `IpInt` column converted to an IP address value.

D s
snippet Syntax

D lang syntax
RawWrangle true syntax true derive type:single value: ipfromint(column_int)

ipfromint(column_int)

ArgumentRequired?Data TypeDescription
column_intYstring or integerName of column or integer literal that is to be converted to an IP address value

D s lang notes

column_int

Name of the column or integer literal whose values are used to compute the equivalent IP address value.

• Missing input values generate missing results.
• Multiple columns and wildcards are not supported.

D s
snippet usage

Required?Data TypeExample Value
YesInteger literal or column reference`16909060`

D s
snippet Examples

Example - Convert IP addresses to integers

Include Page
 EXAMPLE - IPTOINT Function EXAMPLE - IPTOINT Function

D s also
label other