On Thu, Jul 28, 2016 at 11:33 AM, Peter Neorr <
peter...@gmail.com> wrote:
> Hello All,
>
> One of my project's current challenges is querying for IP Blocks that
> contain a given IP address.
>
> Here's an example use case:
>
31.187.93.96/28 is an IP block reserved for Antarctica. I want to use
> Stardog to help me determine that an event with an :ipAddress of
> "31.187.93.100" is related to Antarctica.
>
> We've done some processing (outside of Star Dog) so that each individual of
> type :IPBlock has a :minIPAddressAsLong and :maxIPAddressAsLong.
> For my example use case, The min address is 31.187.93.96 and max address is
> 31.187.93.111 (As long integers, 532372832 and 532372847 respectively)
>
> Is there a clever way to use SPARQL to convert "31.187.93.100" to it's long
> representation of 532372836? This would make it easy for me to just use
> simple greater-than/less-than filters to find matching IPBlocks.
>
> If the IP address is aaa.bbb.ccc.ddd, then it's long integer value should be
> (aaa*256^3) + (bbb*256^2) + (ccc*256^1) + (ddd*256^0).
>
> The algorithm is simple, but the string manipulation and arithmetic are
> beyond my current sparql abilities
>
> I've been considering writing my own set stardog functions in java to make
> this easier. E.g.
> isInIPRange("31.187.93.100","
31.187.93.96/28")
>
> But if I can do this with "pure" sparql, I'd like to try that first.