Re: [HACKERS] cidr - Mailing list pgsql-hackers

From Paul A Vixie
Subject Re: [HACKERS] cidr
Date
Msg-id 199807240730.AAA18087@bb.rc.vix.com
Whole thread Raw
In response to Re: [HACKERS] cidr  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] cidr
List pgsql-hackers
> OK, let me explain what I think Paul was saying.  cidr is used for
> networks.  You can use it for hosts by specifying /32.  It is not the
> same as a netmask.  For example:
>
>     host    192.24.45.32
>
> Now, this is a host address.  We can say its netmask is 255.255.255.0,
> or was can say it is part of network 192.24.45/24, which would allow you
> compute the netmask as 255.255.255.0.  The problem is that you need the
> type to support cidr, hosts, and netmasks.

in that case "hosts" and "netmasks" are completely unrelated to "cidr"'s
and no design should try to cover all three similar-sounding-but-different
needs.

> My idea is to internally store the new type as 8 bytes:
>
>     ____ ____ ____ ____ ____ ___ ___ ____
>     cidr addr  x  .  x .  x .  x ip6 ip6
>     bits len
>
> That way, if they specify cidr bits, we store it.  If they don't we make
> the bits field equal -1, and print/sort appropriately.  The addr len is
> usually 3, but ip6 is also easy to add by making the addr len equal 6.

ouch!

the cidr i posted has an address family.  there was a reason for that.

pgsql-hackers by date:

Previous
From: Brandon Ibach
Date:
Subject: CIDR type
Next
From: darcy@druid.net (D'Arcy J.M. Cain)
Date:
Subject: Re: [HACKERS] cidr