Commit 6c7e6809 authored by Mark Andrews's avatar Mark Andrews
Browse files

115. [cleanup] libdns.a changes:

                        dns_zone_clearnotify() and dns_zone_addnotify()
                        are replaced by dns_zone_setnotifyalso().
                        dns_zone_clearmasters() and dns_zone_addmaster()
                        are replaced by dns_zone_setmasters().
parent 495c00c1
117. [cleanup] libdns.a changes:
dns_zone_clearnotify() and dns_zone_addnotify()
are replaced by dns_zone_setnotifyalso().
dns_zone_clearmasters() and dns_zone_addmaster()
are replaced by dns_zone_setmasters().
116. [func] Added <isc/offset.h> for isc_offset_t (aka off_t
on Unix systems).
......
......@@ -103,7 +103,6 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
dns_c_severity_t severity;
#endif
dns_c_iplist_t *iplist = NULL;
isc_uint32_t i;
isc_sockaddr_t sockaddr;
isc_int32_t maxxfr;
in_port_t port;
......@@ -185,16 +184,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
boolean = ISC_TRUE;
dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, boolean);
dns_zone_clearnotify(zone);
result = dns_c_zone_getalsonotify(czone, &iplist);
if (result == ISC_R_SUCCESS) {
for (i = 0; i < iplist->nextidx; i++) {
result = dns_zone_addnotify(zone,
&iplist->ips[i]);
if (result != ISC_R_SUCCESS)
return (result);
}
}
if (result == ISC_R_SUCCESS)
result = dns_zone_setnotifyalso(zone, iplist->ips,
iplist->nextidx);
else
result = dns_zone_setnotifyalso(zone, NULL, 0);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_c_zone_getmaxtranstimeout(czone, &maxxfr);
if (result != ISC_R_SUCCESS && cview != NULL)
......@@ -264,16 +261,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
port = 53;
dns_zone_setmasterport(zone, port);
dns_zone_clearmasters(zone);
result = dns_c_zone_getmasterips(czone, &iplist);
if (result == ISC_R_SUCCESS) {
for (i = 0; i < iplist->nextidx; i++) {
result = dns_zone_addmaster(zone,
&iplist->ips[i]);
if (result != ISC_R_SUCCESS)
return (result);
}
}
if (result == ISC_R_SUCCESS)
result = dns_zone_setmasters(zone, iplist->ips,
iplist->nextidx);
else
result = dns_zone_setmasters(zone, NULL, 0);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_c_zone_getmaxtranstimein(czone, &maxxfr);
if (result != ISC_R_SUCCESS)
......@@ -345,16 +340,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
boolean = ISC_TRUE;
dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, boolean);
dns_zone_clearnotify(zone);
result = dns_c_zone_getalsonotify(czone, &iplist);
if (result == ISC_R_SUCCESS) {
for (i = 0; i < iplist->nextidx; i++) {
result = dns_zone_addnotify(zone,
&iplist->ips[i]);
if (result != ISC_R_SUCCESS)
return (result);
}
}
if (result == ISC_R_SUCCESS)
result = dns_zone_setnotifyalso(zone, iplist->ips,
iplist->nextidx);
else
result = dns_zone_setnotifyalso(zone, NULL, 0);
if (result != ISC_R_SUCCESS)
return (result);
break;
......@@ -387,16 +380,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
port = 53;
dns_zone_setmasterport(zone, port);
dns_zone_clearmasters(zone);
result = dns_c_zone_getmasterips(czone, &iplist);
if (result == ISC_R_SUCCESS) {
for (i = 0; i < iplist->nextidx; i++) {
result = dns_zone_addmaster(zone,
&iplist->ips[i]);
if (result != ISC_R_SUCCESS)
return (result);
}
}
if (result == ISC_R_SUCCESS)
result = dns_zone_setmasters(zone, iplist->ips,
iplist->nextidx);
else
result = dns_zone_setmasters(zone, NULL, 0);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_c_zone_getmaxtranstimein(czone, &maxxfr);
if (result != ISC_R_SUCCESS)
......
......@@ -362,38 +362,26 @@ void dns_zone_maintenance(dns_zone_t *zone);
* 'zone' to be a valid initalised zone.
*/
void dns_zone_clearmasters(dns_zone_t *zone);
/*
* Clear the set of master servers the zone transfers from.
*
* Require
* 'zone' to be a valid initalised zone.
*/
isc_result_t dns_zone_addmaster(dns_zone_t *zone, isc_sockaddr_t *master);
isc_result_t dns_zone_setmasters(dns_zone_t *zone, isc_sockaddr_t *masters,
isc_uint32_t count);
/*
* Add a master server to the end of the set of master servers for
* the zone.
*
* Require:
* 'zone' to be a valid initalised zone.
* 'master' to be non NULL.
* 'masters' array of isc_sockaddr_t with port set or NULL.
* 'count' the number of masters.
*
* If 'masters' is NULL then 'count' must be zero.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_NOMEMORY
*/
void dns_zone_clearnotify(dns_zone_t *zone);
/*
* Clear the set of additional servers to be notified when the zone
* changes.
*
* Require:
* 'zone' to be a valid initalised zone.
*/
isc_result_t dns_zone_addnotify(dns_zone_t *zone, isc_sockaddr_t *notify);
isc_result_t dns_zone_setnotifyalso(dns_zone_t *zone, isc_sockaddr_t *notify,
isc_uint32_t count);
/*
* Add a server to the end of the list of additional servers to be
* notified when a zone changes.
......@@ -401,6 +389,9 @@ isc_result_t dns_zone_addnotify(dns_zone_t *zone, isc_sockaddr_t *notify);
* Require:
* 'zone' to be a valid initalised zone.
* 'notify' to be non NULL.
* 'count' the number of notify.
*
* If 'notify' is NULL then 'count' must be zero.
*
* Returns:
* ISC_R_SUCCESS
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: zone.c,v 1.102 2000/04/27 00:02:09 tale Exp $ */
/* $Id: zone.c,v 1.103 2000/04/28 00:58:40 marka Exp $ */
#include <config.h>
......@@ -135,9 +135,9 @@ struct dns_zone {
dns_zonetype_t type;
unsigned int flags;
unsigned int options;
char * db_type;
char *db_type;
unsigned int db_argc;
char ** db_argv;
char **db_argv;
isc_stdtime_t expiretime;
isc_stdtime_t refreshtime;
isc_stdtime_t dumptime;
......@@ -150,18 +150,18 @@ struct dns_zone {
isc_uint32_t retry;
isc_uint32_t expire;
isc_uint32_t minimum;
isc_sockaddr_t * masters;
isc_sockaddr_t *masters;
unsigned int masterscnt;
in_port_t masterport;
unsigned int curmaster;
isc_sockaddr_t masteraddr;
isc_sockaddr_t * notify;
isc_sockaddr_t *notify;
unsigned int notifycnt;
isc_sockaddr_t notifyfrom;
isc_task_t * task;
isc_task_t *task;
isc_sockaddr_t xfrsource4;
isc_sockaddr_t xfrsource6;
dns_xfrin_ctx_t * xfr;
dns_xfrin_ctx_t *xfr;
/* Access Control Lists */
dns_acl_t *update_acl;
dns_acl_t *query_acl;
......@@ -200,6 +200,8 @@ struct dns_zone {
* uptodate */
#define DNS_ZONE_F_NEEDNOTIFY 0x00000400U /* need to send out notify
* messages */
#define DNS_ZONE_F_DIFFONRELOAD 0x00000800U /* generate a journal diff on
* reload */
#define DNS_ZONE_OPTION(z,o) (((z)->options & (o)) != 0)
......@@ -442,9 +444,9 @@ zone_free(dns_zone_t *zone) {
if (zone->db != NULL)
dns_db_detach(&zone->db);
dns_zone_cleardbargs(zone);
dns_zone_clearmasters(zone);
dns_zone_setmasters(zone, NULL, 0);
zone->masterport = 0;
dns_zone_clearnotify(zone);
dns_zone_setnotifyalso(zone, NULL, 0);
zone->check_names = dns_severity_ignore;
if (zone->update_acl != NULL)
dns_acl_detach(&zone->update_acl);
......@@ -1612,84 +1614,65 @@ dns_zone_getxfrsource6(dns_zone_t *zone) {
}
isc_result_t
dns_zone_addnotify(dns_zone_t *zone, isc_sockaddr_t *notify) {
dns_zone_setnotifyalso(dns_zone_t *zone, isc_sockaddr_t *notify,
isc_uint32_t count)
{
isc_sockaddr_t *new;
REQUIRE(DNS_ZONE_VALID(zone));
LOCK(&zone->lock);
new = isc_mem_get(zone->mctx, (zone->notifycnt + 1) * sizeof *new);
if (new == NULL)
goto cleanup;
new[zone->notifycnt] = *notify;
if (zone->notifycnt > 0) {
memcpy(new, zone->notify, zone->notifycnt * sizeof *new);
isc_mem_put(zone->mctx, zone->notify,
zone->notifycnt * sizeof *new);
}
zone->notify = new;
zone->notifycnt++;
UNLOCK(&zone->lock);
return (ISC_R_SUCCESS);
cleanup:
UNLOCK(&zone->lock);
return (ISC_R_NOMEMORY);
}
void
dns_zone_clearnotify(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE((notify == NULL) ^ (count != 0));
LOCK(&zone->lock);
if (zone->notify != NULL) {
isc_mem_put(zone->mctx, zone->notify,
zone->notifycnt * sizeof *zone->notify);
zone->notify = NULL;
zone->notifycnt * sizeof *new);
zone->notifycnt = 0;
}
UNLOCK(&zone->lock);
}
if (notify == NULL)
goto unlock;
isc_result_t
dns_zone_addmaster(dns_zone_t *zone, isc_sockaddr_t *master) {
isc_sockaddr_t *new;
REQUIRE(DNS_ZONE_VALID(zone));
LOCK(&zone->lock);
new = isc_mem_get(zone->mctx, (zone->masterscnt + 1) * sizeof *new);
new = isc_mem_get(zone->mctx, count * sizeof *new);
if (new == NULL) {
UNLOCK(&zone->lock);
return (ISC_R_NOMEMORY);
}
new[zone->masterscnt] = *master;
if (zone->masterscnt > 0) {
memcpy(new, zone->masters, zone->masterscnt * sizeof *new);
isc_mem_put(zone->mctx, zone->masters,
zone->masterscnt * sizeof *new);
}
zone->masters = new;
zone->masterscnt++;
memcpy(new, notify, count * sizeof *new);
zone->notify = new;
zone->notifycnt = count;
unlock:
UNLOCK(&zone->lock);
return (ISC_R_SUCCESS);
}
void
dns_zone_clearmasters(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
isc_result_t
dns_zone_setmasters(dns_zone_t *zone, isc_sockaddr_t *masters,
isc_uint32_t count)
{
isc_sockaddr_t *new;
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE((masters == NULL) ^ (count != 0));
LOCK(&zone->lock);
while (DNS_ZONE_FLAG(zone, DNS_ZONE_F_REFRESH)) {
cancel_refresh(zone);
}
if (zone->masters != NULL) {
isc_mem_put(zone->mctx, zone->masters,
zone->masterscnt * sizeof *zone->masters);
zone->masters = NULL;
zone->masterscnt * sizeof *new);
zone->masterscnt = 0;
zone->curmaster = 0;
}
if (masters == NULL)
goto unlock;
new = isc_mem_get(zone->mctx, count * sizeof *new);
if (new == NULL) {
UNLOCK(&zone->lock);
return (ISC_R_NOMEMORY);
}
memcpy(new, masters, count * sizeof *new);
zone->masters = new;
zone->masterscnt = count;
unlock:
UNLOCK(&zone->lock);
return (ISC_R_SUCCESS);
}
isc_result_t
......
......@@ -103,7 +103,6 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
dns_c_severity_t severity;
#endif
dns_c_iplist_t *iplist = NULL;
isc_uint32_t i;
isc_sockaddr_t sockaddr;
isc_int32_t maxxfr;
in_port_t port;
......@@ -185,16 +184,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
boolean = ISC_TRUE;
dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, boolean);
dns_zone_clearnotify(zone);
result = dns_c_zone_getalsonotify(czone, &iplist);
if (result == ISC_R_SUCCESS) {
for (i = 0; i < iplist->nextidx; i++) {
result = dns_zone_addnotify(zone,
&iplist->ips[i]);
if (result != ISC_R_SUCCESS)
return (result);
}
}
if (result == ISC_R_SUCCESS)
result = dns_zone_setnotifyalso(zone, iplist->ips,
iplist->nextidx);
else
result = dns_zone_setnotifyalso(zone, NULL, 0);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_c_zone_getmaxtranstimeout(czone, &maxxfr);
if (result != ISC_R_SUCCESS && cview != NULL)
......@@ -264,16 +261,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
port = 53;
dns_zone_setmasterport(zone, port);
dns_zone_clearmasters(zone);
result = dns_c_zone_getmasterips(czone, &iplist);
if (result == ISC_R_SUCCESS) {
for (i = 0; i < iplist->nextidx; i++) {
result = dns_zone_addmaster(zone,
&iplist->ips[i]);
if (result != ISC_R_SUCCESS)
return (result);
}
}
if (result == ISC_R_SUCCESS)
result = dns_zone_setmasters(zone, iplist->ips,
iplist->nextidx);
else
result = dns_zone_setmasters(zone, NULL, 0);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_c_zone_getmaxtranstimein(czone, &maxxfr);
if (result != ISC_R_SUCCESS)
......@@ -345,16 +340,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
boolean = ISC_TRUE;
dns_zone_setoption(zone, DNS_ZONE_O_NOTIFY, boolean);
dns_zone_clearnotify(zone);
result = dns_c_zone_getalsonotify(czone, &iplist);
if (result == ISC_R_SUCCESS) {
for (i = 0; i < iplist->nextidx; i++) {
result = dns_zone_addnotify(zone,
&iplist->ips[i]);
if (result != ISC_R_SUCCESS)
return (result);
}
}
if (result == ISC_R_SUCCESS)
result = dns_zone_setnotifyalso(zone, iplist->ips,
iplist->nextidx);
else
result = dns_zone_setnotifyalso(zone, NULL, 0);
if (result != ISC_R_SUCCESS)
return (result);
break;
......@@ -387,16 +380,14 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
port = 53;
dns_zone_setmasterport(zone, port);
dns_zone_clearmasters(zone);
result = dns_c_zone_getmasterips(czone, &iplist);
if (result == ISC_R_SUCCESS) {
for (i = 0; i < iplist->nextidx; i++) {
result = dns_zone_addmaster(zone,
&iplist->ips[i]);
if (result != ISC_R_SUCCESS)
return (result);
}
}
if (result == ISC_R_SUCCESS)
result = dns_zone_setmasters(zone, iplist->ips,
iplist->nextidx);
else
result = dns_zone_setmasters(zone, NULL, 0);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_c_zone_getmaxtranstimein(czone, &maxxfr);
if (result != ISC_R_SUCCESS)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment