numerical-string->ipaddr

Synopsis

(numerical-string->ipaddr string)

Parameters

  • string : A string containing a numerical representation of an IP address

Description

This procedure converts a numerical representation of an IP address as found in various IP address databases to an IP address as a data type. This procedure does not rely on 128 bit integer arithmetic and therefore functions identical on 32 bit systems.

Side Effects

Return Value

The IP address is returned, an IP address of all zeroes may indicate a conversion error (external representation “::").

Example

> (numerical-string->ipaddr "281470698550784")
1.0.118.0
> (numerical-string->ipaddr "281470681743360")
0.0.0.0
> (numerical-string->ipaddr "281470698520575")
0.255.255.255
> (numerical-string->ipaddr "281470698520576")
1.0.0.0
> (numerical-string->ipaddr "281470698520831")
1.0.0.255
> (numerical-string->ipaddr "58569107296622255421594597096899477504")
2c0f:fff0::
> (numerical-string->ipaddr "58569107375850417935858934690443427839")
2c0f:fff0:ffff:ffff:ffff:ffff:ffff:ffff
> ipaddr-range
#<primitive-procedure ipaddr-range>
> (ipaddr-range
(numerical-string->ipaddr "58569107296622255421594597096899477504")
(numerical-string->ipaddr "58569107375850417935858934690443427839"))
2c0f:fff0::-2c0f:fff0:ffff:ffff:ffff:ffff:ffff:ffff
> (numerical-string->ipaddr "hello")
::
>