/**
* Creates a query packet for the given name, type, class
*/
-ldns_pkt * ldns_pkt_query_new(char *name, ldns_rr_type rr_type, ldns_rr_class rr_class);
-
+ldns_pkt * ldns_pkt_query_new_frm_str(char *, ldns_rr_type, ldns_rr_class);
+ldns_pkt * ldns_pkt_query_new(ldns_rdf *, ldns_rr_type, ldns_rr_class);
#define MAX_PACKET_SIZE 65535
}
ldns_pkt *
-ldns_pkt_query_new(char *name, ldns_rr_type rr_type, ldns_rr_class rr_class)
+ldns_pkt_query_new_frm_str(char *name, ldns_rr_type rr_type, ldns_rr_class rr_class)
{
- ldns_pkt *packet = ldns_pkt_new();
- ldns_rr *question_rr = ldns_rr_new();
+ ldns_pkt *packet;
+ ldns_rr *question_rr;
ldns_rdf *name_rdf;
+ packet = ldns_pkt_new();
+ if (!packet) {
+ return NULL;
+ }
+
+ question_rr = ldns_rr_new();
+ if (!question_rr) {
+ return NULL;
+ }
+
if (rr_type == 0) {
rr_type = LDNS_RR_TYPE_A;
}
return packet;
}
+
+/**
+ * Create a packet with a query in it
+ * \param[in] name the name to query for
+ * \param[in] type the type to query for
+ * \param[in] class the class to query for
+ * \return ldns_pkt* a pointer to the new pkt
+ */
+ldns_pkt *
+ldns_pkt_query_new(ldns_rdf *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class)
+{
+ ldns_pkt *packet;
+ ldns_rr *question_rr;
+ ldns_rdf *name_rdf;
+
+ packet = ldns_pkt_new();
+ if (!packet) {
+ return NULL;
+ }
+
+ question_rr = ldns_rr_new();
+ if (!question_rr) {
+ return NULL;
+ }
+
+ if (rr_type == 0) {
+ rr_type = LDNS_RR_TYPE_A;
+ }
+ if (rr_class == 0) {
+ rr_class = LDNS_RR_CLASS_IN;
+ }
+
+ ldns_rr_set_owner(question_rr, rr_name);
+ ldns_rr_set_type(question_rr, rr_type);
+ ldns_rr_set_class(question_rr, rr_class);
+
+ ldns_pkt_push_rr(packet, LDNS_SECTION_QUESTION, question_rr);
+ return packet;
+}
/* prepare a question pkt from the parameters
* and then send this */
- /*query_pkt = somesortofconversion2qpkt(name, type, class, flags); * */
+ query_pkt = ldns_pkt_query_new(name, type, class);
/* return NULL on error */
answer_pkt = ldns_send(*r, query_pkt);