* If the DLZ only operates on 'live' data, then version
* wouldn't necessarily be needed.
*/
- if (clientinfo != NULL && clientinfo->version >= DNS_CLIENTINFO_VERSION)
- {
+ if (clientinfo != NULL && clientinfo->version >= 2) {
dbversion = clientinfo->dbversion;
if (dbversion != NULL && *(bool *)dbversion) {
loginfo("dlz_example: lookup against live transaction");
* If the DLZ only operates on 'live' data, then version
* wouldn't necessarily be needed.
*/
- if (clientinfo != NULL && clientinfo->version >= DNS_CLIENTINFO_VERSION)
- {
+ if (clientinfo != NULL && clientinfo->version >= 2) {
dbversion = clientinfo->dbversion;
if (dbversion != NULL && *(bool *)dbversion) {
state->log(ISC_LOG_INFO, "dlz_example: lookup against "
}
if (strcmp(name, "source-addr") == 0) {
+ char ecsbuf[100] = "not supported";
strcpy(buf, "unknown");
if (methods != NULL && methods->sourceip != NULL &&
(methods->version - methods->age <=
methods->sourceip(clientinfo, &src);
fmt_address(src, buf, sizeof(buf));
}
+ if (clientinfo != NULL && clientinfo->version >= 3) {
+ if (clientinfo->ecs.addr.family != AF_UNSPEC) {
+ dns_ecs_format(&clientinfo->ecs, ecsbuf,
+ sizeof(ecsbuf));
+ } else {
+ strcpy(ecsbuf, "not present");
+ }
+ }
+ i = strlen(buf);
+ snprintf(buf + i, sizeof(buf) - i - 1, " ECS %s", ecsbuf);
state->log(ISC_LOG_INFO,
"dlz_example: lookup connection from: %s", buf);
found = true;
result = state->putrr(lookup, "TXT", 0, buf);
+ /* We could also generate a CNAME RR:
+ snprintf(buf, sizeof(buf), "%s.redirect.example.", ecsbuf);
+ result = state->putrr(lookup, "CNAME", 0, buf); */
if (result != ISC_R_SUCCESS) {
return (result);
}
#include <inttypes.h>
#include <stdbool.h>
+#include <dns/ecs.h>
+
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/un.h>
-typedef unsigned int isc_result_t;
-typedef uint32_t dns_ttl_t;
+typedef uint32_t dns_ttl_t;
/*
* Define DLZ_DLOPEN_VERSION to different values to use older versions
/* opaque structures */
typedef void *dns_sdlzlookup_t;
typedef void *dns_sdlzallnodes_t;
-typedef void *dns_view_t;
-typedef void *dns_dlzdb_t;
#if DLZ_DLOPEN_VERSION > 1
/*
void *link;
} isc_sockaddr_t;
-#define DNS_CLIENTINFO_VERSION 2
+#define DNS_CLIENTINFO_VERSION 3
typedef struct dns_clientinfo {
- uint16_t version;
- void *data;
- void *dbversion;
+ uint16_t version;
+ void *data;
+ void *dbversion;
+ dns_ecs_t ecs;
} dns_clientinfo_t;
typedef isc_result_t (*dns_clientinfo_sourceip_t)(dns_clientinfo_t *client,