Thread: plPgSQL + CDIR/INET types ...

plPgSQL + CDIR/INET types ...

From
"Marc G. Fournier"
Date:
Has anyone either played with, or gotten to work, a plPgSQL function that
would take:  192.168.1.1/24 and determine the start and end IP from that?
Or even start IP + # of IPs in the subnet?

----
Marc G. Fournier                        Hub.Org Hosting Solutions S.A.
scrappy@hub.org                                     http://www.hub.org

Yahoo:yscrappy    Skype: hub.org    ICQ:7615664    MSN:scrappy@hub.org

Re: plPgSQL + CDIR/INET types ...

From
Steve Atkins
Date:
On Mar 30, 2010, at 7:09 PM, Marc G. Fournier wrote:

>
> Has anyone either played with, or gotten to work, a plPgSQL function that would take:  192.168.1.1/24 and determine
thestart and end IP from that? Or even start IP + # of IPs in the subnet? 

If that was a valid cidr value (like 192.168.1.0/24) you could just use host() or broadcast() to get the first and last
addresses(and subtraction to get the size of the subnet). 

You could probably convert it to the equivalent cidr range with some combo of set_masklen() and masklen().

Cheers,
  Steve




Re: plPgSQL + CDIR/INET types ...

From
Harald Fuchs
Date:
In article <alpine.BSF.2.00.1003302306490.97069@hub.org>,
"Marc G. Fournier" <scrappy@hub.org> writes:

> Has anyone either played with, or gotten to work, a plPgSQL function
> that would take:  192.168.1.1/24 and determine the start and end IP
> from that? Or even start IP + # of IPs in the subnet?

Just install ip4r from pgfoundry, and you'll never look back at the old
cidr/inet types.