Skip site navigation (1) Skip section navigation (2)

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

From: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
To: tih(at)nhh(dot)no (Tom Ivar Helbekkmo)
Cc: paul(at)vix(dot)com (Paul A Vixie), pgsql-hackers(at)hub(dot)org
Subject: Re: [HACKERS] Re: inet/cidr/bind
Date: 1998-10-11 19:24:12
Message-ID: m0zSR6D-0000emC@druid.net (view raw or flat)
Thread:
Lists: pgsql-hackers
Thus spake Tom Ivar Helbekkmo
> > if this is agreeable, i'll code it up and submit it here for testing
> > before i push it out in bind 8.1.3.  i really do agree with the
> > functionality we've drifted toward in this type -- if folks want to
> > express the netmask of a host address without getting in trouble for
> > a nonzero host part that's lost during parsing and storage, then
> > they jolly well ought to be able to do that.

OK, I have cobbled up some functions and modified others in inet.c
based on the suggested cidr utility functions.  I have made a few
assumptions which I am sure we will have to look at so that everyone
is comfortable with the code.  I have added the following new functions.

char       *inet_netmask(inet * addr);
int4        inet_masklen(inet * addr);
char       *inet_host(inet * addr);
char       *inet_network_no_bits(inet * addr);
char       *inet_network_and_bits(inet * addr);
char       *inet_broadcast(inet * addr);

The difference between inet_network_no_bits and inet_network_and_bits is
that for a.b.c.d/24, the former will return a.b.c and the latter will
return a.b.c/24.  I couldn't use inet_network as a name anyway since
it conflicts with something in arpa/inet.h (On NetBSD -current).

If someone will add the necessary entries to the catalogues, I'll
start testing them.  I'll post the changes to inet.c and builtins.h
to the patches list.  I can't guarantee that they are bug-free yet
but it does compile and shouldn't interfere with anything anyone
else is doing.

-- 
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

pgsql-hackers by date

Next:From: Frank RidderbuschDate: 1998-10-11 19:52:54
Subject: Minor problem with Solaris 2.7beta
Previous:From: WayneDate: 1998-10-11 18:00:59
Subject: GIST

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group