#ifndef GENERIC_CAA_257_C
#define GENERIC_CAA_257_C 1
static unsigned char const alphanumeric[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
static inline isc_result_t
totext_caa(ARGS_TOTEXT) {
isc_region_t region;
uint8_t flags;
char buf[256];
UNUSED(tctx);
REQUIRE(rdata->type == dns_rdatatype_caa);
REQUIRE(rdata->length >= 3U);
REQUIRE(rdata->data != NULL);
dns_rdata_toregion(rdata, ®ion);
flags = uint8_consume_fromregion(®ion);
snprintf(buf, sizeof(buf), "%u ", flags);
RETERR(isc_str_tobuffer(buf, target));
RETERR(txt_totext(®ion, 0, target));
RETERR(isc_str_tobuffer(" ", target));
RETERR(multitxt_totext(®ion, target));
return (ISC_R_SUCCESS);
}
static inline isc_result_t
fromwire_caa(ARGS_FROMWIRE) {
isc_region_t sr;
unsigned int len, i;
REQUIRE(type == dns_rdatatype_caa);
UNUSED(type);
UNUSED(rdclass);
UNUSED(dctx);
UNUSED(options);
isc_buffer_activeregion(source, &sr);
if (sr.length < 2)
return (ISC_R_UNEXPECTEDEND);
RETERR(isc_mem_tobuffer(target, sr.base, 2));
len = sr.base[1];
isc_region_consume(&sr, 2);
isc_buffer_forward(source, 2);
if (sr.length < len || len == 0)
return (DNS_R_FORMERR);
for (i = 0; i < len; i++)
if (!alphanumeric[sr.base[i]])
return (DNS_R_FORMERR);
isc_buffer_forward(source, sr.length);
return (isc_mem_tobuffer(target, sr.base, sr.length));
}
static inline isc_result_t
towire_caa(ARGS_TOWIRE) {
isc_region_t region;
REQUIRE(rdata->type == dns_rdatatype_caa);
REQUIRE(rdata->length >= 3U);
REQUIRE(rdata->data != NULL);
UNUSED(cctx);
dns_rdata_toregion(rdata, ®ion);
return (isc_mem_tobuffer(target, region.base, region.length));
}
#endif