+ if (GNUNET_NO == was_gns)
+ {
+ /* TLD not configured for GNS, fall back to DNS */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using DNS resolver IP `%s' to resolve `%s'\n",
+ dns_ip,
+ request->packet->queries[0].name);
+ request->original_request_id = request->packet->id;
+ GNUNET_DNSPARSER_free_packet (request->packet);
+ request->packet = NULL;
+ request->dns_lookup = GNUNET_DNSSTUB_resolve (dns_stub,
+ request->udp_msg,
+ request->udp_msg_size,
+ &dns_result_processor,
+ request);
+ return;
+ }
+ packet = request->packet;
+ packet->flags.query_or_response = 1;
+ packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR;
+ packet->flags.checking_disabled = 0;
+ packet->flags.authenticated_data = 1;
+ packet->flags.zero = 0;
+ packet->flags.recursion_available = 1;
+ packet->flags.message_truncated = 0;
+ packet->flags.authoritative_answer = 0;
+ //packet->flags.opcode = GNUNET_TUN_DNS_OPCODE_STATUS; // ???
+ for (uint32_t i=0;i<rd_count;i++)
+ {
+ // FIXME: do we need to hanlde #GNUNET_GNSRECORD_RF_SHADOW_RECORD
+ // here? Or should we do this in libgnunetgns?
+ rec.expiration_time.abs_value_us = rd[i].expiration_time;
+ switch (rd[i].record_type)
+ {
+ case GNUNET_DNSPARSER_TYPE_A:
+ GNUNET_assert (sizeof (struct in_addr) == rd[i].data_size);
+ rec.name = GNUNET_strdup (packet->queries[0].name);
+ rec.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
+ rec.type = GNUNET_DNSPARSER_TYPE_A;
+ rec.data.raw.data = GNUNET_new (struct in_addr);
+ GNUNET_memcpy (rec.data.raw.data,
+ rd[i].data,
+ rd[i].data_size);
+ rec.data.raw.data_len = sizeof (struct in_addr);
+ GNUNET_array_append (packet->answers,
+ packet->num_answers,
+ rec);
+ break;
+ case GNUNET_DNSPARSER_TYPE_AAAA:
+ GNUNET_assert (sizeof (struct in6_addr) == rd[i].data_size);
+ rec.name = GNUNET_strdup (packet->queries[0].name);
+ rec.data.raw.data = GNUNET_new (struct in6_addr);
+ rec.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
+ rec.type = GNUNET_DNSPARSER_TYPE_AAAA;
+ GNUNET_memcpy (rec.data.raw.data,
+ rd[i].data,
+ rd[i].data_size);
+ rec.data.raw.data_len = sizeof (struct in6_addr);
+ GNUNET_array_append (packet->answers,
+ packet->num_answers,
+ rec);
+ break;
+ case GNUNET_DNSPARSER_TYPE_CNAME:
+ rec.name = GNUNET_strdup (packet->queries[0].name);
+ rec.data.hostname = GNUNET_strdup (rd[i].data);
+ rec.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
+ rec.type = GNUNET_DNSPARSER_TYPE_CNAME;
+ GNUNET_memcpy (rec.data.hostname,
+ rd[i].data,
+ rd[i].data_size);
+ GNUNET_array_append (packet->answers,
+ packet->num_answers,
+ rec);
+ break;
+ default:
+ /* skip */
+ break;
+ }
+ }