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

Поиск
Список
Период
Сортировка
От darcy@druid.net (D'Arcy J.M. Cain)
Тема Re: [HACKERS] Re: inet/cidr/bind
Дата
Msg-id m0zSR6D-0000emC@druid.net
обсуждение исходный текст
Ответ на Re: [HACKERS] Re: inet/cidr/bind  (Tom Ivar Helbekkmo <tih@nhh.no>)
Список 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@{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 по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Re: inet/cidr/bind
Следующее
От: Massimo Dal Zotto
Дата:
Сообщение: Re: [HACKERS] TCL_ARRAYS code in libpgtcl is pretty seriously broken