Learn R Programming

Rip46 (version 1.0.2)

mySqlToIp4: Convert MySQL ATONs to Rip4

Description

When you query a MySQL db, you should use INET_ATON(ip_field) to convert a string IP to an (unsigned) int.

Usage

mySqlToIp4(x)

Arguments

x
input numeric vector

Value

integer format IP addresses

Details

Unfortunately, the RMySQL driver will convert these to doubles because not all unsigned ints are representable as ints. Because doubles get normalized, we can't mask subnets directly.

Instead, we can map the top half of unsigned integers to the negative half of signed ints using 2s-complement.