static isc_result_t fetch_nsaddress (struct probe_trans *trans) { struct probe_ns *pns; pns = trans->current_ns; REQUIRE (pns != NULL); return (dns_client_startresolve (client, pns->name, dns_rdataclass_in, dns_rdatatype_a, 0, probe_task, resolve_nsaddress, trans, &trans->resid)); }
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); }
static isc_result_t dispatch_query(struct query_trans *trans) { isc_result_t result; size_t namelen; 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(ISC_LIST_EMPTY(trans->answerlist)); REQUIRE(outstanding_queries < MAX_QUERIES); /* Construct qname */ cp = fgets(buf, sizeof(buf), fp); if (cp == NULL) return (ISC_R_NOMORE); /* zap NL if any */ if ((cp = strchr(buf, '\n')) != NULL) *cp = '\0'; namelen = strlen(buf); isc_buffer_init(&b, buf, namelen); isc_buffer_add(&b, namelen); 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; /* Start resolution */ result = dns_client_startresolve(client, trans->qname, dns_rdataclass_in, trans->type, 0, query_task, process_answer, trans, &trans->xid); if (result != ISC_R_SUCCESS) goto cleanup; trans->inuse = ISC_TRUE; outstanding_queries++; return (ISC_R_SUCCESS); cleanup: dns_fixedname_invalidate(&trans->fixedname); return (result); }