mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
apply the modified style
This commit is contained in:
122
lib/dns/diff.c
122
lib/dns/diff.c
@@ -44,19 +44,17 @@
|
||||
dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_DIFF
|
||||
|
||||
static dns_rdatatype_t
|
||||
rdata_covers(dns_rdata_t *rdata)
|
||||
{
|
||||
rdata_covers(dns_rdata_t *rdata) {
|
||||
return (rdata->type == dns_rdatatype_rrsig ? dns_rdata_covers(rdata)
|
||||
: 0);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_difftuple_create(isc_mem_t *mctx, dns_diffop_t op, const dns_name_t *name,
|
||||
dns_ttl_t ttl, dns_rdata_t *rdata, dns_difftuple_t **tp)
|
||||
{
|
||||
dns_ttl_t ttl, dns_rdata_t *rdata, dns_difftuple_t **tp) {
|
||||
dns_difftuple_t *t;
|
||||
unsigned int size;
|
||||
unsigned char * datap;
|
||||
unsigned int size;
|
||||
unsigned char *datap;
|
||||
|
||||
REQUIRE(tp != NULL && *tp == NULL);
|
||||
|
||||
@@ -103,8 +101,7 @@ dns_difftuple_create(isc_mem_t *mctx, dns_diffop_t op, const dns_name_t *name,
|
||||
}
|
||||
|
||||
void
|
||||
dns_difftuple_free(dns_difftuple_t **tp)
|
||||
{
|
||||
dns_difftuple_free(dns_difftuple_t **tp) {
|
||||
dns_difftuple_t *t = *tp;
|
||||
*tp = NULL;
|
||||
isc_mem_t *mctx;
|
||||
@@ -119,23 +116,20 @@ dns_difftuple_free(dns_difftuple_t **tp)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_difftuple_copy(dns_difftuple_t *orig, dns_difftuple_t **copyp)
|
||||
{
|
||||
dns_difftuple_copy(dns_difftuple_t *orig, dns_difftuple_t **copyp) {
|
||||
return (dns_difftuple_create(orig->mctx, orig->op, &orig->name,
|
||||
orig->ttl, &orig->rdata, copyp));
|
||||
}
|
||||
|
||||
void
|
||||
dns_diff_init(isc_mem_t *mctx, dns_diff_t *diff)
|
||||
{
|
||||
dns_diff_init(isc_mem_t *mctx, dns_diff_t *diff) {
|
||||
diff->mctx = mctx;
|
||||
ISC_LIST_INIT(diff->tuples);
|
||||
diff->magic = DNS_DIFF_MAGIC;
|
||||
}
|
||||
|
||||
void
|
||||
dns_diff_clear(dns_diff_t *diff)
|
||||
{
|
||||
dns_diff_clear(dns_diff_t *diff) {
|
||||
dns_difftuple_t *t;
|
||||
REQUIRE(DNS_DIFF_VALID(diff));
|
||||
while ((t = ISC_LIST_HEAD(diff->tuples)) != NULL) {
|
||||
@@ -146,8 +140,7 @@ dns_diff_clear(dns_diff_t *diff)
|
||||
}
|
||||
|
||||
void
|
||||
dns_diff_append(dns_diff_t *diff, dns_difftuple_t **tuplep)
|
||||
{
|
||||
dns_diff_append(dns_diff_t *diff, dns_difftuple_t **tuplep) {
|
||||
ISC_LIST_APPEND(diff->tuples, *tuplep, link);
|
||||
*tuplep = NULL;
|
||||
}
|
||||
@@ -155,8 +148,7 @@ dns_diff_append(dns_diff_t *diff, dns_difftuple_t **tuplep)
|
||||
/* XXX this is O(N) */
|
||||
|
||||
void
|
||||
dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep)
|
||||
{
|
||||
dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep) {
|
||||
dns_difftuple_t *ot, *next_ot;
|
||||
|
||||
REQUIRE(DNS_DIFF_VALID(diff));
|
||||
@@ -178,7 +170,8 @@ dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep)
|
||||
next_ot = ISC_LIST_NEXT(ot, link);
|
||||
if (dns_name_caseequal(&ot->name, &(*tuplep)->name) &&
|
||||
dns_rdata_compare(&ot->rdata, &(*tuplep)->rdata) == 0 &&
|
||||
ot->ttl == (*tuplep)->ttl) {
|
||||
ot->ttl == (*tuplep)->ttl)
|
||||
{
|
||||
ISC_LIST_UNLINK(diff->tuples, ot, link);
|
||||
if ((*tuplep)->op == ot->op) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
@@ -198,12 +191,11 @@ dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep)
|
||||
}
|
||||
|
||||
static isc_stdtime_t
|
||||
setresign(dns_rdataset_t *modified)
|
||||
{
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
setresign(dns_rdataset_t *modified) {
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdata_rrsig_t sig;
|
||||
int64_t when;
|
||||
isc_result_t result;
|
||||
int64_t when;
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_rdataset_first(modified);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
@@ -235,30 +227,27 @@ setresign(dns_rdataset_t *modified)
|
||||
}
|
||||
|
||||
static void
|
||||
getownercase(dns_rdataset_t *rdataset, dns_name_t *name)
|
||||
{
|
||||
getownercase(dns_rdataset_t *rdataset, dns_name_t *name) {
|
||||
if (dns_rdataset_isassociated(rdataset)) {
|
||||
dns_rdataset_getownercase(rdataset, name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
setownercase(dns_rdataset_t *rdataset, const dns_name_t *name)
|
||||
{
|
||||
setownercase(dns_rdataset_t *rdataset, const dns_name_t *name) {
|
||||
if (dns_rdataset_isassociated(rdataset)) {
|
||||
dns_rdataset_setownercase(rdataset, name);
|
||||
}
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, bool warn)
|
||||
{
|
||||
diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, bool warn) {
|
||||
dns_difftuple_t *t;
|
||||
dns_dbnode_t * node = NULL;
|
||||
isc_result_t result;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
char typebuf[DNS_RDATATYPE_FORMATSIZE];
|
||||
char classbuf[DNS_RDATACLASS_FORMATSIZE];
|
||||
dns_dbnode_t *node = NULL;
|
||||
isc_result_t result;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
char typebuf[DNS_RDATATYPE_FORMATSIZE];
|
||||
char classbuf[DNS_RDATACLASS_FORMATSIZE];
|
||||
|
||||
REQUIRE(DNS_DIFF_VALID(diff));
|
||||
REQUIRE(DNS_DB_VALID(db));
|
||||
@@ -280,11 +269,11 @@ diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, bool warn)
|
||||
|
||||
while (t != NULL && dns_name_equal(&t->name, name)) {
|
||||
dns_rdatatype_t type, covers;
|
||||
dns_diffop_t op;
|
||||
dns_diffop_t op;
|
||||
dns_rdatalist_t rdl;
|
||||
dns_rdataset_t rds;
|
||||
dns_rdataset_t ardataset;
|
||||
unsigned int options;
|
||||
dns_rdataset_t rds;
|
||||
dns_rdataset_t ardataset;
|
||||
unsigned int options;
|
||||
|
||||
op = t->op;
|
||||
type = t->rdata.type;
|
||||
@@ -322,7 +311,8 @@ diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, bool warn)
|
||||
|
||||
while (t != NULL && dns_name_equal(&t->name, name) &&
|
||||
t->op == op && t->rdata.type == type &&
|
||||
rdata_covers(&t->rdata) == covers) {
|
||||
rdata_covers(&t->rdata) == covers)
|
||||
{
|
||||
/*
|
||||
* Remember the add name for
|
||||
* dns_rdataset_setownercase.
|
||||
@@ -387,7 +377,8 @@ diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, bool warn)
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (rds.type == dns_rdatatype_rrsig &&
|
||||
(op == DNS_DIFFOP_DELRESIGN ||
|
||||
op == DNS_DIFFOP_ADDRESIGN)) {
|
||||
op == DNS_DIFFOP_ADDRESIGN))
|
||||
{
|
||||
isc_stdtime_t resign;
|
||||
resign = setresign(&ardataset);
|
||||
dns_db_setsigningtime(db, &ardataset,
|
||||
@@ -464,14 +455,12 @@ failure:
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver)
|
||||
{
|
||||
dns_diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver) {
|
||||
return (diff_apply(diff, db, ver, true));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_diff_applysilently(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver)
|
||||
{
|
||||
dns_diff_applysilently(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver) {
|
||||
return (diff_apply(diff, db, ver, false));
|
||||
}
|
||||
|
||||
@@ -479,10 +468,9 @@ dns_diff_applysilently(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver)
|
||||
|
||||
isc_result_t
|
||||
dns_diff_load(dns_diff_t *diff, dns_addrdatasetfunc_t addfunc,
|
||||
void *add_private)
|
||||
{
|
||||
void *add_private) {
|
||||
dns_difftuple_t *t;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(DNS_DIFF_VALID(diff));
|
||||
|
||||
@@ -493,9 +481,9 @@ dns_diff_load(dns_diff_t *diff, dns_addrdatasetfunc_t addfunc,
|
||||
name = &t->name;
|
||||
while (t != NULL && dns_name_caseequal(&t->name, name)) {
|
||||
dns_rdatatype_t type, covers;
|
||||
dns_diffop_t op;
|
||||
dns_diffop_t op;
|
||||
dns_rdatalist_t rdl;
|
||||
dns_rdataset_t rds;
|
||||
dns_rdataset_t rds;
|
||||
|
||||
op = t->op;
|
||||
type = t->rdata.type;
|
||||
@@ -510,7 +498,8 @@ dns_diff_load(dns_diff_t *diff, dns_addrdatasetfunc_t addfunc,
|
||||
while (t != NULL &&
|
||||
dns_name_caseequal(&t->name, name) &&
|
||||
t->op == op && t->rdata.type == type &&
|
||||
rdata_covers(&t->rdata) == covers) {
|
||||
rdata_covers(&t->rdata) == covers)
|
||||
{
|
||||
ISC_LIST_APPEND(rdl.rdata, &t->rdata, link);
|
||||
t = ISC_LIST_NEXT(t, link);
|
||||
}
|
||||
@@ -549,12 +538,11 @@ failure:
|
||||
* and perhaps safer wrt thread stack overflow.
|
||||
*/
|
||||
isc_result_t
|
||||
dns_diff_sort(dns_diff_t *diff, dns_diff_compare_func *compare)
|
||||
{
|
||||
unsigned int length = 0;
|
||||
unsigned int i;
|
||||
dns_diff_sort(dns_diff_t *diff, dns_diff_compare_func *compare) {
|
||||
unsigned int length = 0;
|
||||
unsigned int i;
|
||||
dns_difftuple_t **v;
|
||||
dns_difftuple_t * p;
|
||||
dns_difftuple_t *p;
|
||||
REQUIRE(DNS_DIFF_VALID(diff));
|
||||
|
||||
for (p = ISC_LIST_HEAD(diff->tuples); p != NULL;
|
||||
@@ -587,8 +575,7 @@ dns_diff_sort(dns_diff_t *diff, dns_diff_compare_func *compare)
|
||||
|
||||
static isc_result_t
|
||||
diff_tuple_tordataset(dns_difftuple_t *t, dns_rdata_t *rdata,
|
||||
dns_rdatalist_t *rdl, dns_rdataset_t *rds)
|
||||
{
|
||||
dns_rdatalist_t *rdl, dns_rdataset_t *rds) {
|
||||
REQUIRE(DNS_DIFFTUPLE_VALID(t));
|
||||
REQUIRE(rdl != NULL);
|
||||
REQUIRE(rds != NULL);
|
||||
@@ -605,13 +592,12 @@ diff_tuple_tordataset(dns_difftuple_t *t, dns_rdata_t *rdata,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_diff_print(dns_diff_t *diff, FILE *file)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_diff_print(dns_diff_t *diff, FILE *file) {
|
||||
isc_result_t result;
|
||||
dns_difftuple_t *t;
|
||||
char * mem = NULL;
|
||||
unsigned int size = 2048;
|
||||
const char * op = NULL;
|
||||
char *mem = NULL;
|
||||
unsigned int size = 2048;
|
||||
const char *op = NULL;
|
||||
|
||||
REQUIRE(DNS_DIFF_VALID(diff));
|
||||
|
||||
@@ -623,8 +609,8 @@ dns_diff_print(dns_diff_t *diff, FILE *file)
|
||||
isc_region_t r;
|
||||
|
||||
dns_rdatalist_t rdl;
|
||||
dns_rdataset_t rds;
|
||||
dns_rdata_t rd = DNS_RDATA_INIT;
|
||||
dns_rdataset_t rds;
|
||||
dns_rdata_t rd = DNS_RDATA_INIT;
|
||||
|
||||
result = diff_tuple_tordataset(t, &rd, &rdl, &rds);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
@@ -636,8 +622,8 @@ dns_diff_print(dns_diff_t *diff, FILE *file)
|
||||
}
|
||||
again:
|
||||
isc_buffer_init(&buf, mem, size);
|
||||
result =
|
||||
dns_rdataset_totext(&rds, &t->name, false, false, &buf);
|
||||
result = dns_rdataset_totext(&rds, &t->name, false, false,
|
||||
&buf);
|
||||
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
isc_mem_put(diff->mctx, mem, size);
|
||||
|
Reference in New Issue
Block a user