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

From darcy@druid.net (D'Arcy J.M. Cain)
Subject Re: [HACKERS] cidr
Date
Msg-id m0yyosB-00006FC@druid.net
Whole thread Raw
In response to Re: [HACKERS] cidr  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] cidr
List pgsql-hackers
Thus spake Bruce Momjian
> I think we have to be able to store both old-style and cidr-style
> addresses for several reasons:

I must be missing something.  Can you suggest a classfull network
designation that doesn't fit into the CIDR system?  For example,
what's the difference between the following networks?

  Class "A" network 10
  10.0.0.0 mask 255.0.0.0
  10.0.0.0/8

Don't they all refer to exactly the same thing?  If you subnet that
network into 256 equal subnets you might have this instead.

  Class "B" network 10.42
  10.42.0.0 mask 255.255.0.0
  10.42.0.0/16

Now that first one is an invalid designation in the old classfull system
so it doesn't matter if you can specify it.  Under CIDR, however, that
subnet is perfectly valid (except that that particular range won't route
on the Internet) and the designations work.  So why not store the old
classfull networks in the cidr type?  They fit just fine.

>     we have current users of ip_and_mac

I don't know enough about this type but other than a different name, how
can expanding the range of allowable values limit them?

>     some people don't use cidr yet

Name one.  They may not know what it is called but very little software
or hardware still supports classes.  Do Macs still force the distinction?
In any case, class networks fit in CIDR.

>     we need to be able to store netmasks too, which aren't cidr

Now this is an issue but it is the same issue as hosts.  Netmasks
can also be designated as /32.  However, if all you want to store
is the netmask, just use int.  The range is 0 to 32.

> So a generic INET type is clearer, and will support both address types.

I have no particular problem with calling it INET instead of CIDR if
that gets the type into the system but let's be clear that either way,
any host and netmask combination can be stored whether it fits in
the old class system or not.

Perhaps there is an underlying difference of assumptions about what
the actual type is.  Let me take a stab at defining it (without
naming it) and see if we're all on the same bus.

I see the underlying data type storing two things, a host address
(which can hold an IPv4 or IPv6 IP) and a netmask which can be
stored as a small int, 8 bits is plenty.  The input function would
read IP numbers as follows (I'm making some of this up as I go.)

  x.x.x.x/y             IP x.x.x.x with masklen y
  x.x.x.x:y.y.y.y       IP x.x.x.x with masklen determined by examining
                        y.y.y.y raising an exception if it is an invalid
                        mask (defined as all ones followed by all zeroes)
  x.x.x.x               IP x.x.x.x masklen of 32

The output functions would print in a standard way, possibly allowing
alternate representations like we do for money.  Also, there would
be functions to extract the host, the network or the netmask.

Is this close to what everyone thinks or are we talking about completely
different things?

--
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] cidr
Next
From: Hal Snyder
Date:
Subject: Re: [HACKERS] cidr