Home | History | Annotate | Download | only in ServiceRegistration

Lines Matching refs:question

126 typedef struct question question_t;
140 // query. In this case, we create the query, ask the question, generate a single DNS response, send it, and
186 answer_t *next; // List of answers to a question.
197 struct question {
200 dnssd_query_t *queries; // dnssd queries that are asking this question.
201 dnssd_txn_t *txn; // Subordinate DNSServiceRef for this question
203 answer_t *answers; // Answers this question has received.
204 int64_t start_time; // When this question was started.
205 int serviceFlags; // Service flags to use with this question.
226 int num_questions; // In case of a multi-question query, how many questions were asked
233 dnssd_query_t *question_next; // Linked list of queries on the question this query is subscribed to.
234 question_t *question; // Question asked by this query pointing to a cache entry.
403 static void dp_query_reply_from_cache(question_t *question, dnssd_query_t *query, bool remove);
405 static void dp_question_answers_free(question_t *question);
406 static void question_finalize(question_t *question);
419 question_t *question = context;
420 RELEASE_HERE(question, question);
424 dp_start_question(question_t *question, bool dns64)
432 // If a query has a served domain, query->question->name is the subdomain of the served domain that is
433 // being queried; otherwise query->question->name is the whole name.
434 if (question->served_domain != NULL) {
435 len = strlen(question->name);
436 if (question->served_domain->interface != NULL) {
438 ERROR("[QU%d] question name %s is too long for .local.", SERIAL(question), name);
441 memcpy(name, question->name, len);
444 size_t dlen = strlen(question->served_domain->domain_ld) + 1;
446 ERROR("[QU%d] question name %s is too long for %s.", SERIAL(question), name, question->served_domain->domain);
449 memcpy(name, question->name, len);
450 memcpy(&name[len], question->served_domain->domain_ld, dlen);
454 np = question->name;
466 uint32_t question_interface = question->interface_index;
494 if (dns64 && (question->type == dns_rrtype_aaaa) && (question->qclass == dns_qclass_in)) {
497 err = dns_service_query_record_wa(srp_servers, &sdref, question->serviceFlags | shared_connection_flag,
498 question_interface, np, question->type,
499 question->qclass, attr, dns_question_callback, question);
502 err = dns_service_query_record(srp_servers, &sdref, question->serviceFlags | shared_connection_flag, question_interface, np,
503 question->type, question->qclass, dns_question_callback, question);
506 ERROR("[QU%d] DNSServiceQueryRecord failed for '%s': %d", SERIAL(question), np, err);
508 INFO("[QU%d] txn %p new sdref %p", SERIAL(question), question->txn, sdref);
510 question->txn = ioloop_dnssd_txn_add_subordinate(sdref, dp_question_context_release, NULL);
512 question->txn = dns_service_ioloop_txn_add(srp_servers, sdref, question, dp_question_context_release, dp_handle_server_disconnect);
514 RETAIN_HERE(question, question); // For the callback
516 INFO("[QU%d] DNSServiceQueryRecordWithAttribute started for '" PRI_S_SRP "': %d", SERIAL(question), np, err);
518 INFO("[QU%d] DNSServiceQueryRecord started for '" PRI_S_SRP "': %d", SERIAL(question), np, err);
525 dp_iterate_questions_on_list(question_t *list, bool (*callback)(question_t *question, void *context), void *context)
527 for (question_t *question = list; question; question = question->next) {
528 if (callback(question, context)) {
536 dp_iterate_questions(bool (*callback)(question_t *question, void *context), void *context)
551 dp_restart_question(question_t *question, void *context)
554 if (question->txn == NULL) {
555 dp_start_question(question, dns64);
573 dp_void_question(question_t *question, void *UNUSED context)
575 if (question->txn != NULL) {
576 INFO("[QU%d] question->txn = %p", SERIAL(question), question->txn);
578 question->txn->sdref = NULL;
580 ioloop_dnssd_txn_cancel(question->txn);
582 ioloop_dnssd_txn_release(question->txn);
583 question->txn = NULL;
585 if (question->answers != NULL) {
586 dnssd_query_t *next, *query = question->queries;
590 dp_query_reply_from_cache(question, query, true);
594 dp_question_answers_free(question);
697 dp_question_answers_free(question_t *question)
700 answer_t *answer = question->answers;
707 question->answers = NULL;
710 // The finalize function will deallocate answers associated with the question,
711 // remove question from the question list and deallocate the question.
713 question_finalize(question_t *question)
715 INFO("[QU%d] type %d class %d " PRI_S_SRP, SERIAL(question), question->type, question->qclass, question->name);
716 dp_question_answers_free(question);
717 free(question->name);
718 free(question);
722 dp_question_cancel(question_t *question)
724 if (question->txn != NULL) {
725 INFO("[QU%d] question->txn = %p sdref=%p", SERIAL(question), question->txn, question->txn->sdref);
726 ioloop_dnssd_txn_cancel(question->txn);
727 ioloop_dnssd_txn_release(question->txn);
728 question->txn = NULL;
731 // Remove the question from its list.
733 if (question->served_domain != NULL) {
734 questions = &question->served_domain->questions;
740 if (q_cur == question) {
747 // If this was the last question, see if the served domain is still on the served domain list; if not,
749 if (question->served_domain != NULL && question->served_domain->questions == NULL) {
752 if (served_domain == question->served_domain) {
757 served_domain_free(question->served_domain);
760 RELEASE_HERE(question, question); // Release from the list.
788 if (query->question != NULL) {
789 RELEASE_HERE(query->question, question);
790 query->question = NULL;
796 // Remove any finished queries from the question cache query list.
798 dp_question_cache_remove_queries(question_t *question)
801 if (question == NULL) {
805 dnssd_query_t **pptr = &(question->queries);
806 RETAIN_HERE(question, question);
807 if (question->queries != NULL) {
817 if (question->queries == NULL) {
818 dp_question_cancel(question);
821 RELEASE_HERE(question, question);
902 INFO("[Q%d][QU%d] " PRI_S_SRP PUB_S_SRP PUB_S_SRP, SERIAL(query), SERIAL(query->question),
903 query->question == NULL ? "<null>" : query->question->name,
904 query->question == NULL ? "" : ((query->question->served_domain
905 ? (query->question->served_domain->interface
907 : query->question->served_domain->domain_ld)
1065 INFO("[Q%d][QU%d] " PUB_S_SRP, SERIAL(query), SERIAL(query->question), activity->name);
1073 dp_question_cache_remove_queries(query->question);
1165 question_t *question = query->question;
1170 const bool translate = (question->served_domain != NULL) && (!hardwired_response);
1174 SERIAL(query), SERIAL(question), fullname, dns_rrtype_to_string(rrtype), rrclass);
1186 SERIAL(query), SERIAL(question), fullname, IPv4_ADDR_PARAM_SRP(rd, rd_buf));
1193 SERIAL(query), SERIAL(question), fullname, IPv4_ADDR_PARAM_SRP(rd, rd_buf));
1202 SERIAL(query), SERIAL(question), fullname, SEGMENTED_IPv6_ADDR_PARAM_SRP(rdata, rdata_buf));
1209 SERIAL(query), SERIAL(question), fullname, SEGMENTED_IPv6_ADDR_PARAM_SRP(rdata, rdata_buf));
1220 if (question->served_domain != NULL) {
1222 dns_concatenate_name_to_wire(towire, NULL, question->name, question->served_domain->domain));
1223 INFO("[Q%d][QU%d] " PUB_S_SRP " answer: type " PUB_S_SRP " class %02d " PRI_S_SRP "." PRI_S_SRP, SERIAL(query), SERIAL(question),
1224 query->dso != NULL ? "PUSH" : "DNS ", dns_rrtype_to_string(rrtype), rrclass, question->name, question->served_domain->domain);
1226 TOWIRE_CHECK("compress_name_to_wire", towire, dns_concatenate_name_to_wire(towire, NULL, NULL, question->name));
1228 SERIAL(query), SERIAL(question), query->dso != NULL ? "push" : " dns", dns_rrtype_to_string(rrtype), rrclass, question->name);
1264 INFO("[Q%d][QU%d] record type " PUB_S_SRP " not translated", SERIAL(query), SERIAL(question), dns_rrtype_to_string(rrtype));
1277 dns_concatenate_name_to_wire(towire, name, NULL, question->served_domain->domain));
1279 SERIAL(query), SERIAL(question), rbuf, pbuf, question->served_domain->domain);
1283 INFO("[Q%d][QU%d] compressing " PRI_S_SRP, SERIAL(query), SERIAL(question), rbuf);
1289 ERROR("[Q%d][QU%d] rdata from mDNSResponder didn't parse!!", SERIAL(query), SERIAL(question));
1296 ERROR("[Q%d][QU%d] RR ADD FAIL: " PUB_S_SRP, SERIAL(query), SERIAL(question), failnote);
2256 const char *name = answered_query->question != NULL ? answered_query->question->name : "(null)";
2265 // The usual case, there's only one question in the DNS message, so we can just
2395 question_t *question = query->question;
2403 if (question->served_domain != NULL && question->served_domain->interface != NULL &&
2404 !towire->truncated && (question->type != dns_rrtype_soa || question->name[0] != '\0'))
2462 if (question->type != dns_rrtype_soa) {
2471 INFO("[Q%d][QU%d][QID %x] ->p %p ->lim %p len %zd rcode %d " PUB_S_SRP, SERIAL(query), SERIAL(question),
2579 ERROR("[Q%d][QU%d][QID%x] failed on %s", SERIAL(query), SERIAL(question), ntohs(send_query->message->wire.id), failnote);
2595 INFO("[Q%d][QU%d] (len %zd)", SERIAL(query), SERIAL(question), iov.iov_len);
2647 question_t *question = query->question;
2649 char *name = "<null question name>";
2650 if (question != NULL) {
2651 name = question->name;
2663 INFO("[Q%d][QU%d] " PRI_S_SRP " (len %zd)", SERIAL(query), SERIAL(question), name, iov.iov_len);
2676 question_t *question = query->question;
2680 // If the question is for our uuid name in a domain we're authoritative for, respond with the IP address that
2681 // the question was received on.
2682 if (!strcasecmp(question->name, uuid_name) && (question->type == dns_rrtype_a || question->type == dns_rrtype_aaaa)) {
2691 if (question->type == dns_rrtype_a && local->sa.sa_family == AF_INET) {
2692 dp_query_add_data_to_response(query, question->name, question->type, dns_qclass_in, 4,
2697 else if (local->sa.sa_family == AF_INET6 && question->type == dns_rrtype_a &&
2700 dp_query_add_data_to_response(query, question->name, question->type, dns_qclass_in, 4,
2706 else if (local->sa.sa_family == AF_INET6 && question->type == dns_rrtype_aaaa &&
2764 INFO(PUB_S_SRP " IN AAAA " PRI_SEGMENTED_IPv6_ADDR_SRP " " PUB_S_SRP, question->name,
2766 dp_query_add_data_to_response(query, question->name, question->type, dns_qclass_in, 16,
2771 for (hp = query->question->served_domain->hardwired_responses; hp; hp = hp->next) {
2772 if ((query->question->type == hp->type || query->question->type == dns_rrtype_any) &&
2773 query->question->qclass == dns_qclass_in && !strcasecmp(hp->name, query->question->name))
2817 dp_query_add_data_to_response(query, "ipv4only.arpa.", dns_rrtype_aaaa, query->question->qclass,
2843 question_t *question = query->question;
2845 INFO("[Q%d][QU%d] " PRI_S_SRP PUB_S_SRP PUB_S_SRP " %d %x %d %p", SERIAL(query), SERIAL(question),
2853 const bool aaaa_query_got_a_record = (question->type == dns_rrtype_aaaa) && (rrtype == dns_rrtype_a);
2888 if (question->type != dns_rrtype_cname && rrtype == dns_rrtype_cname) {
2889 INFO("[Q%d][QU%d] not responding yet because CNAME.", SERIAL(query), SERIAL(question));
2941 question_t *question = context;
2945 // For dns push query, insert or remove answer from the question cache depending on the flags
2946 // For dns query (dso==NULL), add answer when receiving callback to the question
2950 for (answer_t *answer = question->answers; answer != NULL; answer = answer->next) {
2953 ", rrclass: " PUB_S_SRP ", rdlen: %u." PUB_S_SRP, SERIAL(question),
2965 ", rrclass: " PUB_S_SRP ", rdlen: %u.", SERIAL(question),
2971 ERROR("[QU%d] strdup failed to copy the answer name: " PRI_S_SRP, SERIAL(question), fullname);
2984 answer_t **tail = &(question->answers);
2990 question->no_data = false;
2992 ", rrclass: " PUB_S_SRP ", rdlen: %u." PUB_S_SRP, SERIAL(question),
2998 answer_t **answer = &(question->answers);
3006 SERIAL(question), fullname, dns_rrtype_to_string(rrtype), dns_qclass_to_string(rrclass), rdlen,
3021 ", rrtype: " PUB_S_SRP ", rrclass: " PUB_S_SRP ", rdlen: %u." PUB_S_SRP, SERIAL(question),
3027 question->no_data = true;
3032 ", rrclass: " PUB_S_SRP ", rdlen: %u." PUB_S_SRP, SERIAL(question), fullname, dns_rrtype_to_string(rrtype),
3034 question->no_data = true;
3044 ioloop_dnssd_txn_cancel(question->txn);
3045 ioloop_dnssd_txn_release(question->txn);
3046 question->txn = NULL;
3051 query = question->queries;
3063 dp_question_cache_remove_queries(question);
3071 size_t namelen = strlen(query->question->name);
3072 question_t *question = query->question;
3074 if (question->answers != NULL) {
3076 SERIAL(query), SERIAL(question), question->name);
3078 question->no_data = true;
3082 if (namelen + (question->served_domain
3083 ? (question->served_domain->interface != NULL
3086 : strlen(question->served_domain->domain_ld) + 1)
3088 ERROR("[Q%d][QU%d] no space to construct name.", SERIAL(query), SERIAL(question));
3093 memcpy(name, question->name, namelen + 1);
3094 if (question->served_domain != NULL) {
3099 dp_question_cache_remove_queries(question);
3103 // Search asked question in the cache; if not existing, create one.
3116 // otherwise lookup in the out-of-domain question cache
3124 question_t *question = *questions;
3125 if (search_term->type == question->type &&
3126 search_term->qclass == question->qclass &&
3127 !strcmp(name, question->name))
3129 ret = question;
3132 questions = &question->next;
3139 ERROR("Unable to allocate memory for question entry on " PRI_S_SRP, name));
3142 ERROR("unable to allocate memory for question name on " PRI_S_SRP, name));
3160 // Link the new_question to the question list.
3163 RETAIN_HERE(*questions, question); // retain
3165 // Successfully created a new question, which will be the returned question.
3172 RELEASE_HERE(new_question, question);
3175 RETAIN_HERE(ret, question);
3183 dp_query_reply_from_cache(question_t *question, dnssd_query_t *query, bool remove)
3185 // For dns query, if no_data is flagged or it's been six seconds since the question
3190 (question->no_data == true ||
3191 (question->answers == NULL &&
3192 srp_utime() - question->start_time > RESPONSE_WINDOW_USECS)))
3194 INFO("[Q%d][QU%d] no data for question - type %d class %d " PRI_S_SRP,
3195 SERIAL(query), SERIAL(question), question->type, question->qclass, question->name);
3196 dns_query_answer_process(0, kDNSServiceErr_NoSuchRecord, question->name,
3197 question->type, question->qclass, 0,
3199 dp_question_cache_remove_queries(question);
3202 // answers are available for the question being asked
3203 if (question->answers != NULL) {
3204 INFO("[Q%d][QU%d] reply from cache for question - type %d class %d " PRI_S_SRP,
3205 SERIAL(query), SERIAL(question), question->type, question->qclass, question->name);
3207 answer_t *answer = question->answers;
3232 dp_question_cache_remove_queries(question);
3247 question_t *question = query->question;
3249 if (question->served_domain != NULL) {
3262 if (question->served_domain != NULL && question->served_domain->interface != NULL && !question->name[0]) {
3272 if (question->txn == NULL) {
3273 int ret = dp_start_question(question, dns64);
3276 INFO("question was refused");
3279 INFO("[Q%d] couldn't start question", SERIAL(query));
3283 if (question->answers != NULL || question->no_data) {
3316 dp_query_create(dp_tracker_t *tracker, dns_rr_t *question, message_t *message, dso_state_t *dso, int *rcode)
3319 served_domain_t *sdt = dp_served(question->name, name, sizeof name);
3330 INFO("[Q%d][QID%x] msg %p " PUB_S_SRP " question: type %d class %d " PRI_S_SRP "." PRI_S_SRP " -> "
3332 question->type, question->qclass, name, sdt->domain, name);
3334 dns_name_print(question->name, name, sizeof name);
3335 INFO("[Q%d][QID%x] msg %p " PUB_S_SRP " question: type %d class %d " PRI_S_SRP, SERIAL(query), xid,
3336 message, dso != NULL ? "push" : " dns", question->type, question->qclass, name);
3358 // Retain the question, as we will need it to send a response.
3368 query->question = dp_query_question_cache_copy(question, &new_entry);
3369 require_action_quiet(query->question != NULL, exit, *rcode = dns_rcode_servfail);
3371 // add the query to the list of queries that are asking this question.
3372 dnssd_query_t **qr = &(query->question->queries);
3377 // Question query list holds a reference to the query.
3379 INFO("[Q%d][QID%x] msg %p " PUB_S_SRP " cache entry for question: type %d class %d " PRI_S_SRP, SERIAL(query),
3380 xid, query->message, new_entry ? "new" : " existing", question->type, question->qclass, name);
3414 // query_state_waiting means that we're answering a regular DNS question
3474 dns_push_subscribe(dp_tracker_t *tracker, const dns_wire_t *header, dso_state_t *dso, dns_rr_t *question,
3478 dnssd_query_t *query = dp_query_create(tracker, question, NULL, dso, &rcode);
3498 dp_question_cache_remove_queries(query->question);
3502 dns_name_print(question->name, nbuf, sizeof(nbuf));
3507 SERIAL(dso), SERIAL(query), nbuf, question->type, question->qclass);
3508 dp_push_response(query, question);
3509 } else if (query->question != NULL) {
3511 SERIAL(dso), SERIAL(query), SERIAL(query->question), nbuf, question->type, question->qclass);
3512 dp_query_reply_from_cache(query->question, query, false);
3525 dns_rr_t question;
3528 memset(&question, 0, sizeof(question));
3537 if (!dns_rr_parse(&question, header->data, len, &offp, false, false) ||
3552 if ((dp_served(question.name, name, sizeof name))) {
3561 dns_name_print(question.name, &name[8], sizeof name - 8);
3565 question.type, question.qclass, rdlen, &header->data[offp]);
3568 dns_rrdata_free(&question);
3569 dns_name_free(question.name);
3590 // Get the question
3591 dns_rr_t question;
3595 memset(&question, 0, sizeof(question));
3597 if (!dns_rr_parse(&question, header->data, offp + dso->primary.length, &offp, false, false)) {
3602 dns_name_print(question.name, nbuf, sizeof(nbuf));
3634 SERIAL(dso), SERIAL(tracker), opcode_name, nbuf, activity_name, question.type);
3636 dns_push_subscribe(tracker, header, dso, &question, activity_name, opcode_name);
3649 char *question_name = query->question != NULL ? query->question->name : nbuf;
3651 SERIAL(dso), SERIAL(tracker), opcode_name, question_name, activity_name, question.type);
3656 dns_rrdata_free(&question);
3657 dns_name_free(question.name);
3858 dp_dns_query(dp_tracker_t *tracker, message_t *message, dns_rr_t *question, int num_questions)
3871 dnssd_query_t *query = dp_query_create(tracker, question, message, NULL, &rcode);
3882 // For DNS queries, we need to return the question.
3884 if (query->question->served_domain != NULL) {
3885 TOWIRE_CHECK("name", &query->towire, dns_name_to_wire(NULL, &query->towire, query->question->name));
3888 &query->towire, query->question->served_domain->domain));
3890 TOWIRE_CHECK("full name", &query->towire, dns_full_name_to_wire(NULL, &query->towire, query->question->name));
3892 TOWIRE_CHECK("TYPE", &query->towire, dns_u16_to_wire(&query->towire, question->type)); // TYPE
3893 TOWIRE_CHECK("CLASS", &query->towire, dns_u16_to_wire(&query->towire, question->qclass)); // CLASS
3895 ERROR("[TRK%d][QID %x] failure encoding question
3914 // If query->question isn't NULL, we need to reply from cache
3918 dp_question_cache_remove_queries(query->question);
3919 RELEASE_HERE(query->question, question);
3920 query->question = NULL;
3921 } else if (query->question != NULL) {
3923 dp_query_reply_from_cache(query->question, query, false);
3924 dp_question_cache_remove_queries(query->question);
3933 dp_question_cache_remove_queries(query->question);
3980 dns_rr_t question;
4034 // Some Matter accessories will send queries with more than one question, and if we don't answer these
4037 memset(&question, 0, sizeof(question));
4038 if (!dns_rr_parse(&question, message->wire.data, message->length - DNS_HEADER_SIZE, &offset, false, false)) {
4043 bool success = dp_dns_query(tracker, message, &question, num_questions);
4044 dns_rrdata_free(&question);
4045 dns_name_free(question.name);
4052 dp_question_cache_remove_queries(query->question);