本文整理汇总了C++中dns_rdata_toregion函数的典型用法代码示例。如果您正苦于以下问题:C++ dns_rdata_toregion函数的具体用法?C++ dns_rdata_toregion怎么用?C++ dns_rdata_toregion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dns_rdata_toregion函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: towire_rrsig
static inline isc_result_t
towire_rrsig(ARGS_TOWIRE) {
isc_region_t sr;
dns_name_t name;
dns_offsets_t offsets;
REQUIRE(rdata->type == 46);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_rdata_toregion(rdata, &sr);
/*
* type covered: 2
* algorithm: 1
* labels: 1
* original ttl: 4
* signature expiration: 4
* time signed: 4
* key footprint: 2
*/
RETERR(mem_tobuffer(target, sr.base, 18));
isc_region_consume(&sr, 18);
/*
* Signer.
*/
dns_name_init(&name, offsets);
dns_name_fromregion(&name, &sr);
isc_region_consume(&sr, name_length(&name));
RETERR(dns_name_towire(&name, cctx, target));
/*
* Signature.
*/
return (mem_tobuffer(target, sr.base, sr.length));
}
示例2: tostruct_isdn
static inline isc_result_t
tostruct_isdn(ARGS_TOSTRUCT) {
dns_rdata_isdn_t *isdn = target;
isc_region_t r;
REQUIRE(rdata->type == 20);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
isdn->common.rdclass = rdata->rdclass;
isdn->common.rdtype = rdata->type;
ISC_LINK_INIT(&isdn->common, link);
dns_rdata_toregion(rdata, &r);
isdn->isdn_len = uint8_fromregion(&r);
isc_region_consume(&r, 1);
isdn->isdn = mem_maybedup(mctx, r.base, isdn->isdn_len);
if (isdn->isdn == NULL)
return (ISC_R_NOMEMORY);
isc_region_consume(&r, isdn->isdn_len);
isdn->subaddress_len = uint8_fromregion(&r);
isc_region_consume(&r, 1);
isdn->subaddress = mem_maybedup(mctx, r.base, isdn->subaddress_len);
if (isdn->subaddress == NULL)
goto cleanup;
isdn->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL && isdn->isdn != NULL)
isc_mem_free(mctx, isdn->isdn);
return (ISC_R_NOMEMORY);
}
示例3: totext_afsdb
static inline isc_result_t
totext_afsdb(ARGS_TOTEXT) {
dns_name_t name;
dns_name_t prefix;
isc_region_t region;
char buf[sizeof("64000 ")];
isc_boolean_t sub;
unsigned int num;
REQUIRE(rdata->type == dns_rdatatype_afsdb);
REQUIRE(rdata->length != 0);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, ®ion);
num = uint16_fromregion(®ion);
isc_region_consume(®ion, 2);
sprintf(buf, "%u ", num);
RETERR(str_totext(buf, target));
dns_name_fromregion(&name, ®ion);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
示例4: towire_afsdb
static inline isc_result_t
towire_afsdb(ARGS_TOWIRE) {
isc_region_t tr;
isc_region_t sr;
dns_name_t name;
dns_offsets_t offsets;
REQUIRE(rdata->type == dns_rdatatype_afsdb);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
isc_buffer_availableregion(target, &tr);
dns_rdata_toregion(rdata, &sr);
if (tr.length < 2)
return (ISC_R_NOSPACE);
memmove(tr.base, sr.base, 2);
isc_region_consume(&sr, 2);
isc_buffer_add(target, 2);
dns_name_init(&name, offsets);
dns_name_fromregion(&name, &sr);
return (dns_name_towire(&name, cctx, target));
}
示例5: towire_in_srv
static inline isc_result_t
towire_in_srv(ARGS_TOWIRE) {
dns_name_t name;
dns_offsets_t offsets;
isc_region_t sr;
REQUIRE(rdata->type == 33);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/*
* Priority, weight, port.
*/
dns_rdata_toregion(rdata, &sr);
RETERR(mem_tobuffer(target, sr.base, 6));
isc_region_consume(&sr, 6);
/*
* Target.
*/
dns_name_init(&name, offsets);
dns_name_fromregion(&name, &sr);
return (dns_name_towire(&name, cctx, target));
}
示例6: tostruct_mx
static inline isc_result_t
tostruct_mx(ARGS_TOSTRUCT) {
isc_region_t region;
dns_rdata_mx_t *mx = target;
dns_name_t name;
REQUIRE(rdata->type == 15);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
mx->common.rdclass = rdata->rdclass;
mx->common.rdtype = rdata->type;
ISC_LINK_INIT(&mx->common, link);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, ®ion);
mx->pref = uint16_fromregion(®ion);
isc_region_consume(®ion, 2);
dns_name_fromregion(&name, ®ion);
dns_name_init(&mx->mx, NULL);
RETERR(name_duporclone(&name, mctx, &mx->mx));
mx->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例7: totext_dnskey
static inline isc_result_t
totext_dnskey(ARGS_TOTEXT) {
isc_region_t sr;
char buf[sizeof("64000")];
unsigned int flags;
unsigned char algorithm;
char algbuf[DNS_NAME_FORMATSIZE];
const char *keyinfo;
REQUIRE(rdata->type == 48);
REQUIRE(rdata->length != 0);
dns_rdata_toregion(rdata, &sr);
/* flags */
flags = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%u", flags);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
if ((flags & DNS_KEYFLAG_KSK) != 0) {
if (flags & DNS_KEYFLAG_REVOKE)
keyinfo = "revoked KSK";
else
keyinfo = "KSK";
} else
keyinfo = "ZSK";
/* protocol */
sprintf(buf, "%u", sr.base[0]);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/* algorithm */
algorithm = sr.base[0];
sprintf(buf, "%u", algorithm);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
/* No Key? */
if ((flags & 0xc000) == 0xc000)
return (ISC_R_SUCCESS);
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0 &&
algorithm == DNS_KEYALG_PRIVATEDNS) {
dns_name_t name;
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &sr);
dns_name_format(&name, algbuf, sizeof(algbuf));
} else {
dns_secalg_format((dns_secalg_t) algorithm, algbuf,
sizeof(algbuf));
}
/* key */
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" (", target));
RETERR(str_totext(tctx->linebreak, target));
if (tctx->width == 0) /* No splitting */
RETERR(isc_base64_totext(&sr, 0, "", target));
else
RETERR(isc_base64_totext(&sr, tctx->width - 2,
tctx->linebreak, target));
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0)
RETERR(str_totext(tctx->linebreak, target));
else if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" ", target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(")", target));
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0) {
isc_region_t tmpr;
RETERR(str_totext(" ; ", target));
RETERR(str_totext(keyinfo, target));
RETERR(str_totext("; alg = ", target));
RETERR(str_totext(algbuf, target));
RETERR(str_totext("; key id = ", target));
dns_rdata_toregion(rdata, &tmpr);
sprintf(buf, "%u", dst_region_computeid(&tmpr, algorithm));
RETERR(str_totext(buf, target));
}
return (ISC_R_SUCCESS);
}
示例8: totext_keydata
static inline isc_result_t
totext_keydata(ARGS_TOTEXT) {
isc_region_t sr;
char buf[sizeof("64000")];
unsigned int flags;
unsigned char algorithm;
unsigned long refresh, add, remove;
char algbuf[DNS_NAME_FORMATSIZE];
const char *keyinfo;
REQUIRE(rdata->type == 65533);
if ((tctx->flags & DNS_STYLEFLAG_KEYDATA) == 0 || rdata->length < 16)
return (unknown_totext(rdata, tctx, target));
dns_rdata_toregion(rdata, &sr);
/* refresh timer */
refresh = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
RETERR(dns_time32_totext(refresh, target));
RETERR(str_totext(" ", target));
/* add hold-down */
add = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
RETERR(dns_time32_totext(add, target));
RETERR(str_totext(" ", target));
/* remove hold-down */
remove = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
RETERR(dns_time32_totext(remove, target));
RETERR(str_totext(" ", target));
/* flags */
flags = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%u", flags);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
if ((flags & DNS_KEYFLAG_KSK) != 0) {
if (flags & DNS_KEYFLAG_REVOKE)
keyinfo = "revoked KSK";
else
keyinfo = "KSK";
} else
keyinfo = "ZSK";
/* protocol */
sprintf(buf, "%u", sr.base[0]);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/* algorithm */
algorithm = sr.base[0];
sprintf(buf, "%u", algorithm);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
/* No Key? */
if ((flags & 0xc000) == 0xc000)
return (ISC_R_SUCCESS);
/* key */
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" (", target));
RETERR(str_totext(tctx->linebreak, target));
if (tctx->width == 0) /* No splitting */
RETERR(isc_base64_totext(&sr, 60, "", target));
else
RETERR(isc_base64_totext(&sr, tctx->width - 2,
tctx->linebreak, target));
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0)
RETERR(str_totext(tctx->linebreak, target));
else if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" ", target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(")", target));
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0) {
isc_region_t tmpr;
char rbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
char abuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
char dbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
isc_time_t t;
RETERR(str_totext(" ; ", target));
RETERR(str_totext(keyinfo, target));
dns_secalg_format((dns_secalg_t) algorithm, algbuf,
sizeof(algbuf));
RETERR(str_totext("; alg = ", target));
RETERR(str_totext(algbuf, target));
RETERR(str_totext("; key id = ", target));
dns_rdata_toregion(rdata, &tmpr);
/* Skip over refresh, addhd, and removehd */
isc_region_consume(&tmpr, 12);
//.........这里部分代码省略.........
示例9: totext_nsec3
static inline isc_result_t
totext_nsec3(ARGS_TOTEXT) {
isc_region_t sr;
unsigned int i, j;
unsigned char hash;
unsigned char flags;
char buf[sizeof("TYPE65535")];
isc_uint32_t iterations;
REQUIRE(rdata->type == dns_rdatatype_nsec3);
REQUIRE(rdata->length != 0);
dns_rdata_toregion(rdata, &sr);
/* Hash */
hash = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
sprintf(buf, "%u ", hash);
RETERR(str_totext(buf, target));
/* Flags */
flags = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
sprintf(buf, "%u ", flags);
RETERR(str_totext(buf, target));
/* Iterations */
iterations = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%u ", iterations);
RETERR(str_totext(buf, target));
/* Salt */
j = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
INSIST(j <= sr.length);
if (j != 0) {
i = sr.length;
sr.length = j;
RETERR(isc_hex_totext(&sr, 1, "", target));
sr.length = i - j;
} else
RETERR(str_totext("-", target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" (", target));
RETERR(str_totext(tctx->linebreak, target));
/* Next hash */
j = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
INSIST(j <= sr.length);
i = sr.length;
sr.length = j;
RETERR(isc_base32hexnp_totext(&sr, 1, "", target));
sr.length = i - j;
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) == 0)
RETERR(str_totext(" ", target));
RETERR(typemap_totext(&sr, tctx, target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" )", target));
return (ISC_R_SUCCESS);
}
示例10: tostruct_tkey
static inline isc_result_t
tostruct_tkey(ARGS_TOSTRUCT) {
dns_rdata_tkey_t *tkey = target;
dns_name_t alg;
isc_region_t sr;
REQUIRE(rdata->type == 249);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
tkey->common.rdclass = rdata->rdclass;
tkey->common.rdtype = rdata->type;
ISC_LINK_INIT(&tkey->common, link);
dns_rdata_toregion(rdata, &sr);
/*
* Algorithm Name.
*/
dns_name_init(&alg, NULL);
dns_name_fromregion(&alg, &sr);
dns_name_init(&tkey->algorithm, NULL);
RETERR(name_duporclone(&alg, mctx, &tkey->algorithm));
isc_region_consume(&sr, name_length(&tkey->algorithm));
/*
* Inception.
*/
tkey->inception = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/*
* Expire.
*/
tkey->expire = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/*
* Mode.
*/
tkey->mode = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/*
* Error.
*/
tkey->error = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/*
* Key size.
*/
tkey->keylen = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/*
* Key.
*/
tkey->key = mem_maybedup(mctx, sr.base, tkey->keylen);
if (tkey->key == NULL)
goto cleanup;
isc_region_consume(&sr, tkey->keylen);
/*
* Other size.
*/
tkey->otherlen = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/*
* Other.
*/
tkey->other = mem_maybedup(mctx, sr.base, tkey->otherlen);
if (tkey->other == NULL)
goto cleanup;
tkey->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL)
dns_name_free(&tkey->algorithm, mctx);
if (mctx != NULL && tkey->key != NULL)
isc_mem_free(mctx, tkey->key);
return (ISC_R_NOMEMORY);
}
示例11: tostruct_sig
static inline isc_result_t
tostruct_sig(ARGS_TOSTRUCT) {
isc_region_t sr;
dns_rdata_sig_t *sig = target;
dns_name_t signer;
REQUIRE(rdata->type == dns_rdatatype_sig);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
sig->common.rdclass = rdata->rdclass;
sig->common.rdtype = rdata->type;
ISC_LINK_INIT(&sig->common, link);
dns_rdata_toregion(rdata, &sr);
/*
* Type covered.
*/
sig->covered = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/*
* Algorithm.
*/
sig->algorithm = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
/*
* Labels.
*/
sig->labels = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
/*
* Original TTL.
*/
sig->originalttl = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/*
* Expire time.
*/
sig->timeexpire = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/*
* Time signed.
*/
sig->timesigned = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
/*
* Key ID.
*/
sig->keyid = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
dns_name_init(&signer, NULL);
dns_name_fromregion(&signer, &sr);
dns_name_init(&sig->signer, NULL);
RETERR(name_duporclone(&signer, mctx, &sig->signer));
isc_region_consume(&sr, name_length(&sig->signer));
/*
* Signature.
*/
sig->siglen = sr.length;
sig->signature = mem_maybedup(mctx, sr.base, sig->siglen);
if (sig->signature == NULL)
goto cleanup;
sig->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL)
dns_name_free(&sig->signer, mctx);
return (ISC_R_NOMEMORY);
}
示例12: totext_in_apl
static inline isc_result_t
totext_in_apl(ARGS_TOTEXT) {
isc_region_t sr;
isc_region_t ir;
isc_uint16_t afi;
isc_uint8_t prefix;
isc_uint8_t len;
isc_boolean_t neg;
unsigned char buf[16];
char txt[sizeof(" !64000:")];
const char *sep = "";
int n;
REQUIRE(rdata->type == dns_rdatatype_apl);
REQUIRE(rdata->rdclass == dns_rdataclass_in);
UNUSED(tctx);
dns_rdata_toregion(rdata, &sr);
ir.base = buf;
ir.length = sizeof(buf);
while (sr.length > 0) {
INSIST(sr.length >= 4);
afi = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
prefix = *sr.base;
isc_region_consume(&sr, 1);
len = (*sr.base & 0x7f);
neg = ISC_TF((*sr.base & 0x80) != 0);
isc_region_consume(&sr, 1);
INSIST(len <= sr.length);
n = snprintf(txt, sizeof(txt), "%s%s%u:", sep,
neg ? "!" : "", afi);
INSIST(n < (int)sizeof(txt));
RETERR(str_totext(txt, target));
switch (afi) {
case 1:
INSIST(len <= 4);
INSIST(prefix <= 32);
memset(buf, 0, sizeof(buf));
memmove(buf, sr.base, len);
RETERR(inet_totext(AF_INET, &ir, target));
break;
case 2:
INSIST(len <= 16);
INSIST(prefix <= 128);
memset(buf, 0, sizeof(buf));
memmove(buf, sr.base, len);
RETERR(inet_totext(AF_INET6, &ir, target));
break;
default:
return (ISC_R_NOTIMPLEMENTED);
}
n = snprintf(txt, sizeof(txt), "/%u", prefix);
INSIST(n < (int)sizeof(txt));
RETERR(str_totext(txt, target));
isc_region_consume(&sr, len);
sep = " ";
}
return (ISC_R_SUCCESS);
}
示例13: totext_hip
static inline isc_result_t
totext_hip(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
unsigned int length, key_len, hit_len;
unsigned char algorithm;
char buf[sizeof("225 ")];
REQUIRE(rdata->type == dns_rdatatype_hip);
REQUIRE(rdata->length != 0);
dns_rdata_toregion(rdata, ®ion);
hit_len = uint8_fromregion(®ion);
isc_region_consume(®ion, 1);
algorithm = uint8_fromregion(®ion);
isc_region_consume(®ion, 1);
key_len = uint16_fromregion(®ion);
isc_region_consume(®ion, 2);
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext("( ", target));
/*
* Algorithm
*/
sprintf(buf, "%u ", algorithm);
RETERR(str_totext(buf, target));
/*
* HIT.
*/
INSIST(hit_len < region.length);
length = region.length;
region.length = hit_len;
RETERR(isc_hex_totext(®ion, 1, "", target));
region.length = length - hit_len;
RETERR(str_totext(tctx->linebreak, target));
/*
* Public KEY.
*/
INSIST(key_len <= region.length);
length = region.length;
region.length = key_len;
RETERR(isc_base64_totext(®ion, 1, "", target));
region.length = length - key_len;
RETERR(str_totext(tctx->linebreak, target));
/*
* Rendezvous Servers.
*/
dns_name_init(&name, NULL);
while (region.length > 0) {
dns_name_fromregion(&name, ®ion);
RETERR(dns_name_totext(&name, ISC_FALSE, target));
isc_region_consume(®ion, name.length);
if (region.length > 0)
RETERR(str_totext(tctx->linebreak, target));
}
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" )", target));
return (ISC_R_SUCCESS);
}
示例14: tostruct_naptr
static inline isc_result_t
tostruct_naptr(ARGS_TOSTRUCT) {
dns_rdata_naptr_t *naptr = target;
isc_region_t r;
isc_result_t result;
dns_name_t name;
REQUIRE(rdata->type == dns_rdatatype_naptr);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
naptr->common.rdclass = rdata->rdclass;
naptr->common.rdtype = rdata->type;
ISC_LINK_INIT(&naptr->common, link);
naptr->flags = NULL;
naptr->service = NULL;
naptr->regexp = NULL;
dns_rdata_toregion(rdata, &r);
naptr->order = uint16_fromregion(&r);
isc_region_consume(&r, 2);
naptr->preference = uint16_fromregion(&r);
isc_region_consume(&r, 2);
naptr->flags_len = uint8_fromregion(&r);
isc_region_consume(&r, 1);
INSIST(naptr->flags_len <= r.length);
naptr->flags = mem_maybedup(mctx, r.base, naptr->flags_len);
if (naptr->flags == NULL)
goto cleanup;
isc_region_consume(&r, naptr->flags_len);
naptr->service_len = uint8_fromregion(&r);
isc_region_consume(&r, 1);
INSIST(naptr->service_len <= r.length);
naptr->service = mem_maybedup(mctx, r.base, naptr->service_len);
if (naptr->service == NULL)
goto cleanup;
isc_region_consume(&r, naptr->service_len);
naptr->regexp_len = uint8_fromregion(&r);
isc_region_consume(&r, 1);
INSIST(naptr->regexp_len <= r.length);
naptr->regexp = mem_maybedup(mctx, r.base, naptr->regexp_len);
if (naptr->regexp == NULL)
goto cleanup;
isc_region_consume(&r, naptr->regexp_len);
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &r);
dns_name_init(&naptr->replacement, NULL);
result = name_duporclone(&name, mctx, &naptr->replacement);
if (result != ISC_R_SUCCESS)
goto cleanup;
naptr->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL && naptr->flags != NULL)
isc_mem_free(mctx, naptr->flags);
if (mctx != NULL && naptr->service != NULL)
isc_mem_free(mctx, naptr->service);
if (mctx != NULL && naptr->regexp != NULL)
isc_mem_free(mctx, naptr->regexp);
return (ISC_R_NOMEMORY);
}
示例15: compare_naptr
static inline int
compare_naptr(ARGS_COMPARE) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
int order, len;
REQUIRE(rdata1->type == rdata2->type);
REQUIRE(rdata1->rdclass == rdata2->rdclass);
REQUIRE(rdata1->type == dns_rdatatype_naptr);
REQUIRE(rdata1->length != 0);
REQUIRE(rdata2->length != 0);
dns_rdata_toregion(rdata1, ®ion1);
dns_rdata_toregion(rdata2, ®ion2);
/*
* Order, preference.
*/
order = memcmp(region1.base, region2.base, 4);
if (order != 0)
return (order < 0 ? -1 : 1);
isc_region_consume(®ion1, 4);
isc_region_consume(®ion2, 4);
/*
* Flags.
*/
len = ISC_MIN(region1.base[0], region2.base[0]);
order = memcmp(region1.base, region2.base, len + 1);
if (order != 0)
return (order < 0 ? -1 : 1);
isc_region_consume(®ion1, region1.base[0] + 1);
isc_region_consume(®ion2, region2.base[0] + 1);
/*
* Service.
*/
len = ISC_MIN(region1.base[0], region2.base[0]);
order = memcmp(region1.base, region2.base, len + 1);
if (order != 0)
return (order < 0 ? -1 : 1);
isc_region_consume(®ion1, region1.base[0] + 1);
isc_region_consume(®ion2, region2.base[0] + 1);
/*
* Regexp.
*/
len = ISC_MIN(region1.base[0], region2.base[0]);
order = memcmp(region1.base, region2.base, len + 1);
if (order != 0)
return (order < 0 ? -1 : 1);
isc_region_consume(®ion1, region1.base[0] + 1);
isc_region_consume(®ion2, region2.base[0] + 1);
/*
* Replacement.
*/
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_name_fromregion(&name1, ®ion1);
dns_name_fromregion(&name2, ®ion2);
return (dns_name_rdatacompare(&name1, &name2));
}