Example #1
0
ldns_pkt *
ldns_resolver_search(const ldns_resolver *r,const  ldns_rdf *name, ldns_rr_type type, 
                ldns_rr_class c, uint16_t flags)
{

	char *str_dname;
	ldns_rdf *new_name;
	ldns_rdf **search_list;
	size_t i;
	ldns_pkt *p;

	str_dname = ldns_rdf2str(name);

	if (ldns_dname_str_absolute(str_dname)) {
		/* query as-is */
		return ldns_resolver_query(r, name, type, c, flags);
	} else {
		search_list = ldns_resolver_searchlist(r);
		for (i = 0; i < ldns_resolver_searchlist_count(r); i++) {
			new_name = ldns_dname_cat_clone(name, search_list[i]);

			p = ldns_resolver_query(r, new_name, type, c, flags);
			ldns_rdf_free(new_name);
			if (p) {
				return p;
			}
		}
	}
	return NULL;
}
Example #2
0
void
ldns_resolver_deep_free(ldns_resolver *res)
{
    size_t i;

    if (res) {
        if (res->_searchlist) {
            for (i = 0; i < ldns_resolver_searchlist_count(res); i++) {
                ldns_rdf_deep_free(res->_searchlist[i]);
            }
            LDNS_FREE(res->_searchlist);
        }
        if (res->_nameservers) {
            for (i = 0; i < res->_nameserver_count; i++) {
                ldns_rdf_deep_free(res->_nameservers[i]);
            }
            LDNS_FREE(res->_nameservers);
        }
        if (ldns_resolver_domain(res)) {
            ldns_rdf_deep_free(ldns_resolver_domain(res));
        }
        if (res->_tsig_keyname) {
            LDNS_FREE(res->_tsig_keyname);
        }
        if (res->_tsig_keydata) {
            LDNS_FREE(res->_tsig_keydata);
        }
        if (res->_tsig_algorithm) {
            LDNS_FREE(res->_tsig_algorithm);
        }

        if (res->_cur_axfr_pkt) {
            ldns_pkt_free(res->_cur_axfr_pkt);
        }

        if (res->_rtt) {
            LDNS_FREE(res->_rtt);
        }
        if (res->_dnssec_anchors) {
            ldns_rr_list_deep_free(res->_dnssec_anchors);
        }
        LDNS_FREE(res);
    }
}
Example #3
0
void
ldns_resolver_push_searchlist(ldns_resolver *r, ldns_rdf *d)
{
	ldns_rdf **searchlist;
	size_t list_count;

	if (ldns_rdf_get_type(d) != LDNS_RDF_TYPE_DNAME) {
		return;
	}

	list_count = ldns_resolver_searchlist_count(r);
	searchlist = ldns_resolver_searchlist(r);

	searchlist = LDNS_XREALLOC(searchlist, ldns_rdf *, (list_count + 1));
	if (searchlist) {
		r->_searchlist = searchlist;

		searchlist[list_count] = ldns_rdf_clone(d);
		ldns_resolver_set_searchlist_count(r, list_count + 1);
	}
}