本文整理汇总了C++中dns_rdataset_init函数的典型用法代码示例。如果您正苦于以下问题:C++ dns_rdataset_init函数的具体用法?C++ dns_rdataset_init怎么用?C++ dns_rdataset_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dns_rdataset_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_event
static isc_result_t
build_event(dns_lookup_t *lookup) {
dns_name_t *name = NULL;
dns_rdataset_t *rdataset = NULL;
dns_rdataset_t *sigrdataset = NULL;
isc_result_t result;
name = isc_mem_get(lookup->mctx, sizeof(dns_name_t));
if (name == NULL) {
result = ISC_R_NOMEMORY;
goto fail;
}
dns_name_init(name, NULL);
result = dns_name_dup(dns_fixedname_name(&lookup->name),
lookup->mctx, name);
if (result != ISC_R_SUCCESS)
goto fail;
if (dns_rdataset_isassociated(&lookup->rdataset)) {
rdataset = isc_mem_get(lookup->mctx, sizeof(dns_rdataset_t));
if (rdataset == NULL) {
result = ISC_R_NOMEMORY;
goto fail;
}
dns_rdataset_init(rdataset);
dns_rdataset_clone(&lookup->rdataset, rdataset);
}
if (dns_rdataset_isassociated(&lookup->sigrdataset)) {
sigrdataset = isc_mem_get(lookup->mctx,
sizeof(dns_rdataset_t));
if (sigrdataset == NULL) {
result = ISC_R_NOMEMORY;
goto fail;
}
dns_rdataset_init(sigrdataset);
dns_rdataset_clone(&lookup->sigrdataset, sigrdataset);
}
lookup->event->name = name;
lookup->event->rdataset = rdataset;
lookup->event->sigrdataset = sigrdataset;
return (ISC_R_SUCCESS);
fail:
if (name != NULL) {
if (dns_name_dynamic(name))
dns_name_free(name, lookup->mctx);
isc_mem_put(lookup->mctx, name, sizeof(dns_name_t));
}
if (rdataset != NULL) {
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
isc_mem_put(lookup->mctx, rdataset, sizeof(dns_rdataset_t));
}
return (result);
}
示例2: sendquery
static isc_result_t
sendquery(isc_task_t *task) {
dns_request_t *request;
dns_message_t *message;
dns_name_t *qname;
dns_rdataset_t *qrdataset;
isc_result_t result;
dns_fixedname_t queryname;
isc_buffer_t buf;
static char host[256];
int c;
c = scanf("%255s", host);
if (c == EOF)
return ISC_R_NOMORE;
onfly++;
dns_fixedname_init(&queryname);
isc_buffer_init(&buf, host, strlen(host));
isc_buffer_add(&buf, strlen(host));
result = dns_name_fromtext(dns_fixedname_name(&queryname), &buf,
dns_rootname, 0, NULL);
CHECK("dns_name_fromtext", result);
message = NULL;
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
CHECK("dns_message_create", result);
message->opcode = dns_opcode_query;
message->flags |= DNS_MESSAGEFLAG_RD;
message->rdclass = dns_rdataclass_in;
message->id = (unsigned short)(random() & 0xFFFF);
qname = NULL;
result = dns_message_gettempname(message, &qname);
CHECK("dns_message_gettempname", result);
qrdataset = NULL;
result = dns_message_gettemprdataset(message, &qrdataset);
CHECK("dns_message_gettemprdataset", result);
dns_name_init(qname, NULL);
dns_name_clone(dns_fixedname_name(&queryname), qname);
dns_rdataset_init(qrdataset);
dns_rdataset_makequestion(qrdataset, dns_rdataclass_in,
dns_rdatatype_a);
ISC_LIST_APPEND(qname->list, qrdataset, link);
dns_message_addname(message, qname, DNS_SECTION_QUESTION);
request = NULL;
result = dns_request_createvia(requestmgr, message,
have_src ? &srcaddr : NULL, &dstaddr,
DNS_REQUESTOPT_TCP|DNS_REQUESTOPT_SHARE,
NULL, TIMEOUT, task, recvresponse,
message, &request);
CHECK("dns_request_create", result);
return ISC_R_SUCCESS;
}
示例3: deleterdataset
static void
deleterdataset(isc_assertioncallback_t callback) {
isc_result_t result;
dns_rdataset_t rdataset;
dns_fixedname_t fixed;
dns_dbnode_t *node = NULL;
result = dns_test_begin(NULL, ISC_FALSE);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
setup_db();
dns_rdataset_init(&rdataset);
dns_fixedname_init(&fixed);
result = dns_db_findnode(db1, dns_rootname, ISC_FALSE, &node);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_assertion_setcallback(callback);
result = dns_db_deleterdataset(db1, node, VERSION(callback),
dns_rdatatype_soa, 0);
if (callback != NULL)
atf_tc_fail("dns_db_deleterdataset did not assert");
ATF_REQUIRE_EQ(result, DNS_R_UNCHANGED);
dns_db_detachnode(db1, &node);
ATF_REQUIRE_EQ(node, NULL);
close_db();
dns_test_end();
}
示例4: add_rdata_to_list
static isc_result_t
add_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata,
isc_uint32_t ttl, dns_namelist_t *namelist)
{
isc_result_t result;
isc_region_t r, newr;
dns_rdata_t *newrdata = NULL;
dns_name_t *newname = NULL;
dns_rdatalist_t *newlist = NULL;
dns_rdataset_t *newset = NULL;
isc_buffer_t *tmprdatabuf = NULL;
RETERR(dns_message_gettemprdata(msg, &newrdata));
dns_rdata_toregion(rdata, &r);
RETERR(isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length));
isc_buffer_availableregion(tmprdatabuf, &newr);
memcpy(newr.base, r.base, r.length);
dns_rdata_fromregion(newrdata, rdata->rdclass, rdata->type, &newr);
dns_message_takebuffer(msg, &tmprdatabuf);
RETERR(dns_message_gettempname(msg, &newname));
dns_name_init(newname, NULL);
RETERR(dns_name_dup(name, msg->mctx, newname));
RETERR(dns_message_gettemprdatalist(msg, &newlist));
newlist->rdclass = newrdata->rdclass;
newlist->type = newrdata->type;
newlist->covers = 0;
newlist->ttl = ttl;
ISC_LIST_INIT(newlist->rdata);
ISC_LIST_APPEND(newlist->rdata, newrdata, link);
RETERR(dns_message_gettemprdataset(msg, &newset));
dns_rdataset_init(newset);
RETERR(dns_rdatalist_tordataset(newlist, newset));
ISC_LIST_INIT(newname->list);
ISC_LIST_APPEND(newname->list, newset, link);
ISC_LIST_APPEND(*namelist, newname, link);
return (ISC_R_SUCCESS);
failure:
if (newrdata != NULL) {
if (ISC_LINK_LINKED(newrdata, link))
ISC_LIST_UNLINK(newlist->rdata, newrdata, link);
dns_message_puttemprdata(msg, &newrdata);
}
if (newname != NULL)
dns_message_puttempname(msg, &newname);
if (newset != NULL) {
dns_rdataset_disassociate(newset);
dns_message_puttemprdataset(msg, &newset);
}
if (newlist != NULL)
dns_message_puttemprdatalist(msg, &newlist);
return (result);
}
示例5: add_soa
/*
* Auxiliary functions add_*() create minimal database which can be loaded.
* This is necessary because this driver create empty 'fake' zone which
* is not loaded from disk so there is no way for user to supply SOA, NS and A
* records.
*
* Following functions were copied from BIND 9.10.2rc1 named/server.c,
* credit goes to ISC.
*/
static isc_result_t
add_soa(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name,
const dns_name_t *origin, const dns_name_t *contact)
{
dns_dbnode_t *node = NULL;
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdatalist_t rdatalist;
dns_rdataset_t rdataset;
isc_result_t result;
unsigned char buf[DNS_SOA_BUFFERSIZE];
dns_rdataset_init(&rdataset);
dns_rdatalist_init(&rdatalist);
CHECK(dns_soa_buildrdata(origin, contact, dns_db_class(db),
0, 28800, 7200, 604800, 86400, buf, &rdata));
rdatalist.type = rdata.type;
rdatalist.covers = 0;
rdatalist.rdclass = rdata.rdclass;
rdatalist.ttl = 86400;
ISC_LIST_APPEND(rdatalist.rdata, &rdata, link);
CHECK(dns_rdatalist_tordataset(&rdatalist, &rdataset));
CHECK(dns_db_findnode(db, name, ISC_TRUE, &node));
CHECK(dns_db_addrdataset(db, node, version, 0, &rdataset, 0, NULL));
cleanup:
if (node != NULL)
dns_db_detachnode(db, &node);
return (result);
}
示例6: dns_nsec_build
isc_result_t
dns_nsec_build(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
dns_name_t *target, dns_ttl_t ttl)
{
isc_result_t result;
dns_rdata_t rdata = DNS_RDATA_INIT;
unsigned char data[DNS_NSEC_BUFFERSIZE];
dns_rdatalist_t rdatalist;
dns_rdataset_t rdataset;
dns_rdataset_init(&rdataset);
dns_rdata_init(&rdata);
RETERR(dns_nsec_buildrdata(db, version, node, target, data, &rdata));
rdatalist.rdclass = dns_db_class(db);
rdatalist.type = dns_rdatatype_nsec;
rdatalist.covers = 0;
rdatalist.ttl = ttl;
ISC_LIST_INIT(rdatalist.rdata);
ISC_LIST_APPEND(rdatalist.rdata, &rdata, link);
RETERR(dns_rdatalist_tordataset(&rdatalist, &rdataset));
result = dns_db_addrdataset(db, node, version, 0, &rdataset,
0, NULL);
if (result == DNS_R_UNCHANGED)
result = ISC_R_SUCCESS;
RETERR(result);
failure:
if (dns_rdataset_isassociated(&rdataset))
dns_rdataset_disassociate(&rdataset);
return (result);
}
示例7: check_node
static isc_result_t
check_node(dns_rdataset_t *rootns, dns_name_t *name,
dns_rdatasetiter_t *rdsiter) {
isc_result_t result;
dns_rdataset_t rdataset;
dns_rdataset_init(&rdataset);
result = dns_rdatasetiter_first(rdsiter);
while (result == ISC_R_SUCCESS) {
dns_rdatasetiter_current(rdsiter, &rdataset);
switch (rdataset.type) {
case dns_rdatatype_a:
case dns_rdatatype_aaaa:
result = in_rootns(rootns, name);
if (result != ISC_R_SUCCESS)
goto cleanup;
break;
case dns_rdatatype_ns:
if (dns_name_compare(name, dns_rootname) == 0)
break;
/*FALLTHROUGH*/
default:
result = ISC_R_FAILURE;
goto cleanup;
}
dns_rdataset_disassociate(&rdataset);
result = dns_rdatasetiter_next(rdsiter);
}
if (result == ISC_R_NOMORE)
result = ISC_R_SUCCESS;
cleanup:
if (dns_rdataset_isassociated(&rdataset))
dns_rdataset_disassociate(&rdataset);
return (result);
}
示例8: find
static void
find(isc_assertioncallback_t callback) {
isc_result_t result;
dns_rdataset_t rdataset;
dns_fixedname_t fixed;
result = dns_test_begin(NULL, ISC_FALSE);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
setup_db();
dns_rdataset_init(&rdataset);
dns_fixedname_init(&fixed);
isc_assertion_setcallback(callback);
result = dns_db_find(db1, dns_rootname, VERSION(callback),
dns_rdatatype_soa, 0, 0, NULL,
dns_fixedname_name(&fixed), &rdataset, NULL);
if (callback != NULL)
atf_tc_fail("dns_db_find did not assert");
ATF_REQUIRE_EQ(result, DNS_R_NXDOMAIN);
close_db();
dns_test_end();
}
示例9: make_querymessage
/*
* Common routine to make query data
*/
static isc_result_t
make_querymessage(dns_message_t *message, dns_name_t *qname0,
dns_rdatatype_t rdtype)
{
dns_name_t *qname = NULL;
dns_rdataset_t *qrdataset = NULL;
isc_result_t result;
message->opcode = dns_opcode_query;
message->rdclass = dns_rdataclass_in;
result = dns_message_gettempname(message, &qname);
if (result != ISC_R_SUCCESS)
goto cleanup;
result = dns_message_gettemprdataset(message, &qrdataset);
if (result != ISC_R_SUCCESS)
goto cleanup;
dns_name_init(qname, NULL);
dns_name_clone(qname0, qname);
dns_rdataset_init(qrdataset);
dns_rdataset_makequestion(qrdataset, message->rdclass, rdtype);
ISC_LIST_APPEND(qname->list, qrdataset, link);
dns_message_addname(message, qname, DNS_SECTION_QUESTION);
return (ISC_R_SUCCESS);
cleanup:
if (qname != NULL)
dns_message_puttempname(message, &qname);
if (qrdataset != NULL)
dns_message_puttemprdataset(message, &qrdataset);
return (result);
}
示例10: add_a
static isc_result_t
add_a(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name,
struct in_addr addr)
{
dns_dbnode_t *node = NULL;
dns_rdata_in_a_t a;
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdatalist_t rdatalist;
dns_rdataset_t rdataset;
isc_result_t result;
isc_buffer_t b;
unsigned char buf[DNS_NAME_MAXWIRE];
isc_buffer_init(&b, buf, sizeof(buf));
dns_rdataset_init(&rdataset);
dns_rdatalist_init(&rdatalist);
a.common.rdtype = dns_rdatatype_a;
a.common.rdclass = dns_db_class(db);
a.in_addr = addr;
CHECK(dns_rdata_fromstruct(&rdata, dns_db_class(db), dns_rdatatype_a,
&a, &b));
rdatalist.type = rdata.type;
rdatalist.covers = 0;
rdatalist.rdclass = rdata.rdclass;
rdatalist.ttl = 86400;
ISC_LIST_APPEND(rdatalist.rdata, &rdata, link);
CHECK(dns_rdatalist_tordataset(&rdatalist, &rdataset));
CHECK(dns_db_findnode(db, name, ISC_TRUE, &node));
CHECK(dns_db_addrdataset(db, node, version, 0, &rdataset, 0, NULL));
cleanup:
if (node != NULL)
dns_db_detachnode(db, &node);
return (result);
}
示例11: loadkeyset
static isc_result_t
loadkeyset(char *dirname, dns_rdataset_t *rdataset) {
isc_result_t result;
char filename[PATH_MAX + 1];
isc_buffer_t buf;
dns_rdataset_init(rdataset);
isc_buffer_init(&buf, filename, sizeof(filename));
if (dirname != NULL) {
/* allow room for a trailing slash */
if (strlen(dirname) >= isc_buffer_availablelength(&buf))
return (ISC_R_NOSPACE);
isc_buffer_putstr(&buf, dirname);
if (dirname[strlen(dirname) - 1] != '/')
isc_buffer_putstr(&buf, "/");
}
if (isc_buffer_availablelength(&buf) < 7)
return (ISC_R_NOSPACE);
isc_buffer_putstr(&buf, "keyset-");
result = dns_name_tofilenametext(name, ISC_FALSE, &buf);
check_result(result, "dns_name_tofilenametext()");
if (isc_buffer_availablelength(&buf) == 0)
return (ISC_R_NOSPACE);
isc_buffer_putuint8(&buf, 0);
return (loadsetfromfile(filename, rdataset));
}
示例12: make_querymessage
static isc_result_t
make_querymessage(dns_message_t *message, const char *namestr,
dns_rdatatype_t rdtype)
{
dns_name_t *qname = NULL, *qname0;
dns_rdataset_t *qrdataset = NULL;
isc_result_t result;
isc_buffer_t b;
unsigned int namelen;
REQUIRE(message != NULL);
REQUIRE(namestr != NULL);
/* Construct qname */
namelen = strlen(namestr);
isc_buffer_constinit(&b, namestr, namelen);
isc_buffer_add(&b, namelen);
dns_fixedname_init(&fixedqname);
qname0 = dns_fixedname_name(&fixedqname);
result = dns_name_fromtext(qname0, &b, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "failed to convert qname: %d\n", result);
return (result);
}
/* Construct query message */
message->opcode = dns_opcode_query;
message->rdclass = dns_rdataclass_in;
result = dns_message_gettempname(message, &qname);
if (result != ISC_R_SUCCESS)
goto cleanup;
result = dns_message_gettemprdataset(message, &qrdataset);
if (result != ISC_R_SUCCESS)
goto cleanup;
dns_name_init(qname, NULL);
dns_name_clone(qname0, qname);
dns_rdataset_init(qrdataset);
dns_rdataset_makequestion(qrdataset, message->rdclass, rdtype);
ISC_LIST_APPEND(qname->list, qrdataset, link);
dns_message_addname(message, qname, DNS_SECTION_QUESTION);
return (ISC_R_SUCCESS);
cleanup:
if (qname != NULL)
dns_message_puttempname(message, &qname);
if (qrdataset != NULL)
dns_message_puttemprdataset(message, &qrdataset);
dns_message_destroy(&message);
return (result);
}
示例13: check_hints
static isc_result_t
check_hints(dns_db_t *db) {
isc_result_t result;
dns_rdataset_t rootns;
dns_dbiterator_t *dbiter = NULL;
dns_dbnode_t *node = NULL;
isc_stdtime_t now;
dns_fixedname_t fixname;
dns_name_t *name;
dns_rdatasetiter_t *rdsiter = NULL;
isc_stdtime_get(&now);
dns_fixedname_init(&fixname);
name = dns_fixedname_name(&fixname);
dns_rdataset_init(&rootns);
(void)dns_db_find(db, dns_rootname, NULL, dns_rdatatype_ns, 0,
now, NULL, name, &rootns, NULL);
result = dns_db_createiterator(db, 0, &dbiter);
if (result != ISC_R_SUCCESS)
goto cleanup;
result = dns_dbiterator_first(dbiter);
while (result == ISC_R_SUCCESS) {
result = dns_dbiterator_current(dbiter, &node, name);
if (result != ISC_R_SUCCESS)
goto cleanup;
result = dns_db_allrdatasets(db, node, NULL, now, &rdsiter);
if (result != ISC_R_SUCCESS)
goto cleanup;
result = check_node(&rootns, name, rdsiter);
if (result != ISC_R_SUCCESS)
goto cleanup;
dns_rdatasetiter_destroy(&rdsiter);
dns_db_detachnode(db, &node);
result = dns_dbiterator_next(dbiter);
}
if (result == ISC_R_NOMORE)
result = ISC_R_SUCCESS;
cleanup:
if (dns_rdataset_isassociated(&rootns))
dns_rdataset_disassociate(&rootns);
if (rdsiter != NULL)
dns_rdatasetiter_destroy(&rdsiter);
if (node != NULL)
dns_db_detachnode(db, &node);
if (dbiter != NULL)
dns_dbiterator_destroy(&dbiter);
return (result);
}
示例14: dns_nsec_nseconly
isc_result_t
dns_nsec_nseconly(dns_db_t *db, dns_dbversion_t *version,
isc_boolean_t *answer)
{
dns_dbnode_t *node = NULL;
dns_rdataset_t rdataset;
dns_rdata_dnskey_t dnskey;
isc_result_t result;
REQUIRE(answer != NULL);
dns_rdataset_init(&rdataset);
result = dns_db_getoriginnode(db, &node);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey,
0, 0, &rdataset, NULL);
dns_db_detachnode(db, &node);
if (result == ISC_R_NOTFOUND) {
*answer = ISC_FALSE;
return (ISC_R_SUCCESS);
}
if (result != ISC_R_SUCCESS)
return (result);
for (result = dns_rdataset_first(&rdataset);
result == ISC_R_SUCCESS;
result = dns_rdataset_next(&rdataset)) {
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdataset_current(&rdataset, &rdata);
result = dns_rdata_tostruct(&rdata, &dnskey, NULL);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
if (dnskey.algorithm == DST_ALG_RSAMD5 ||
dnskey.algorithm == DST_ALG_RSASHA1 ||
dnskey.algorithm == DST_ALG_DSA ||
dnskey.algorithm == DST_ALG_ECC)
break;
}
dns_rdataset_disassociate(&rdataset);
if (result == ISC_R_SUCCESS)
*answer = ISC_TRUE;
if (result == ISC_R_NOMORE) {
*answer = ISC_FALSE;
result = ISC_R_SUCCESS;
}
return (result);
}
示例15: log_rr
static void
log_rr(dns_name_t *name, dns_rdata_t *rdata, isc_uint32_t ttl) {
isc_result_t result;
isc_buffer_t buf;
char mem[2000];
dns_rdatalist_t rdl;
dns_rdataset_t rds;
dns_rdata_t rd = DNS_RDATA_INIT;
rdl.type = rdata->type;
rdl.rdclass = rdata->rdclass;
rdl.ttl = ttl;
if (rdata->type == dns_rdatatype_sig ||
rdata->type == dns_rdatatype_rrsig)
rdl.covers = dns_rdata_covers(rdata);
else
rdl.covers = dns_rdatatype_none;
ISC_LIST_INIT(rdl.rdata);
ISC_LINK_INIT(&rdl, link);
dns_rdataset_init(&rds);
dns_rdata_init(&rd);
dns_rdata_clone(rdata, &rd);
ISC_LIST_APPEND(rdl.rdata, &rd, link);
RUNTIME_CHECK(dns_rdatalist_tordataset(&rdl, &rds) == ISC_R_SUCCESS);
isc_buffer_init(&buf, mem, sizeof(mem));
result = dns_rdataset_totext(&rds, name,
ISC_FALSE, ISC_FALSE, &buf);
/*
* We could use xfrout_log(), but that would produce
* very long lines with a repetitive prefix.
*/
if (result == ISC_R_SUCCESS) {
/*
* Get rid of final newline.
*/
INSIST(buf.used >= 1 &&
((char *) buf.base)[buf.used - 1] == '\n');
buf.used--;
isc_log_write(XFROUT_RR_LOGARGS, "%.*s",
(int)isc_buffer_usedlength(&buf),
(char *)isc_buffer_base(&buf));
} else {
isc_log_write(XFROUT_RR_LOGARGS, "<RR too large to print>");
}
}