Re: [HACKERS] CIDR type and functions - Mailing list pgsql-hackers

From darcy@druid.net (D'Arcy J.M. Cain)
Subject Re: [HACKERS] CIDR type and functions
Date
Msg-id m0zRh5F-0000exC@druid.net
Whole thread Raw
In response to Re: [HACKERS] CIDR type and functions  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] CIDR type and functions  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Thus spake Bruce Momjian
> Check \df and \fo.  There is a >> and << operators that do subnet
> testing.

[I assume you meant \do]

Cool.  I checked out what other functions as well.  I don't see a couple
that were discussed early on though.  Specifically, how about functions
to extract the  host, the network or the netmask from an address?

Here are the functions I had suggested.

    netmask('192.3.4.5/24::cidr') == 255.255.255.0
    masklen('192.3.4.5/24::cidr') == 24
    host('192.3.4.5/24::cidr') == 192.3.4.5
    network('192.3.4.5/24::cidr') == 192.3.4.0

and perhaps;

    class('192.3.4.5/24::cidr') == C
    classnet('192.3.4.5/24::cidr') == 192.3.4

Can I help code up some of this stuff?

--
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] dynamic libraries
Next
From: Peter T Mount
Date:
Subject: Re: [HACKERS] dynamic libraries