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

From: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
To: paul(at)vix(dot)com (Paul A Vixie)
Cc: pgsql-hackers(at)hub(dot)org
Subject: Re: [HACKERS] Re: inet/cidr/bind
Date: 1998-10-14 02:36:21
Message-ID: m0zTGnV-0000f3C@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at){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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-10-14 02:43:43 Re: [HACKERS] PostgreSQL v6.4 BETA2 ...
Previous Message Thomas G. Lockhart 1998-10-14 02:24:25 odbc installation broken