本文整理汇总了C++中dns_name_fromtext函数的典型用法代码示例。如果您正苦于以下问题:C++ dns_name_fromtext函数的具体用法?C++ dns_name_fromtext怎么用?C++ dns_name_fromtext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dns_name_fromtext函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: convert_name
static isc_result_t
convert_name(dns_fixedname_t *fn, dns_name_t **name, const char *text) {
isc_result_t result;
isc_buffer_t b;
dns_name_t *n;
unsigned int len;
REQUIRE(fn != NULL && name != NULL && text != NULL);
len = strlen(text);
isc_buffer_constinit(&b, text, len);
isc_buffer_add(&b, len);
dns_fixedname_init(fn);
n = dns_fixedname_name(fn);
result = dns_name_fromtext(n, &b, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS) {
delv_log(ISC_LOG_ERROR, "failed to convert QNAME %s: %s",
text, isc_result_totext(result));
return (result);
}
*name = n;
return (ISC_R_SUCCESS);
}
开发者ID:jaredmcneill,项目名称:netbsd-src,代码行数:25,代码来源:delv.c
示例2: setup_master
static isc_result_t
setup_master(void (*warn)(struct dns_rdatacallbacks *, const char *, ...),
void (*error)(struct dns_rdatacallbacks *, const char *, ...))
{
isc_result_t result;
int len;
isc_buffer_t source;
isc_buffer_t target;
strcpy(origin, TEST_ORIGIN);
len = strlen(origin);
isc_buffer_init(&source, origin, len);
isc_buffer_add(&source, len);
isc_buffer_setactive(&source, len);
isc_buffer_init(&target, name_buf, BUFLEN);
dns_name_init(&dns_origin, NULL);
dns_master_initrawheader(&header);
result = dns_name_fromtext(&dns_origin, &source, dns_rootname,
0, &target);
if (result != ISC_R_SUCCESS)
return(result);
dns_rdatacallbacks_init_stdio(&callbacks);
callbacks.add = add_callback;
callbacks.rawdata = rawdata_callback;
callbacks.zone = NULL;
if (warn != NULL)
callbacks.warn = warn;
if (error != NULL)
callbacks.error = error;
headerset = ISC_FALSE;
return (result);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:34,代码来源:master_test.c
示例3: add_test_data
/*
* Load test data into the RBT.
*/
static void
add_test_data(isc_mem_t *mymctx, dns_rbt_t *rbt) {
char buffer[1024];
isc_buffer_t b;
isc_result_t result;
dns_fixedname_t fname;
dns_name_t *name;
dns_compress_t cctx;
rbt_testdata_t *testdatap = testdata;
dns_compress_init(&cctx, -1, mymctx);
while (testdatap->name != NULL && testdatap->data.data != NULL) {
memmove(buffer, testdatap->name, testdatap->name_len);
isc_buffer_init(&b, buffer, testdatap->name_len);
isc_buffer_add(&b, testdatap->name_len);
dns_fixedname_init(&fname);
name = dns_fixedname_name(&fname);
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS) {
testdatap++;
continue;
}
if (name != NULL) {
result = dns_rbt_addname(rbt, name, &testdatap->data);
ATF_CHECK_STREQ(dns_result_totext(result), "success");
}
testdatap++;
}
dns_compress_invalidate(&cctx);
}
开发者ID:execunix,项目名称:vinos,代码行数:37,代码来源:rbt_serialize_test.c
示例4: select_db
static dbinfo *
select_db(char *origintext) {
dns_fixedname_t forigin;
dns_name_t *origin;
isc_buffer_t source;
size_t len;
dbinfo *dbi;
isc_result_t result;
if (strcasecmp(origintext, "cache") == 0) {
if (cache_dbi == NULL)
printf("the cache does not exist\n");
return (cache_dbi);
}
len = strlen(origintext);
isc_buffer_init(&source, origintext, len);
isc_buffer_add(&source, len);
dns_fixedname_init(&forigin);
origin = dns_fixedname_name(&forigin);
result = dns_name_fromtext(origin, &source, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS) {
print_result("bad name", result);
return (NULL);
}
for (dbi = ISC_LIST_HEAD(dbs);
dbi != NULL;
dbi = ISC_LIST_NEXT(dbi, link)) {
if (dns_name_compare(dns_db_origin(dbi->db), origin) == 0)
break;
}
return (dbi);
}
开发者ID:fatman2021,项目名称:netbsd-src,代码行数:34,代码来源:db_test.c
示例5: make_name
static isc_result_t
make_name(const char *src, dns_name_t *name) {
isc_buffer_t b;
isc_buffer_constinit(&b, src, strlen(src));
isc_buffer_add(&b, strlen(src));
return (dns_name_fromtext(name, &b, dns_rootname, 0, NULL));
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:7,代码来源:dbiterator_test.c
示例6: fromtext_ptr
static inline isc_result_t
fromtext_ptr(ARGS_FROMTEXT) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
REQUIRE(type == 12);
UNUSED(type);
UNUSED(rdclass);
UNUSED(callbacks);
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
if (rdclass == dns_rdataclass_in &&
(options & DNS_RDATA_CHECKNAMES) != 0 &&
(options & DNS_RDATA_CHECKREVERSE) != 0) {
isc_boolean_t ok;
ok = dns_name_ishostname(&name, ISC_FALSE);
if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0)
RETTOK(DNS_R_BADNAME);
if (!ok && callbacks != NULL)
warn_badname(&name, lexer, callbacks);
}
return (ISC_R_SUCCESS);
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:31,代码来源:ptr_12.c
示例7: fromtext_mx
static inline isc_result_t
fromtext_mx(ARGS_FROMTEXT) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
isc_boolean_t ok;
REQUIRE(type == 15);
UNUSED(type);
UNUSED(rdclass);
UNUSED(callbacks);
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
ISC_FALSE));
if (token.value.as_ulong > 0xffffU)
RETTOK(ISC_R_RANGE);
RETERR(uint16_tobuffer(token.value.as_ulong, target));
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
ok = ISC_TRUE;
if ((options & DNS_RDATA_CHECKNAMES) != 0)
ok = dns_name_ishostname(&name, ISC_FALSE);
if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0)
RETTOK(DNS_R_BADNAME);
if (!ok && callbacks != NULL)
warn_badname(&name, lexer, callbacks);
return (ISC_R_SUCCESS);
}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:34,代码来源:mx_15.c
示例8: fromtext_rp
static inline isc_result_t
fromtext_rp(ARGS_FROMTEXT) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
int i;
isc_boolean_t ok;
REQUIRE(type == 17);
UNUSED(type);
UNUSED(rdclass);
UNUSED(callbacks);
origin = (origin != NULL) ? origin : dns_rootname;
for (i = 0; i < 2; i++) {
RETERR(isc_lex_getmastertoken(lexer, &token,
isc_tokentype_string,
ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region);
RETTOK(dns_name_fromtext(&name, &buffer, origin,
options, target));
ok = ISC_TRUE;
if ((options & DNS_RDATA_CHECKNAMES) != 0 && i == 0)
ok = dns_name_ismailbox(&name);
if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0)
RETTOK(DNS_R_BADNAME);
if (!ok && callbacks != NULL)
warn_badname(&name, lexer, callbacks);
}
return (ISC_R_SUCCESS);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:34,代码来源:rp_17.c
示例9: set_nextqname
static isc_result_t
set_nextqname(struct probe_trans *trans) {
isc_result_t result;
size_t domainlen;
isc_buffer_t b;
char buf[4096]; /* XXX ad-hoc constant, but should be enough */
if (*trans->qlabel == NULL)
return (ISC_R_NOMORE);
result = isc_string_copy(buf, sizeof(buf), *trans->qlabel);
if (result != ISC_R_SUCCESS)
return (result);
result = isc_string_append(buf, sizeof(buf), trans->domain);
if (result != ISC_R_SUCCESS)
return (result);
domainlen = strlen(buf);
isc_buffer_init(&b, buf, domainlen);
isc_buffer_add(&b, domainlen);
dns_fixedname_init(&trans->fixedname);
trans->qname = dns_fixedname_name(&trans->fixedname);
result = dns_name_fromtext(trans->qname, &b, dns_rootname,
0, NULL);
trans->qlabel++;
return (result);
}
开发者ID:jhbsz,项目名称:netbsd,代码行数:29,代码来源:nsprobe.c
示例10: loadzone
/*%
* Load the zone file from disk
*/
static void
loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) {
isc_buffer_t b;
int len;
dns_fixedname_t fname;
dns_name_t *name;
isc_result_t result;
len = strlen(origin);
isc_buffer_init(&b, origin, len);
isc_buffer_add(&b, len);
dns_fixedname_init(&fname);
name = dns_fixedname_name(&fname);
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS)
fatal("failed converting name '%s' to dns format: %s",
origin, isc_result_totext(result));
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone,
rdclass, 0, NULL, db);
check_result(result, "dns_db_create()");
result = dns_db_load2(*db, file, inputformat);
if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE)
fatal("failed loading zone from '%s': %s",
file, isc_result_totext(result));
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:31,代码来源:dnssec-verify.c
示例11: fromtext_in_kx
static inline isc_result_t
fromtext_in_kx(ARGS_FROMTEXT) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
REQUIRE(type == 36);
REQUIRE(rdclass == 1);
UNUSED(type);
UNUSED(rdclass);
UNUSED(callbacks);
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
ISC_FALSE));
if (token.value.as_ulong > 0xffffU)
RETTOK(ISC_R_RANGE);
RETERR(uint16_tobuffer(token.value.as_ulong, target));
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
return (ISC_R_SUCCESS);
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:27,代码来源:kx_36.c
示例12: ATF_TC_BODY
ATF_TC_BODY(isc_dh_computesecret, tc) {
dst_key_t *key = NULL;
isc_buffer_t buf;
unsigned char array[1024];
isc_result_t ret;
dns_fixedname_t fname;
dns_name_t *name;
UNUSED(tc);
ret = dns_test_begin(NULL, ISC_FALSE);
ATF_REQUIRE_EQ(ret, ISC_R_SUCCESS);
dns_fixedname_init(&fname);
name = dns_fixedname_name(&fname);
isc_buffer_constinit(&buf, "dh.", 3);
isc_buffer_add(&buf, 3);
ret = dns_name_fromtext(name, &buf, NULL, 0, NULL);
ATF_REQUIRE_EQ(ret, ISC_R_SUCCESS);
ret = dst_key_fromfile(name, 18602, DST_ALG_DH,
DST_TYPE_PUBLIC | DST_TYPE_KEY,
"./", mctx, &key);
ATF_REQUIRE_EQ(ret, ISC_R_SUCCESS);
isc_buffer_init(&buf, array, sizeof(array));
ret = dst_key_computesecret(key, key, &buf);
ATF_REQUIRE_EQ(ret, DST_R_NOTPRIVATEKEY);
ret = key->func->computesecret(key, key, &buf);
ATF_REQUIRE_EQ(ret, DST_R_COMPUTESECRETFAILURE);
dst_key_free(&key);
dns_test_end();
}
开发者ID:execunix,项目名称:vinos,代码行数:34,代码来源:dh_test.c
示例13: dns_peer_setkeybycharp
isc_result_t
dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval) {
isc_buffer_t b;
dns_fixedname_t fname;
dns_name_t *name;
isc_result_t result;
dns_fixedname_init(&fname);
isc_buffer_constinit(&b, keyval, strlen(keyval));
isc_buffer_add(&b, strlen(keyval));
result = dns_name_fromtext(dns_fixedname_name(&fname), &b,
dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS)
return (result);
name = isc_mem_get(peer->mem, sizeof(dns_name_t));
if (name == NULL)
return (ISC_R_NOMEMORY);
dns_name_init(name, NULL);
result = dns_name_dup(dns_fixedname_name(&fname), peer->mem, name);
if (result != ISC_R_SUCCESS) {
isc_mem_put(peer->mem, name, sizeof(dns_name_t));
return (result);
}
result = dns_peer_setkey(peer, &name);
if (result != ISC_R_SUCCESS)
isc_mem_put(peer->mem, name, sizeof(dns_name_t));
return (result);
}
开发者ID:jhbsz,项目名称:netbsd,代码行数:32,代码来源:peer.c
示例14: make_zone
static isc_result_t
make_zone(const char *name, dns_zone_t **zonep) {
isc_result_t result;
dns_view_t *view = NULL;
dns_zone_t *zone = NULL;
isc_buffer_t buffer;
dns_fixedname_t fixorigin;
dns_name_t *origin;
CHECK(dns_view_create(mctx, dns_rdataclass_in, "view", &view));
CHECK(dns_zone_create(&zone, mctx));
isc_buffer_init(&buffer, name, strlen(name));
isc_buffer_add(&buffer, strlen(name));
dns_fixedname_init(&fixorigin);
origin = dns_fixedname_name(&fixorigin);
CHECK(dns_name_fromtext(origin, &buffer, dns_rootname, 0, NULL));
CHECK(dns_zone_setorigin(zone, origin));
dns_zone_setview(zone, view);
dns_zone_settype(zone, dns_zone_master);
dns_zone_setclass(zone, view->rdclass);
dns_view_detach(&view);
*zonep = zone;
return (ISC_R_SUCCESS);
cleanup:
if (zone != NULL)
dns_zone_detach(&zone);
if (view != NULL)
dns_view_detach(&view);
return (result);
}
开发者ID:Feechka,项目名称:bind9,代码行数:34,代码来源:zonemgr_test.c
示例15: 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;
}
开发者ID:pspacek,项目名称:dyndb-work,代码行数:60,代码来源:pipequeries.c
示例16: configure_staticstub_servernames
/*%
* Configure an apex NS with an out-of-zone NS names for a static-stub zone.
* For example, for the zone named "example.com", something like the following
* RRs will be added to the zone DB:
* example.com. NS ns.example.net.
*/
static isc_result_t
configure_staticstub_servernames(const cfg_obj_t *zconfig, dns_zone_t *zone,
dns_rdatalist_t *rdatalist, const char *zname)
{
const cfg_listelt_t *element;
isc_mem_t *mctx = dns_zone_getmctx(zone);
dns_rdata_t *rdata;
isc_region_t sregion, region;
isc_result_t result = ISC_R_SUCCESS;
for (element = cfg_list_first(zconfig);
element != NULL;
element = cfg_list_next(element))
{
const cfg_obj_t *obj;
const char *str;
dns_fixedname_t fixed_name;
dns_name_t *nsname;
isc_buffer_t b;
obj = cfg_listelt_value(element);
str = cfg_obj_asstring(obj);
dns_fixedname_init(&fixed_name);
nsname = dns_fixedname_name(&fixed_name);
isc_buffer_init(&b, str, strlen(str));
isc_buffer_add(&b, strlen(str));
result = dns_name_fromtext(nsname, &b, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS) {
cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
"server-name '%s' is not a valid "
"name", str);
return (result);
}
if (dns_name_issubdomain(nsname, dns_zone_getorigin(zone))) {
cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
"server-name '%s' must not be a "
"subdomain of zone name '%s'",
str, zname);
return (ISC_R_FAILURE);
}
dns_name_toregion(nsname, &sregion);
rdata = isc_mem_get(mctx, sizeof(*rdata) + sregion.length);
if (rdata == NULL)
return (ISC_R_NOMEMORY);
region.length = sregion.length;
region.base = (unsigned char *)(rdata + 1);
memcpy(region.base, sregion.base, region.length);
dns_rdata_init(rdata);
dns_rdata_fromregion(rdata, dns_zone_getclass(zone),
dns_rdatatype_ns, ®ion);
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
}
return (result);
}
开发者ID:ElRevo,项目名称:xia-core,代码行数:64,代码来源:zoneconf.c
示例17: fromtext_soa
static inline isc_result_t
fromtext_soa(ARGS_FROMTEXT) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
int i;
isc_uint32_t n;
isc_boolean_t ok;
REQUIRE(type == 6);
UNUSED(type);
UNUSED(rdclass);
UNUSED(callbacks);
origin = (origin != NULL) ? origin : dns_rootname;
for (i = 0; i < 2; i++) {
RETERR(isc_lex_getmastertoken(lexer, &token,
isc_tokentype_string,
ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region);
RETTOK(dns_name_fromtext(&name, &buffer, origin,
options, target));
ok = ISC_TRUE;
if ((options & DNS_RDATA_CHECKNAMES) != 0)
switch (i) {
case 0:
ok = dns_name_ishostname(&name, ISC_FALSE);
break;
case 1:
ok = dns_name_ismailbox(&name);
break;
}
if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0)
RETTOK(DNS_R_BADNAME);
if (!ok && callbacks != NULL)
warn_badname(&name, lexer, callbacks);
}
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
ISC_FALSE));
RETERR(uint32_tobuffer(token.value.as_ulong, target));
for (i = 0; i < 4; i++) {
RETERR(isc_lex_getmastertoken(lexer, &token,
isc_tokentype_string,
ISC_FALSE));
RETTOK(dns_counter_fromtext(&token.value.as_textregion, &n));
RETERR(uint32_tobuffer(n, target));
}
return (ISC_R_SUCCESS);
}
开发者ID:fanf2,项目名称:bind-9,代码行数:57,代码来源:soa_6.c
示例18: main
int
main(int argc, char **argv) {
dns_fixedname_t fixed;
dns_name_t *name;
isc_buffer_t buffer;
isc_region_t region;
isc_result_t result;
unsigned char hash[NSEC3_MAX_HASH_LENGTH];
unsigned char salt[DNS_NSEC3_SALTSIZE];
unsigned char text[1024];
unsigned int hash_alg;
unsigned int length;
unsigned int iterations;
unsigned int salt_length;
if (argc != 5)
usage();
if (strcmp(argv[1], "-") == 0) {
salt_length = 0;
salt[0] = 0;
} else {
isc_buffer_init(&buffer, salt, sizeof(salt));
result = isc_hex_decodestring(argv[1], &buffer);
check_result(result, "isc_hex_decodestring(salt)");
salt_length = isc_buffer_usedlength(&buffer);
if (salt_length > DNS_NSEC3_SALTSIZE)
fatal("salt too long");
}
hash_alg = atoi(argv[2]);
if (hash_alg > 255U)
fatal("hash algorithm too large");
iterations = atoi(argv[3]);
if (iterations > 0xffffU)
fatal("iterations to large");
dns_fixedname_init(&fixed);
name = dns_fixedname_name(&fixed);
isc_buffer_init(&buffer, argv[4], strlen(argv[4]));
isc_buffer_add(&buffer, strlen(argv[4]));
result = dns_name_fromtext(name, &buffer, dns_rootname, 0, NULL);
check_result(result, "dns_name_fromtext() failed");
dns_name_downcase(name, name, NULL);
length = isc_iterated_hash(hash, hash_alg, iterations, salt,
salt_length, name->ndata, name->length);
if (length == 0)
fatal("isc_iterated_hash failed");
region.base = hash;
region.length = length;
isc_buffer_init(&buffer, text, sizeof(text));
isc_base32hexnp_totext(®ion, 1, "", &buffer);
fprintf(stdout, "%.*s (salt=%s, hash=%u, iterations=%u)\n",
(int)isc_buffer_usedlength(&buffer), text, argv[1], hash_alg, iterations);
return(0);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:56,代码来源:nsec3hash.c
示例19: probe_domain
static isc_result_t probe_domain (struct probe_trans *trans)
{
isc_result_t result;
size_t domainlen;
isc_buffer_t b;
char buf[4096]; /* XXX ad hoc constant, but should be enough */
char *cp;
REQUIRE (trans != NULL);
REQUIRE (trans->inuse == ISC_FALSE);
REQUIRE (outstanding_probes < MAX_PROBES);
/* Construct domain */
cp = fgets (buf, sizeof (buf), fp);
if (cp == NULL)
return (ISC_R_NOMORE);
if ((cp = strchr (buf, '\n')) != NULL) /* zap NL if any */
*cp = '\0';
trans->domain = isc_mem_strdup (mctx, buf);
if (trans->domain == NULL)
{
fprintf (stderr, "failed to allocate memory for domain: %s", cp);
return (ISC_R_NOMEMORY);
}
/* Start getting NS for the domain */
domainlen = strlen (buf);
isc_buffer_init (&b, buf, domainlen);
isc_buffer_add (&b, domainlen);
dns_fixedname_init (&trans->fixedname);
trans->qname = dns_fixedname_name (&trans->fixedname);
result = dns_name_fromtext (trans->qname, &b, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS)
goto cleanup;
result = dns_client_startresolve (client, trans->qname,
dns_rdataclass_in, dns_rdatatype_ns,
0, probe_task, resolve_ns, trans, &trans->resid);
if (result != ISC_R_SUCCESS)
goto cleanup;
trans->inuse = ISC_TRUE;
outstanding_probes++;
return (ISC_R_SUCCESS);
cleanup:
isc_mem_free (mctx, trans->domain);
dns_fixedname_invalidate (&trans->fixedname);
return (result);
}
开发者ID:274914765,项目名称:C,代码行数:55,代码来源:nsprobe.c
示例20: 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);
}
开发者ID:JeanCaron,项目名称:bind9,代码行数:54,代码来源:sample-request.c
注:本文中的dns_name_fromtext函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论