Re: [HACKERS] Re: inet/cidr/bind

Поиск
Список
Период
Сортировка
От darcy@druid.net (D'Arcy J.M. Cain)
Тема Re: [HACKERS] Re: inet/cidr/bind
Дата
Msg-id m0zTGnV-0000f3C@druid.net
обсуждение исходный текст
Ответ на Re: [HACKERS] Re: inet/cidr/bind  (Paul A Vixie <paul@vix.com>)
Ответы Re: [HACKERS] Re: inet/cidr/bind
Список pgsql-hackers
Thus spake Paul A Vixie
> > The network function will output it correctly, I think.
> >
> > inet_network_with_bits('192.5/16')     => '192.5/16'
> > inet_network_with_bits('192.5.5.1/16') => '192.5/16'
> > inet_network_with_bits('192.5/24')     => '192.5.0/16'
> >
> > Does this seem right?
>
> for networks, yes.

Hmm.  It _is_ the network function I was talking about.  The same inputs
whould give the following results.

Input           Network (with)   Network (without)   Host         Broadcast
192.5/16        192.5/16         192.5               192.5.0.0    192.5.255.255
192.5.5.1/16    192.5/16         192.5               192.5.0.0    192.5.255.255
192.5/24        192.5.0/16       192.5.0             192.5.0.0    192.5.0.255

Of course, you wouldn't expect the first and last to have the host function
applied to it.  They are probably in a field used to store networks.

> ok.  here's the current proposal.  any further comments?
>
> /*
>  * char *
>  * inet_cidr_ntop(af, src, bits, dst, size)
>  *      convert network address from network to presentation format.
>  *      generates "/CIDR" style result unless "bits" is -1.  "src"'s
>  *      size is determined from its "af".

And size is the available space in dst, right?  Perfect.

> /*
>  * int
>  * inet_cidr_pton(af, src, dst, *bits)
>  *      convert network address from presentation to network format.
>  *      accepts hex octets, hex strings, decimal octets, and /CIDR.
>  *      "dst" is assumed large enough for its "af".  "bits" is set to the
>  *      /CIDR prefix length if one was specified, or -1 otherwise.

This sounds bang-on to me.  How soon before your functions are in the
tree?  I'll start modifying my code based on this but I won't send it
in until I have tested it against your functions.

By George!  I think we've got it.  :-)

--
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 по дате отправления:

Предыдущее
От: "Thomas G. Lockhart"
Дата:
Сообщение: odbc installation broken
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] PostgreSQL v6.4 BETA2 ...