Re: [HACKERS] cidr

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] cidr
Дата
Msg-id 199807210530.BAA22477@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] cidr  (Paul A Vixie <vixie@vix.com>)
Список pgsql-hackers
> > My guess is that it is going to output x.x.x.x/32, but we should supply
> > a function so they can get just the IP or the mask from the type.  That
> > way, people who don't want the cidr format can pull out the part they
> > want.
>
> this i don't understand.  why would you want only one part of it?  if you
> want to do address arithmetic then you need specific OR and AND and NOT
> functions -- like making a broadcast address if all you know is your address
> and netmask.  but why would you want to know the mantissa without the scale?

I guess I thought someone might want to have ipaddr() and netmask()
functions so they can do:

    x = 192.7.34.21/24
    ipaddr(x)  -> 192.7.34.21
    netmask(x) -> 255.255.255.0

    x = 192.7.0.0/16
    ipaddr(x)  -> 192.7.0.0
    netmask(x) -> 255.255.0.0

These function are defined on the cidr type, and can be called if
someone wants the old output format.

>
> > If they don't specify a netmask when they load the value, perhaps we use
> > the standard class A,B,C netmasks.  How you specify a HOST address using
> > the non-cidr format, I really don't know.  I am sure the experts will
> > hash it out before 6.4 beta on September 1.
>
> classful assumptions are out of fashion, outdated, and dangerous.  consider:
>
>     "16" -> "16/8" -> "16.0.0.0/8"
>     "128" -> "128/16" -> "128.0.0.0/16"
>     "192" -> "192/24" -> "192.0.0.0/24"
>
> not very helpful.  the implementation of "cidr" that i posted here yesterday
> uses the BIND-8 functions for representational conversion.  those functions
> assume that a text representation with no "/" given has as many bits as the
> number of octets they fully cover:
>
>     "16" -> "16/8"
>     "128" -> "128/8"
>     "192" -> "192/8"
>     "127.1" -> "127.1/16"


>
> this is how a Cisco router would interpret such routes if "ip classless" is
> enabled and static routes were being entered.  "ip classless" is a prereq-
> uisite for running OSPF, RIPv2, or BGP4.  in other words it's pervasive.
>
> BIND follows RFC 1884 in this regard, and deviates significantly from both
> classful assumptions and the old BSD standard, which would treat "127.1" as
> "127.0.0.1".  this burned on some old /etc/rc files but it was the right
> thing to do and now that the world has gotten over the scars, let's not run
> backwards.
>
> the IETF's CIDR project was long running, painful, and successful.

Yes, the 127.1 ambiguity was very strange.  netstat -rn is very hard to
understand using the old format.

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Thomas G. Lockhart"
Дата:
Сообщение: [Fwd: SGVLLUG Oracle and Informix on Linux]
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] cidr