goto failure; \
} while (0)
+#define loginfo(...) \
+ ({ if ((state != NULL) && (state->log != NULL)) \
+ state->log(ISC_LOG_INFO, __VA_ARGS__); })
+#define logerr(...) \
+ ({ if ((state != NULL) && (state->log != NULL)) \
+ state->log(ISC_LOG_ERROR, __VA_ARGS__); })
+
/* For this simple example, use fixed sized strings */
struct record {
char name[100];
i = first_empty;
}
if (i == MAX_RECORDS) {
- if (state->log != NULL)
- state->log(ISC_LOG_ERROR,
- "dlz_example: out of record space");
+ logerr("dlz_example: out of record space");
return (ISC_R_FAILURE);
}
va_end(ap);
if (argc < 2 || argv[1][0] == '\0') {
- if (state->log != NULL)
- state->log(ISC_LOG_ERROR,
- "dlz_example: please specify a zone name");
+ logerr("dlz_example: please specify a zone name");
dlz_destroy(state);
return (ISC_R_FAILURE);
}
add_name(state, &state->current[0], state->zone_name,
"a", 1800, "10.53.0.1");
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: started for zone %s",
- state->zone_name);
+ loginfo("dlz_example: started for zone %s", state->zone_name);
*dbdata = state;
return (ISC_R_SUCCESS);
dlz_destroy(void *dbdata) {
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
- if (state->log != NULL)
- state->log(ISC_LOG_INFO,
- "dlz_example: shutting down zone %s",
- state->zone_name);
+ loginfo("dlz_example: shutting down zone %s", state->zone_name);
free(state->zone_name);
free(state);
}
fmt_address(src, addrbuf, sizeof(addrbuf));
}
- state->log(ISC_LOG_INFO,
- "dlz_example: dlz_findzonedb called with name '%s' "
- "in zone DB '%s' from %s",
- name, state->zone_name, addrbuf);
+ loginfo("dlz_example: dlz_findzonedb called with name '%s' "
+ "in zone DB '%s' from %s", name, state->zone_name, addrbuf);
/*
* Returning ISC_R_NOTFOUND will cause the query logic to
count = 1;
memcpy(last, full_name, size + 1);
}
- state->log(ISC_LOG_INFO, "lookup #%d for %s", count, full_name);
+ loginfo("lookup #%d for %s", count, full_name);
/*
* If we need to know the database version (as set in
if (clientinfo != NULL &&
clientinfo->version >= DNS_CLIENTINFO_VERSION) {
dbversion = clientinfo->dbversion;
- if (dbversion != NULL && *(bool *)dbversion)
- state->log(ISC_LOG_INFO,
- "dlz_example: lookup against live "
- "transaction");
+ if (dbversion != NULL && *(bool *)dbversion) {
+ loginfo("dlz_example: lookup against live transaction");
+ }
}
if (strcmp(name, "source-addr") == 0) {
fmt_address(src, buf, sizeof(buf));
}
- state->log(ISC_LOG_INFO,
- "dlz_example: lookup connection from %s", buf);
+ loginfo("dlz_example: lookup connection from %s", buf);
found = true;
result = state->putrr(lookup, "TXT", 0, buf);
*/
isc_result_t
dlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
+ struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
isc_result_t result;
+ loginfo("dlz_example: dlz_allowzonexfr called for %s", name);
+
result = dlz_findzonedb(dbdata, name, NULL, NULL);
if (result != ISC_R_SUCCESS) {
+ loginfo("dlz_example: findzonedb returned %s",
+ isc_result_totext(result));
return (result);
}
* is effective.
*/
if (strcmp(client, "10.53.0.5") == 0) {
+ loginfo("dlz_example: disallow transfer to 10.53.0.5");
return (ISC_R_NOPERM);
}
+ loginfo("dlz_example: transfer allowed for %s", name);
+
return (ISC_R_SUCCESS);
}
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
if (state->transaction_started) {
- if (state->log != NULL)
- state->log(ISC_LOG_INFO,
- "dlz_example: transaction already "
- "started for zone %s", zone);
+ loginfo("dlz_example: transaction already started for zone %s",
+ zone);
return (ISC_R_FAILURE);
}
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
if (!state->transaction_started) {
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: transaction not "
- "started for zone %s", zone);
+ loginfo("dlz_example: transaction not started for zone %s",
+ zone);
*versionp = NULL;
return;
}
if (commit) {
int i;
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: committing "
- "transaction on zone %s", zone);
+ loginfo("dlz_example: committing transaction on zone %s", zone);
for (i = 0; i < MAX_RECORDS; i++) {
if (strlen(state->deletes[i].name) > 0U) {
(void)del_name(state, &state->current[0],
}
}
} else {
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: cancelling "
- "transaction on zone %s", zone);
+ loginfo("dlz_example: cancelling transaction on zone %s", zone);
}
memset(state->adds, 0, sizeof(state->adds));
memset(state->deletes, 0, sizeof(state->deletes));
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
isc_result_t result;
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: starting configure");
+ loginfo("dlz_example: starting configure");
if (state->writeable_zone == NULL) {
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: no "
- "writeable_zone method available");
+ loginfo("dlz_example: no writeable_zone method available");
return (ISC_R_FAILURE);
}
result = state->writeable_zone(view, dlzdb, state->zone_name);
if (result != ISC_R_SUCCESS) {
- if (state->log != NULL)
- state->log(ISC_LOG_ERROR, "dlz_example: failed to "
- "configure zone %s", state->zone_name);
+ loginfo("dlz_example: failed to configure zone %s",
+ state->zone_name);
return (result);
}
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: configured writeable "
- "zone %s", state->zone_name);
+ loginfo("dlz_example: configured writeable zone %s", state->zone_name);
return (ISC_R_SUCCESS);
}
UNUSED(keydata);
if (strncmp(name, "deny.", 5) == 0) {
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: denying update "
- "of name=%s by %s", name, signer);
+ loginfo("dlz_example: denying update of name=%s by %s",
+ name, signer);
return (false);
}
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: allowing update of "
- "name=%s by %s", name, signer);
+ loginfo("dlz_example: allowing update of name=%s by %s", name, signer);
return (true);
}
if (version != (void *) &state->transaction_started)
return (ISC_R_FAILURE);
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: adding rdataset %s '%s'",
- name, rdatastr);
+ loginfo("dlz_example: adding rdataset %s '%s'", name, rdatastr);
return (modrdataset(state, name, rdatastr, &state->adds[0]));
}
if (version != (void *) &state->transaction_started)
return (ISC_R_FAILURE);
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: subtracting rdataset "
- "%s '%s'", name, rdatastr);
+ loginfo("dlz_example: subtracting rdataset %s '%s'", name, rdatastr);
return (modrdataset(state, name, rdatastr, &state->deletes[0]));
}
if (version != (void *) &state->transaction_started)
return (ISC_R_FAILURE);
- if (state->log != NULL)
- state->log(ISC_LOG_INFO, "dlz_example: deleting rdataset %s "
- "of type %s", name, type);
+ loginfo("dlz_example: deleting rdataset %s of type %s", name, type);
return (ISC_R_SUCCESS);
}