[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: IP callculation library (ipcalc)
- From: Rob Kendrick <rjek@...>
- Date: Mon, 22 Nov 2010 22:06:26 +0000
On Mon, Nov 22, 2010 at 10:53:47PM +0100, Marcin Jurczuk wrote:
> I'm writing some auth plugin that will have to check if given
> remote-ip belongs to specific network.
> Is there some tool that have similar functions to ipcalc tool ?
> Something similar to:
> =check_ip("10.10.10.1","10.10.10.0/24")
> true
> =check_ip("192.168.1.10","192.168.2.0/24")
> false
>
> Otherwise I have to write my own using bitlib module ..
I've written a small module that uses Mike Pall's bit library and
Roberto's LPEG to parse IP addresses and expressions. It can cope with
things like:
10.19.3.10
10.19.3.0/25
10.19.3.0-127
10.19.3.0/255.255.255.128
etc, parsing them into a single value which can then be easily converted
to other notations, or used to see if another address is within the
range specified.
It is as yet unfinished; anybody wanting a copy contact should me off list.
B.