}
if (strcmp(name, "source-addr") == 0) {
+ char ecsbuf[DNS_ECS_FORMATSIZE] = "not supported";
strncpy(buf, "unknown", sizeof(buf));
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 {
+ snprintf(ecsbuf, sizeof(ecsbuf), "%s",
+ "not present");
+ }
+ }
+ i = strlen(buf);
+ snprintf(buf + i, sizeof(buf) - i - 1, " ECS %s", ecsbuf);
loginfo("dlz_example: lookup connection from %s", buf);
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
+newtest "checking ECS data is passed to driver in clientinfo"
+$DIG $DIGOPTS +short +subnet=192.0/16 source-addr.example.nil txt > dig.out.ns1.test$n.1 || ret=1
+grep "192.0.0.0/16/0" dig.out.ns1.test$n.1 > /dev/null || ret=1
+$DIG $DIGOPTS +short source-addr.example.nil txt > dig.out.ns1.test$n.2 || ret=1
+grep "not.*present" dig.out.ns1.test$n.2 > /dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1
}
if (strcmp(name, "source-addr") == 0) {
- char ecsbuf[100] = "not supported";
- strcpy(buf, "unknown");
+ char ecsbuf[DNS_ECS_FORMATSIZE] = "not supported";
+ strncpy(buf, "unknown", sizeof(buf));
if (methods != NULL && methods->sourceip != NULL &&
(methods->version - methods->age <=
DNS_CLIENTINFOMETHODS_VERSION) &&
dns_ecs_format(&clientinfo->ecs, ecsbuf,
sizeof(ecsbuf));
} else {
- strcpy(ecsbuf, "not present");
+ snprintf(ecsbuf, sizeof(ecsbuf), "%s",
+ "not present");
}
}
i = strlen(buf);
} dns_clientinfomethods_t;
#endif /* DLZ_DLOPEN_VERSION > 1 */
+#define DNS_ECS_FORMATSIZE \
+ sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX%SSSSSSSSSS" \
+ "/NNN/NNN")
+
/*
* Method definitions for callbacks provided by the dlopen driver
*/