teraslice icon indicating copy to clipboard operation
teraslice copied to clipboard

data-mate ip functions discussion

Open ciorg opened this issue 3 years ago • 1 comments

current functions:

  • isIP
  • isRoutableIP
  • isNonRoutableIP
  • inIPRange
  • isCIDR

new functions:

  • reverseIP

ciorg avatar Apr 30 '21 20:04 ciorg

other ip functions to consider:

from presto:

ip_prefix(ip_address, prefix_bits) → ipprefix#
Returns the IP prefix of a given ip_address with subnet size of prefix_bits. ip_address can be either of type VARCHAR or type IPADDRESS.

SELECT ip_prefix(CAST('192.168.255.255' AS IPADDRESS), 9); -- {192.128.0.0/9}
SELECT ip_prefix('2001:0db8:85a3:0001:0001:8a2e:0370:7334', 48); -- {2001:db8:85a3::/48}
ip_subnet_range(ip_prefix)#
Return an array of 2 IP addresses. The array contains the smallest and the largest IP address in the subnet specified by ip_prefix.

SELECT ip_subnet_range(IPPREFIX '1.2.3.160/24'); -- [{1.2.3.0}, {1.2.3.255}]
SELECT ip_subnet_range(IPPREFIX '64:ff9b::52f4/120'); -- [{64:ff9b::5200}, {64:ff9b::52ff}]

functions from ipaddr.js a module that we already use

  • fromByteArray
  • toByteArray
  • rangeName -> unicast, linkLocal, reserved, loopback ...etc

ipv4 specific

  • toIPv4MappedAddress -> ipv6 mapped ipv4
  • broadcastAddressFromCIDR
  • networkAddressFromCIDR

ipv6 specific

  • isIPv4MappedAddress
  • toIPv4Address
  • zoneId

other:

  • ip to integer?, 70.176.201.23 -> 1185990935
  • to binary? 70.176.201.23 -> 1000110101100001100100100010111
  • to hex?70.176.201.23 -> 0x46b0c917

ciorg avatar May 03 '21 22:05 ciorg

I believe we have reasonable coverage on these now.

kstaken avatar Oct 07 '24 19:10 kstaken