+ return 0;
+}
+
+static void bus_method_resolve_hostname_complete(DnsQuery *q) {
+ _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *cname = NULL, *canonical = NULL;
+ _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+ unsigned i, n, added = 0;
+ size_t answer_rindex;
+ int r;
+
+ assert(q);
+
+ if (q->state != DNS_QUERY_SUCCESS) {
+ r = reply_query_state(q);
+ goto finish;
+ }
+
+ assert(q->received);
+
+ r = dns_packet_skip_question(q->received);
+ if (r < 0)
+ goto parse_fail;
+
+ answer_rindex = q->received->rindex;
+
+ r = sd_bus_message_new_method_return(q->request, &reply);
+ if (r < 0)
+ goto finish;
+
+ r = sd_bus_message_open_container(reply, 'a', "(yayi)");
+ if (r < 0)
+ goto finish;
+
+ n = DNS_PACKET_ANCOUNT(q->received) +
+ DNS_PACKET_NSCOUNT(q->received) +
+ DNS_PACKET_ARCOUNT(q->received);
+
+ for (i = 0; i < n; i++) {
+ _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
+
+ r = dns_packet_read_rr(q->received, &rr, NULL);
+ if (r < 0)
+ goto parse_fail;
+
+ r = dns_query_matches_rr(q, rr);
+ if (r < 0)
+ goto parse_fail;
+ if (r == 0) {
+ /* Hmm, if this is not an address record,
+ maybe it's a cname? If so, remember this */
+ r = dns_query_matches_cname(q, rr);