size_t reply_len;
};
+#define DNS_REQUEST_TIMEOUT 2
+
/* Declare callback functions used below. */
-static void dns_request_get_reply(struct tevent_req *subreq);
-static void dns_request_done(struct tevent_req *subreq);
+static void dns_udp_request_get_reply(struct tevent_req *subreq);
+static void dns_udp_request_done(struct tevent_req *subreq);
struct tevent_req *dns_udp_request_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
ret = tsocket_address_inet_from_strings(state, "ip", NULL, 0,
&local_addr);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(ret));
+ tevent_req_werror(req, unix_to_werror(errno));
return tevent_req_post(req, ev);
}
ret = tsocket_address_inet_from_strings(state, "ip", server_addr_string,
DNS_SERVICE_PORT, &server_addr);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(ret));
+ tevent_req_werror(req, unix_to_werror(errno));
return tevent_req_post(req, ev);
}
ret = tdgram_inet_udp_socket(local_addr, server_addr, state, &dgram);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(ret));
+ tevent_req_werror(req, unix_to_werror(errno));
return tevent_req_post(req, ev);
}
return tevent_req_post(req, ev);
}
- tevent_req_set_callback(subreq, dns_request_get_reply, req);
+ if (!tevent_req_set_endtime(req, ev,
+ timeval_current_ofs(DNS_REQUEST_TIMEOUT, 0))) {
+ return tevent_req_post(req, ev);
+ }
+
+
+ tevent_req_set_callback(subreq, dns_udp_request_get_reply, req);
return req;
}
-static void dns_request_get_reply(struct tevent_req *subreq)
+static void dns_udp_request_get_reply(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(subreq,
struct tevent_req);
return;
}
- tevent_req_set_callback(subreq, dns_request_done, req);
+ tevent_req_set_callback(subreq, dns_udp_request_done, req);
return;
}
-static void dns_request_done(struct tevent_req *subreq)
+static void dns_udp_request_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(subreq,
struct tevent_req);