本文整理汇总了C++中dns_compress_setmethods函数的典型用法代码示例。如果您正苦于以下问题:C++ dns_compress_setmethods函数的具体用法?C++ dns_compress_setmethods怎么用?C++ dns_compress_setmethods使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dns_compress_setmethods函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: towire_rp
static inline isc_result_t
towire_rp(ARGS_TOWIRE) {
isc_region_t region;
dns_name_t rmail;
dns_name_t email;
dns_offsets_t roffsets;
dns_offsets_t eoffsets;
REQUIRE(rdata->type == dns_rdatatype_rp);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&rmail, roffsets);
dns_name_init(&email, eoffsets);
dns_rdata_toregion(rdata, ®ion);
dns_name_fromregion(&rmail, ®ion);
isc_region_consume(®ion, rmail.length);
RETERR(dns_name_towire(&rmail, cctx, target));
dns_name_fromregion(&rmail, ®ion);
isc_region_consume(®ion, rmail.length);
return (dns_name_towire(&rmail, cctx, target));
}
示例2: towire_in_px
static inline isc_result_t
towire_in_px(ARGS_TOWIRE) {
dns_name_t name;
dns_offsets_t offsets;
isc_region_t region;
REQUIRE(rdata->type == dns_rdatatype_px);
REQUIRE(rdata->rdclass == dns_rdataclass_in);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/*
* Preference.
*/
dns_rdata_toregion(rdata, ®ion);
RETERR(mem_tobuffer(target, region.base, 2));
isc_region_consume(®ion, 2);
/*
* MAP822.
*/
dns_name_init(&name, offsets);
dns_name_fromregion(&name, ®ion);
RETERR(dns_name_towire(&name, cctx, target));
isc_region_consume(®ion, name_length(&name));
/*
* MAPX400.
*/
dns_name_init(&name, offsets);
dns_name_fromregion(&name, ®ion);
return (dns_name_towire(&name, cctx, target));
}
示例3: towire_soa
static inline isc_result_t
towire_soa(ARGS_TOWIRE) {
isc_region_t sregion;
isc_region_t tregion;
dns_name_t mname;
dns_name_t rname;
dns_offsets_t moffsets;
dns_offsets_t roffsets;
REQUIRE(rdata->type == 6);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
dns_name_init(&mname, moffsets);
dns_name_init(&rname, roffsets);
dns_rdata_toregion(rdata, &sregion);
dns_name_fromregion(&mname, &sregion);
isc_region_consume(&sregion, name_length(&mname));
RETERR(dns_name_towire(&mname, cctx, target));
dns_name_fromregion(&rname, &sregion);
isc_region_consume(&sregion, name_length(&rname));
RETERR(dns_name_towire(&rname, cctx, target));
isc_buffer_availableregion(target, &tregion);
if (tregion.length < 20)
return (ISC_R_NOSPACE);
memmove(tregion.base, sregion.base, 20);
isc_buffer_add(target, 20);
return (ISC_R_SUCCESS);
}
示例4: towire_dname
static inline isc_result_t
towire_dname(ARGS_TOWIRE) {
dns_name_t name;
dns_offsets_t offsets;
isc_region_t region;
REQUIRE(rdata->type == 39);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
dns_name_init(&name, offsets);
dns_rdata_toregion(rdata, ®ion);
dns_name_fromregion(&name, ®ion);
return (dns_name_towire(&name, cctx, target));
}
示例5: towire_naptr
static inline isc_result_t
towire_naptr(ARGS_TOWIRE) {
dns_name_t name;
dns_offsets_t offsets;
isc_region_t sr;
REQUIRE(rdata->type == dns_rdatatype_naptr);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/*
* Order, preference.
*/
dns_rdata_toregion(rdata, &sr);
RETERR(mem_tobuffer(target, sr.base, 4));
isc_region_consume(&sr, 4);
/*
* Flags.
*/
RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
isc_region_consume(&sr, sr.base[0] + 1);
/*
* Service.
*/
RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
isc_region_consume(&sr, sr.base[0] + 1);
/*
* Regexp.
*/
RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
isc_region_consume(&sr, sr.base[0] + 1);
/*
* Replacement.
*/
dns_name_init(&name, offsets);
dns_name_fromregion(&name, &sr);
return (dns_name_towire(&name, cctx, target));
}
示例6: towire_tkey
static inline isc_result_t
towire_tkey(ARGS_TOWIRE) {
isc_region_t sr;
dns_name_t name;
dns_offsets_t offsets;
REQUIRE(rdata->type == 249);
REQUIRE(rdata->length != 0);
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
/*
* Algorithm.
*/
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 (mem_tobuffer(target, sr.base, sr.length));
}
示例7: 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));
}
示例8: 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));
}
示例9: 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));
}
示例10: dns_ncache_towire
isc_result_t
dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
isc_buffer_t *target, unsigned int options,
unsigned int *countp)
{
dns_rdata_t rdata = DNS_RDATA_INIT;
isc_result_t result;
isc_region_t remaining, tavailable;
isc_buffer_t source, savedbuffer, rdlen;
dns_name_t name;
dns_rdatatype_t type;
unsigned int i, rcount, count;
/*
* Convert the negative caching rdataset 'rdataset' to wire format,
* compressing names as specified in 'cctx', and storing the result in
* 'target'.
*/
REQUIRE(rdataset != NULL);
REQUIRE(rdataset->type == 0);
REQUIRE((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0);
savedbuffer = *target;
count = 0;
result = dns_rdataset_first(rdataset);
while (result == ISC_R_SUCCESS) {
dns_rdataset_current(rdataset, &rdata);
isc_buffer_init(&source, rdata.data, rdata.length);
isc_buffer_add(&source, rdata.length);
dns_name_init(&name, NULL);
isc_buffer_remainingregion(&source, &remaining);
dns_name_fromregion(&name, &remaining);
INSIST(remaining.length >= name.length);
isc_buffer_forward(&source, name.length);
remaining.length -= name.length;
INSIST(remaining.length >= 5);
type = isc_buffer_getuint16(&source);
isc_buffer_forward(&source, 1);
rcount = isc_buffer_getuint16(&source);
for (i = 0; i < rcount; i++) {
/*
* Get the length of this rdata and set up an
* rdata structure for it.
*/
isc_buffer_remainingregion(&source, &remaining);
INSIST(remaining.length >= 2);
dns_rdata_reset(&rdata);
rdata.length = isc_buffer_getuint16(&source);
isc_buffer_remainingregion(&source, &remaining);
rdata.data = remaining.base;
rdata.type = type;
rdata.rdclass = rdataset->rdclass;
INSIST(remaining.length >= rdata.length);
isc_buffer_forward(&source, rdata.length);
if ((options & DNS_NCACHETOWIRE_OMITDNSSEC) != 0 &&
dns_rdatatype_isdnssec(type))
continue;
/*
* Write the name.
*/
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
result = dns_name_towire(&name, cctx, target);
if (result != ISC_R_SUCCESS)
goto rollback;
/*
* See if we have space for type, class, ttl, and
* rdata length. Write the type, class, and ttl.
*/
isc_buffer_availableregion(target, &tavailable);
if (tavailable.length < 10) {
result = ISC_R_NOSPACE;
goto rollback;
}
isc_buffer_putuint16(target, type);
isc_buffer_putuint16(target, rdataset->rdclass);
isc_buffer_putuint32(target, rdataset->ttl);
/*
* Save space for rdata length.
*/
rdlen = *target;
isc_buffer_add(target, 2);
/*
* Write the rdata.
*/
result = dns_rdata_towire(&rdata, cctx, target);
if (result != ISC_R_SUCCESS)
goto rollback;
/*
* Set the rdata length field to the compressed
* length.
//.........这里部分代码省略.........
示例11: towiresorted
//.........这里部分代码省略.........
*/
/* mark if is answer data. */
is_no_auth_answer = 0;
/* Answer from a non-authoritative server,we set the ttl fixed as 500. */
if(rdataset->attributes == DNS_RDATASETATTR_LOADORDER &&
rdataset->type == dns_rdatatype_a){
/* Answer from a non-authoritative server,we set the ttl fixed as 500. */
if(rdataset->trust == dns_trust_answer ){
is_no_auth_answer = 1;
}
/* for all multi-ip answer,if set DNS_ANSWER_ONLY_ONE_IP flag, return only 1 ip. */
if(answer_count == 0){
answer_count ++;
}else{
if( DNS_ANSWER_ONLY_ONE_IP ){
//fprintf(stderr,"DNS_ANSWER_ONLY_ONE_IP set,skip. \n");
if (shuffle) {
tmp_count--;
if (i == tmp_count)
result = ISC_R_NOMORE;
else
result = ISC_R_SUCCESS;
} else {
result = dns_rdataset_next(rdataset);
}
continue;
}
}
}
rrbuffer = *target;
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
result = dns_name_towire(owner_name, cctx, target);
if (result != ISC_R_SUCCESS)
goto rollback;
headlen = sizeof(dns_rdataclass_t) + sizeof(dns_rdatatype_t);
if (!question)
headlen += sizeof(dns_ttl_t)
+ 2; /* XXX 2 for rdata len */
isc_buffer_availableregion(target, &r);
if (r.length < headlen) {
result = ISC_R_NOSPACE;
goto rollback;
}
isc_buffer_putuint16(target, rdataset->type);
isc_buffer_putuint16(target, rdataset->rdclass);
if (!question) {
if( is_no_auth_answer ){
isc_buffer_putuint32(target, DNS_DEFAULT_TTL_FOR_NO_AUTH_NAME);
}else{
isc_buffer_putuint32(target, rdataset->ttl);
}
//fprintf(stderr,"xxxxxxxxx:trust : %d artr: %d ttl:%d cover: %d type: %d count: %d class: %d\n", rdataset->trust,rdataset->attributes,rdataset->ttl, rdataset->covers,rdataset->type, rdataset->count, rdataset->rdclass);
/*
* Save space for rdlen.
*/
rdlen = *target;
isc_buffer_add(target, 2);
/*
* Copy out the rdata
示例12: ATF_TC_BODY
ATF_TC_BODY(send, tc) {
isc_result_t result;
dns_dtenv_t *dtenv = NULL;
dns_dthandle_t handle;
isc_uint8_t *data;
size_t dsize;
unsigned char zone[DNS_NAME_MAXWIRE];
unsigned char qambuffer[4096], rambuffer[4096];
unsigned char qrmbuffer[4096], rrmbuffer[4096];
isc_buffer_t zb, qamsg, ramsg, qrmsg, rrmsg;
size_t qasize, qrsize, rasize, rrsize;
dns_fixedname_t zfname;
dns_name_t *zname;
dns_dtmsgtype_t dt;
dns_view_t *view = NULL;
dns_compress_t cctx;
isc_region_t zr;
isc_sockaddr_t addr;
struct in_addr in;
isc_stdtime_t now;
isc_time_t p, f;
UNUSED(tc);
cleanup();
result = dns_test_begin(NULL, ISC_TRUE);
ATF_REQUIRE(result == ISC_R_SUCCESS);
result = dns_test_makeview("test", &view);
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, 1, &dtenv);
ATF_REQUIRE(result == ISC_R_SUCCESS);
dns_dt_attach(dtenv, &view->dtenv);
view->dttypes = DNS_DTTYPE_ALL;
/*
* Set up some test data
*/
dns_fixedname_init(&zfname);
zname = dns_fixedname_name(&zfname);
isc_buffer_constinit(&zb, "example.com.", 12);
isc_buffer_add(&zb, 12);
result = dns_name_fromtext(zname, &zb, NULL, 0, NULL);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
memset(&zr, 0, sizeof(zr));
isc_buffer_init(&zb, zone, sizeof(zone));
result = dns_compress_init(&cctx, -1, mctx);
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
result = dns_name_towire(zname, &cctx, &zb);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
dns_compress_invalidate(&cctx);
isc_buffer_usedregion(&zb, &zr);
in.s_addr = inet_addr("10.53.0.1");
isc_sockaddr_fromin(&addr, &in, 2112);
isc_stdtime_get(&now);
isc_time_set(&p, now - 3600, 0); /* past */
isc_time_set(&f, now + 3600, 0); /* future */
result = dns_test_getdata("testdata/dnstap/query.auth",
qambuffer, sizeof(qambuffer), &qasize);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_buffer_init(&qamsg, qambuffer, qasize);
isc_buffer_add(&qamsg, qasize);
result = dns_test_getdata("testdata/dnstap/response.auth",
rambuffer, sizeof(rambuffer), &rasize);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_buffer_init(&ramsg, rambuffer, rasize);
isc_buffer_add(&ramsg, rasize);
result = dns_test_getdata("testdata/dnstap/query.recursive", qrmbuffer,
sizeof(qrmbuffer), &qrsize);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_buffer_init(&qrmsg, qrmbuffer, qrsize);
isc_buffer_add(&qrmsg, qrsize);
result = dns_test_getdata("testdata/dnstap/response.recursive",
rrmbuffer, sizeof(rrmbuffer), &rrsize);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_buffer_init(&rrmsg, rrmbuffer, rrsize);
isc_buffer_add(&rrmsg, rrsize);
for (dt = DNS_DTTYPE_SQ; dt <= DNS_DTTYPE_TR; dt <<= 1) {
isc_buffer_t *m;
switch (dt) {
case DNS_DTTYPE_AQ:
m = &qamsg;
break;
case DNS_DTTYPE_AR:
m = &ramsg;
break;
default:
m = &qrmsg;
if ((dt & DNS_DTTYPE_RESPONSE) != 0)
//.........这里部分代码省略.........
示例13: test
void
test(unsigned int allowed, dns_name_t *name1, dns_name_t *name2,
dns_name_t *name3, unsigned char *result, unsigned int length)
{
isc_mem_t *mctx = NULL;
dns_compress_t cctx;
dns_decompress_t dctx;
isc_buffer_t source;
isc_buffer_t target;
dns_name_t name;
unsigned char buf1[1024];
unsigned char buf2[1024];
if (verbose) {
const char *s;
switch (allowed) {
case DNS_COMPRESS_NONE: s = "DNS_COMPRESS_NONE"; break;
case DNS_COMPRESS_GLOBAL14: s = "DNS_COMPRESS_GLOBAL14"; break;
/* case DNS_COMPRESS_ALL: s = "DNS_COMPRESS_ALL"; break; */
default: s = "UNKNOWN"; break;
}
fprintf(stdout, "Allowed = %s\n", s);
}
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_buffer_init(&source, buf1, sizeof(buf1));
RUNTIME_CHECK(dns_compress_init(&cctx, -1, mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_name_towire(name1, &cctx, &source) == ISC_R_SUCCESS);
/*
RUNTIME_CHECK(dns_compress_localinit(&cctx, name1, &source) ==
ISC_R_SUCCESS);
*/
dns_compress_setmethods(&cctx, allowed);
RUNTIME_CHECK(dns_name_towire(name2, &cctx, &source) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_name_towire(name2, &cctx, &source) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_name_towire(name3, &cctx, &source) == ISC_R_SUCCESS);
/*
dns_compress_localinvalidate(&cctx);
*/
dns_compress_rollback(&cctx, 0); /* testing only */
dns_compress_invalidate(&cctx);
if (raw) {
unsigned int i;
for (i = 0; i < source.used; /* */ ) {
fprintf(stdout, "%02x",
((unsigned char *)source.base)[i]);
if ((++i % 20) == 0)
fputs("\n", stdout);
else
if (i == source.used)
fputs("\n", stdout);
else
fputs(" ", stdout);
}
}
isc_buffer_setactive(&source, source.used);
isc_buffer_init(&target, buf2, sizeof(buf2));
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
dns_name_init(&name, NULL);
RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE,
&target) == ISC_R_SUCCESS);
dns_decompress_setmethods(&dctx, allowed);
/*
dns_decompress_localinit(&dctx, &name, &source);
*/
RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE,
&target) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE,
&target) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE,
&target) == ISC_R_SUCCESS);
/*
dns_decompress_localinvalidate(&dctx);
*/
dns_decompress_invalidate(&dctx);
if (raw) {
unsigned int i;
for (i = 0; i < target.used; /* */ ) {
fprintf(stdout, "%02x",
((unsigned char *)target.base)[i]);
if ((++i % 20) == 0)
fputs("\n", stdout);
else
if (i == target.used)
fputs("\n", stdout);
else
fputs(" ", stdout);
}
fputs("\n", stdout);
fflush(stdout);
}
RUNTIME_CHECK(target.used == length);
RUNTIME_CHECK(memcmp(target.base, result, target.used) == 0);
//.........这里部分代码省略.........