o I you know what you do you should be able to bypass the resolver
module and directly talk to the network module.
o All modules will export functions to be used to client applications.
+ o All the stuff from the network is put in ldns_buffer's
2. Different parts of ldns:
#include <ldns/resolver.h>
#include <ldns/buffer.h>
#include <ldns/wire2host.h>
+#include <ldns/host2wire.h>
#include <ldns/host2str.h>
+#include <ldns/resolver.h>
#include <netinet/in.h>
#include <sys/socket.h>
ns_array = ldns_resolver_nameservers(r);
reply = NULL;
- if (ldns_pkt2buffer_str(qb, query_pkt) != LDNS_STATUS_OK) {
+ qb = ldns_buffer_new(MAX_PACKET_SIZE);
+
+ if (ldns_pkt2buffer_wire(qb, query_pkt) != LDNS_STATUS_OK) {
return NULL;
}
ns_ip = ldns_rdf2native_aaaaa(ns_array[i]);
ns_ip_len = ldns_rdf_size(ns_array[i]);
+ ldns_rdf_print(stdout, ns_ip);
+ printf("\n");
+
/* query */
reply = ldns_send_udp(qb, ns_ip, ns_ip_len);
query_pkt = ldns_pkt_query_new(name, type, class);
if (!query_pkt) {
printf("Failed to generate pkt\n");
+ return NULL;
}
/* return NULL on error */
-/* answer_pkt = ldns_send(*r, query_pkt);
- */
+ answer_pkt = ldns_send(r, query_pkt);
return answer_pkt;
}
printf("error pkt sending\n");
return 1;
}
-
/* print the resulting pkt to stdout */
- /* DISABLE FOR NOW ldns_pkt_print(stdout, pkt); */
+ ldns_pkt_print(stdout, pkt);
return 0;
}