本文整理汇总了C++中dns_name_fromregion函数的典型用法代码示例。如果您正苦于以下问题:C++ dns_name_fromregion函数的具体用法?C++ dns_name_fromregion怎么用?C++ dns_name_fromregion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dns_name_fromregion函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: totext_md
static inline isc_result_t totext_md (ARGS_TOTEXT)
{
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
REQUIRE (rdata->type == 3);
REQUIRE (rdata->length != 0);
dns_name_init (&name, NULL);
dns_name_init (&prefix, NULL);
dns_rdata_toregion (rdata, ®ion);
dns_name_fromregion (&name, ®ion);
sub = name_prefix (&name, tctx->origin, &prefix);
return (dns_name_totext (&prefix, sub, target));
}
示例2: tostruct_in_nsap_ptr
static inline isc_result_t
tostruct_in_nsap_ptr(ARGS_TOSTRUCT) {
isc_region_t region;
dns_rdata_in_nsap_ptr_t *nsap_ptr = target;
dns_name_t name;
REQUIRE(rdata->type == 23);
REQUIRE(rdata->rdclass == 1);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
nsap_ptr->common.rdclass = rdata->rdclass;
nsap_ptr->common.rdtype = rdata->type;
ISC_LINK_INIT(&nsap_ptr->common, link);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, ®ion);
dns_name_fromregion(&name, ®ion);
dns_name_init(&nsap_ptr->owner, NULL);
RETERR(name_duporclone(&name, mctx, &nsap_ptr->owner));
nsap_ptr->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例3: tostruct_md
static inline isc_result_t tostruct_md (ARGS_TOSTRUCT)
{
dns_rdata_md_t *md = target;
isc_region_t r;
dns_name_t name;
REQUIRE (rdata->type == 3);
REQUIRE (target != NULL);
REQUIRE (rdata->length != 0);
md->common.rdclass = rdata->rdclass;
md->common.rdtype = rdata->type;
ISC_LINK_INIT (&md->common, link);
dns_name_init (&name, NULL);
dns_rdata_toregion (rdata, &r);
dns_name_fromregion (&name, &r);
dns_name_init (&md->md, NULL);
RETERR (name_duporclone (&name, mctx, &md->md));
md->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例4: tostruct_lp
static inline isc_result_t
tostruct_lp(ARGS_TOSTRUCT) {
isc_region_t region;
dns_rdata_lp_t *lp = target;
dns_name_t name;
REQUIRE(rdata->type == dns_rdatatype_lp);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
lp->common.rdclass = rdata->rdclass;
lp->common.rdtype = rdata->type;
ISC_LINK_INIT(&lp->common, link);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, ®ion);
lp->pref = uint16_fromregion(®ion);
isc_region_consume(®ion, 2);
dns_name_fromregion(&name, ®ion);
dns_name_init(&lp->lp, NULL);
RETERR(name_duporclone(&name, mctx, &lp->lp));
lp->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例5: towire_rt
static inline isc_result_t
towire_rt(ARGS_TOWIRE) {
dns_name_t name;
dns_offsets_t offsets;
isc_region_t region;
isc_region_t tr;
REQUIRE(rdata->type == 21);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
isc_buffer_availableregion(target, &tr);
dns_rdata_toregion(rdata, ®ion);
if (tr.length < 2)
return (ISC_R_NOSPACE);
memmove(tr.base, region.base, 2);
isc_region_consume(®ion, 2);
isc_buffer_add(target, 2);
dns_name_init(&name, offsets);
dns_name_fromregion(&name, ®ion);
return (dns_name_towire(&name, cctx, target));
}
示例6: 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 == 18);
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));
}
示例7: towire_sig
static inline isc_result_t
towire_sig(ARGS_TOWIRE) {
isc_region_t sr;
dns_name_t name;
dns_offsets_t offsets;
REQUIRE(rdata->type == dns_rdatatype_sig);
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));
}
示例8: checknames_ptr
static inline isc_boolean_t
checknames_ptr(ARGS_CHECKNAMES) {
isc_region_t region;
dns_name_t name;
REQUIRE(rdata->type == 12);
if (rdata->rdclass != dns_rdataclass_in)
return (ISC_TRUE);
if (dns_name_issubdomain(owner, &in_addr_arpa) ||
dns_name_issubdomain(owner, &ip6_arpa) ||
dns_name_issubdomain(owner, &ip6_int)) {
dns_rdata_toregion(rdata, ®ion);
dns_name_init(&name, NULL);
dns_name_fromregion(&name, ®ion);
if (!dns_name_ishostname(&name, ISC_FALSE)) {
if (bad != NULL)
dns_name_clone(&name, bad);
return (ISC_FALSE);
}
}
return (ISC_TRUE);
}
示例9: 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));
}
示例10: totext_tkey
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;
isc_boolean_t sub;
REQUIRE(rdata->type == 249);
REQUIRE(rdata->length != 0);
dns_rdata_toregion(rdata, &sr);
/*
* Algorithm.
*/
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(str_totext(" ", target));
isc_region_consume(&sr, name_length(&name));
/*
* Inception.
*/
n = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
sprintf(buf, "%lu ", n);
RETERR(str_totext(buf, target));
/*
* Expiration.
*/
n = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
sprintf(buf, "%lu ", n);
RETERR(str_totext(buf, target));
/*
* Mode.
*/
n = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%lu ", n);
RETERR(str_totext(buf, target));
/*
* Error.
*/
n = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
if (dns_tsigrcode_totext((dns_rcode_t)n, target) == ISC_R_SUCCESS)
RETERR(str_totext(" ", target));
else {
sprintf(buf, "%lu ", n);
RETERR(str_totext(buf, target));
}
/*
* Key Size.
*/
n = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%lu", n);
RETERR(str_totext(buf, target));
/*
* Key Data.
*/
REQUIRE(n <= sr.length);
dr = sr;
dr.length = n;
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" (", target));
RETERR(str_totext(tctx->linebreak, target));
RETERR(isc_base64_totext(&dr, tctx->width - 2,
tctx->linebreak, target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" ) ", target));
else
RETERR(str_totext(" ", target));
isc_region_consume(&sr, n);
/*
* Other Size.
*/
n = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%lu", n);
RETERR(str_totext(buf, target));
/*
* Other Data.
*/
REQUIRE(n <= sr.length);
if (n != 0U) {
dr = sr;
//.........这里部分代码省略.........
示例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_sig
static inline isc_result_t
totext_sig(ARGS_TOTEXT) {
isc_region_t sr;
char buf[sizeof("4294967295")];
dns_rdatatype_t covered;
unsigned long ttl;
unsigned long when;
unsigned long exp;
unsigned long foot;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
REQUIRE(rdata->type == dns_rdatatype_sig);
REQUIRE(rdata->length != 0);
dns_rdata_toregion(rdata, &sr);
/*
* Type covered.
*/
covered = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
/*
* XXXAG We should have something like dns_rdatatype_isknown()
* that does the right thing with type 0.
*/
if (dns_rdatatype_isknown(covered) && covered != 0) {
RETERR(dns_rdatatype_totext(covered, target));
} else {
sprintf(buf, "%u", covered);
RETERR(str_totext(buf, target));
}
RETERR(str_totext(" ", target));
/*
* Algorithm.
*/
sprintf(buf, "%u", sr.base[0]);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/*
* Labels.
*/
sprintf(buf, "%u", sr.base[0]);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/*
* Ttl.
*/
ttl = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
sprintf(buf, "%lu", ttl);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/*
* Sig exp.
*/
exp = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
RETERR(dns_time32_totext(exp, target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" (", target));
RETERR(str_totext(tctx->linebreak, target));
/*
* Time signed.
*/
when = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
RETERR(dns_time32_totext(when, target));
RETERR(str_totext(" ", target));
/*
* Footprint.
*/
foot = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%lu", foot);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/*
* Signer.
*/
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_name_fromregion(&name, &sr);
isc_region_consume(&sr, name_length(&name));
sub = name_prefix(&name, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
/*
* Sig.
//.........这里部分代码省略.........
示例13: 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));
}
示例14: dns_compress_add
void
dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
const dns_name_t *prefix, isc_uint16_t offset)
{
dns_name_t tname, xname;
unsigned int start;
unsigned int n;
unsigned int count;
unsigned int i;
dns_compressnode_t *node;
unsigned int length;
unsigned int tlength;
isc_uint16_t toffset;
unsigned char *tmp;
isc_region_t r;
REQUIRE(VALID_CCTX(cctx));
REQUIRE(dns_name_isabsolute(name));
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0))
return;
if (offset >= 0x4000)
return;
dns_name_init(&tname, NULL);
dns_name_init(&xname, NULL);
n = dns_name_countlabels(name);
count = dns_name_countlabels(prefix);
if (dns_name_isabsolute(prefix))
count--;
if (count == 0)
return;
start = 0;
dns_name_toregion(name, &r);
length = r.length;
tmp = isc_mem_get(cctx->mctx, length);
if (tmp == NULL)
return;
/*
* Copy name data to 'tmp' and make 'r' use 'tmp'.
*/
memmove(tmp, r.base, r.length);
r.base = tmp;
dns_name_fromregion(&xname, &r);
if (count > 2U)
count = 2U;
while (count > 0) {
unsigned char ch;
dns_name_getlabelsequence(&xname, start, n, &tname);
/*
* We calculate the table index using the first
* character in the first label of tname.
*/
ch = tname.ndata[1];
i = tableindex[ch];
tlength = name_length(&tname);
toffset = (isc_uint16_t)(offset + (length - tlength));
if (toffset >= 0x4000)
break;
/*
* Create a new node and add it.
*/
if (cctx->count < DNS_COMPRESS_INITIALNODES)
node = &cctx->initialnodes[cctx->count];
else {
node = isc_mem_get(cctx->mctx,
sizeof(dns_compressnode_t));
if (node == NULL)
break;
}
node->count = cctx->count++;
/*
* 'node->r.base' becomes 'tmp' when start == 0.
* Record this by setting 0x8000 so it can be freed later.
*/
if (start == 0)
toffset |= 0x8000;
node->offset = toffset;
dns_name_toregion(&tname, &node->r);
dns_name_init(&node->name, NULL);
node->name.length = node->r.length;
node->name.ndata = node->r.base;
node->name.labels = tname.labels;
node->name.attributes = DNS_NAMEATTR_ABSOLUTE;
node->next = cctx->table[i];
cctx->table[i] = node;
start++;
n--;
count--;
}
if (start == 0)
isc_mem_put(cctx->mctx, tmp, length);
}
示例15: dns_ncache_getrdataset
isc_result_t
dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
dns_rdatatype_t type, dns_rdataset_t *rdataset)
{
isc_result_t result;
dns_rdata_t rdata = DNS_RDATA_INIT;
isc_region_t remaining;
isc_buffer_t source;
dns_name_t tname;
dns_rdatatype_t ttype;
dns_trust_t trust = dns_trust_none;
dns_rdataset_t clone;
REQUIRE(ncacherdataset != NULL);
REQUIRE(ncacherdataset->type == 0);
REQUIRE((ncacherdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0);
REQUIRE(name != NULL);
REQUIRE(!dns_rdataset_isassociated(rdataset));
REQUIRE(type != dns_rdatatype_rrsig);
dns_rdataset_init(&clone);
dns_rdataset_clone(ncacherdataset, &clone);
result = dns_rdataset_first(&clone);
while (result == ISC_R_SUCCESS) {
dns_rdataset_current(&clone, &rdata);
isc_buffer_init(&source, rdata.data, rdata.length);
isc_buffer_add(&source, rdata.length);
dns_name_init(&tname, NULL);
isc_buffer_remainingregion(&source, &remaining);
dns_name_fromregion(&tname, &remaining);
INSIST(remaining.length >= tname.length);
isc_buffer_forward(&source, tname.length);
remaining.length -= tname.length;
INSIST(remaining.length >= 3);
ttype = isc_buffer_getuint16(&source);
if (ttype == type && dns_name_equal(&tname, name)) {
trust = isc_buffer_getuint8(&source);
INSIST(trust <= dns_trust_ultimate);
isc_buffer_remainingregion(&source, &remaining);
break;
}
result = dns_rdataset_next(&clone);
dns_rdata_reset(&rdata);
}
dns_rdataset_disassociate(&clone);
if (result == ISC_R_NOMORE)
return (ISC_R_NOTFOUND);
if (result != ISC_R_SUCCESS)
return (result);
INSIST(remaining.length != 0);
rdataset->methods = &rdataset_methods;
rdataset->rdclass = ncacherdataset->rdclass;
rdataset->type = type;
rdataset->covers = 0;
rdataset->ttl = ncacherdataset->ttl;
rdataset->trust = trust;
rdataset->private1 = NULL;
rdataset->private2 = NULL;
rdataset->private3 = remaining.base;
/*
* Reset iterator state.
*/
rdataset->privateuint4 = 0;
rdataset->private5 = NULL;
rdataset->private6 = NULL;
return (ISC_R_SUCCESS);
}