Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] CIDR type and functions

From: Tom Ivar Helbekkmo <tih(at)nhh(dot)no>
To: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
Cc: maillist(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian), pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] CIDR type and functions
Date: 1998-10-10 11:57:54
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
D'Arcy J.M. Cain:

>     netmask('') ==
>     masklen('') == 24
>     host('') ==
>     network('') ==
>     broadcast('') ==
> and perhaps;
>     class('') == C
>     classnet('') == 192.3.4

Bruce Momjian:

> Yes, we need those.  Code them up, and I will add them as standard
> types.

This is really all contrary to the concept of CIDR notation.  While I
did end up calling the type INET instead of CIDR (which seemed to be
the consensus when the discussion was going on, because INET would be
more intuitively understandable by users than CIDR), I still stuck to
the behavior that Paul Vixie wanted: CIDR notation and representation.
It seemed to me that this was a good compromise, as it gives us a
clean, standards-based notation where host addresses are a functioning
special case.  However, networks, netmasks, broadcast addresses and
interface addresses all need to be stored in separate INET values.

If what we actually want is what D'Arcy shows above, then we should
drop CIDR notation, stop using Paul Vixie's functions for dealing with
the same, and change the storage format to include more information,
and a different and more flexible input format.  Just off the top of
my head, 'inet netmask 0xffffff00 broadcast'
would be a cool input (and output) format to support.  :-)

D'Arcy J.M. Cain:

> OK, I started but I could use a small change to inet_net_ntop.c [...]

I have to side with Paul on this one: that file and its companion with
the similar name were pulled in from the BIND distribution simply for
convenience, so we wouldn't have to insist that people must install
BIND from source to be able to install PostgreSQL.  We really, really
shouldn't change them.  If what we want is not what they implement, we
should drop them and implement what we want.

My vote (surprise! surprise!) goes toward keeping what we've got right
now.  As Paul says, there's an RFC describing the behavior of the data
type as it now stands, and it's not as if it were difficult to do all
the other things one might want to do with it.

However, adding utility functions to do some of the things D'Arcy
suggests sounds good.  I would think that they should be defined to
take INET parameters and return INET results, and the most useful ones
seem to me to be the following three (shown with various inputs):

netmask('158.37.96')		==> ''
netmask('158.37.96/21')		==> ''
broadcast('158.37')		==> ''
broadcast('158.37.96')		==> ''
broadcast('158.37.96/21')	==> ''
network('')		==> '158.37/16'

Note that the last one has to assume the old class A/B/C/D/E stuff.

Popularity is the hallmark of mediocrity.  --Niles Crane, "Frasier"

In response to


pgsql-hackers by date

Next:From: Tom Ivar HelbekkmoDate: 1998-10-10 12:12:40
Subject: Re: [HACKERS] Open 6.4 items
Previous:From: Tom Ivar HelbekkmoDate: 1998-10-10 10:28:19
Subject: Re: [HACKERS] Open 6.4 items

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group