Changes in uspace/srv/net/dnsrsrv/query.c [716357f:959d2ec] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsrsrv/query.c
r716357f r959d2ec 54 54 dns_question_t *question; 55 55 dns_host_info_t *info; 56 char *sname, *cname; 57 size_t eoff; 56 58 int rc; 57 59 … … 83 85 } 84 86 87 /* Start with the caller-provided name */ 88 sname = str_dup(name); 89 85 90 list_foreach(amsg->answer, link) { 86 91 dns_rr_t *rr = list_get_instance(link, dns_rr_t, msg); … … 89 94 rr->name, rr->rtype, rr->rclass, rr->rdata_size); 90 95 96 if (rr->rtype == DTYPE_CNAME && rr->rclass == DC_IN && 97 str_cmp(rr->name, sname) == 0) { 98 log_msg(LOG_DEFAULT, LVL_DEBUG, "decode cname (%p, %zu, %zu)", 99 amsg->pdu.data, amsg->pdu.size, rr->roff); 100 rc = dns_name_decode(&amsg->pdu, rr->roff, &cname, &eoff); 101 if (rc != EOK) { 102 log_msg(LOG_DEFAULT, LVL_DEBUG, 103 "error decoding cname"); 104 assert(rc == EINVAL || rc == ENOMEM); 105 dns_message_destroy(msg); 106 dns_message_destroy(amsg); 107 return rc; 108 } 109 110 log_msg(LOG_DEFAULT, LVL_DEBUG, "name = '%s' " 111 "cname = '%s'", sname, cname); 112 113 free(sname); 114 /* Continue looking for the more canonical name */ 115 sname = cname; 116 } 117 91 118 if (rr->rtype == DTYPE_A && rr->rclass == DC_IN && 92 rr->rdata_size == sizeof(uint32_t)) { 119 rr->rdata_size == sizeof(uint32_t) && 120 str_cmp(rr->name, sname) == 0) { 93 121 94 122 info = calloc(1, sizeof(dns_host_info_t)); 95 123 if (info == NULL) { 124 dns_message_destroy(msg); 96 125 dns_message_destroy(amsg); 97 126 return ENOMEM; 98 127 } 99 128 100 info-> name = str_dup(rr->name);129 info->cname = str_dup(rr->name); 101 130 info->addr.ipv4 = dns_uint32_t_decode(rr->rdata, rr->rdata_size); 102 log_msg(LOG_DEFAULT, LVL_DEBUG, "info-> addr = %x",103 info->addr.ipv4);131 log_msg(LOG_DEFAULT, LVL_DEBUG, "info->name = '%s' " 132 "info->addr = %x", info->cname, info->addr.ipv4); 104 133 105 134 dns_message_destroy(msg); … … 112 141 dns_message_destroy(msg); 113 142 dns_message_destroy(amsg); 114 log_msg(LOG_DEFAULT, LVL_DEBUG, " No A/IN found, fail");143 log_msg(LOG_DEFAULT, LVL_DEBUG, "'%s' not resolved, fail", sname); 115 144 116 145 return EIO; … … 119 148 void dns_hostinfo_destroy(dns_host_info_t *info) 120 149 { 121 free(info-> name);150 free(info->cname); 122 151 free(info); 123 152 }
Note:
See TracChangeset
for help on using the changeset viewer.