#ifndef RDATA_GENERIC_TKEY_249_C
#define RDATA_GENERIC_TKEY_249_C
static inline isc_result_t
totext_tkey(ARGS_TOTEXT) {
isc_region_t sr, dr;
char buf[sizeof("4294967295 ")];
unsigned long n;
dns_name_t name;
dns_name_t prefix;
int sub;
REQUIRE(rdata->type == dns_rdatatype_tkey);
REQUIRE(rdata->length != 0);
dns_rdata_toregion(rdata, &sr);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_name_fromregion(&name, &sr);
sub = name_prefix(&name, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
RETERR(isc_str_tobuffer(" ", target));
isc_region_consume(&sr, name_length(&name));
n = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
snprintf(buf, sizeof(buf), "%lu ", n);
RETERR(isc_str_tobuffer(buf, target));
n = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
snprintf(buf, sizeof(buf), "%lu ", n);
RETERR(isc_str_tobuffer(buf, target));
n = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
snprintf(buf, sizeof(buf), "%lu ", n);
RETERR(isc_str_tobuffer(buf, target));
n = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
if (dns_tsigrcode_totext((dns_rcode_t)n, target) == ISC_R_SUCCESS)
RETERR(isc_str_tobuffer(" ", target));
else {
snprintf(buf, sizeof(buf), "%lu ", n);
RETERR(isc_str_tobuffer(buf, target));
}
n = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
snprintf(buf, sizeof(buf), "%lu", n);
RETERR(isc_str_tobuffer(buf, target));
REQUIRE(n <= sr.length);
dr = sr;
dr.length = n;
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(isc_str_tobuffer(" (", target));
RETERR(isc_str_tobuffer(tctx->linebreak, target));
if (tctx->width == 0)
RETERR(isc_base64_totext(&dr, 60, "", target));
else
RETERR(isc_base64_totext(&dr, tctx->width - 2,
tctx->linebreak, target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(isc_str_tobuffer(" ) ", target));
else
RETERR(isc_str_tobuffer(" ", target));
isc_region_consume(&sr, n);
n = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
snprintf(buf, sizeof(buf), "%lu", n);
RETERR(isc_str_tobuffer(buf, target));
REQUIRE(n <= sr.length);
if (n != 0U) {
dr = sr;
dr.length = n;
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(isc_str_tobuffer(" (", target));
RETERR(isc_str_tobuffer(tctx->linebreak, target));
if (tctx->width == 0)
RETERR(isc_base64_totext(&dr, 60, "", target));
else
RETERR(isc_base64_totext(&dr, tctx->width - 2,
tctx->linebreak, target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(isc_str_tobuffer(" )", target));
}
return (ISC_R_SUCCESS);
}
static inline isc_result_t
fromwire_tkey(ARGS_FROMWIRE) {
isc_region_t sr;
unsigned long n;
dns_name_t name;
REQUIRE(type == dns_rdatatype_tkey);
UNUSED(type);
UNUSED(rdclass);
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
dns_name_init(&name, NULL);
RETERR(dns_name_fromwire(&name, source, dctx, options, target));
isc_buffer_activeregion(source, &sr);
if (sr.length < 12)
return (ISC_R_UNEXPECTEDEND);
RETERR(isc_mem_tobuffer(target, sr.base, 12));
isc_region_consume(&sr, 12);
isc_buffer_forward(source, 12);
if (sr.length < 2)
return (ISC_R_UNEXPECTEDEND);
n = uint16_fromregion(&sr);
if (sr.length < n + 2)
return (ISC_R_UNEXPECTEDEND);
RETERR(isc_mem_tobuffer(target, sr.base, n + 2));
isc_region_consume(&sr, n + 2);
isc_buffer_forward(source, n + 2);
if (sr.length < 2)
return (ISC_R_UNEXPECTEDEND);
n = uint16_fromregion(&sr);
if (sr.length < n + 2)
return (ISC_R_UNEXPECTEDEND);
isc_buffer_forward(source, n + 2);
return (isc_mem_tobuffer(target, sr.base, n + 2));
}
static inline isc_result_t
towire_tkey(ARGS_TOWIRE) {
isc_region_t sr;
dns_name_t name;
dns_offsets_t offsets;
REQUIRE(rdata->type == dns_rdatatype_tkey);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &sr);
dns_name_init(&name, offsets);
dns_name_fromregion(&name, &sr);
RETERR(dns_name_towire(&name, cctx, target));
isc_region_consume(&sr, name_length(&name));
return (isc_mem_tobuffer(target, sr.base, sr.length));
}
#endif