Changeset 48171fc4 in mainline for uspace/srv/net/dnsrsrv/query.c
- Timestamp:
- 2013-05-03T08:10:02Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0d97f83
- Parents:
- fff7ef4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsrsrv/query.c
rfff7ef4 r48171fc4 35 35 36 36 #include <errno.h> 37 #include <io/log.h> 37 38 #include <mem.h> 38 39 #include <stdlib.h> … … 47 48 static uint16_t msg_id; 48 49 49 #include <stdio.h>50 50 int dns_name2host(const char *name, dns_host_info_t **rinfo) 51 51 { 52 dns_message_t msg;52 dns_message_t *msg; 53 53 dns_message_t *amsg; 54 54 dns_question_t question; … … 60 60 question.qclass = DC_IN; 61 61 62 memset(&msg, 0, sizeof(msg)); 62 msg = calloc(1, sizeof(dns_message_t)); 63 if (msg == NULL) 64 return ENOMEM; 63 65 64 list_initialize(&msg .question);65 list_append(&question.msg, &msg .question);66 list_initialize(&msg->question); 67 list_append(&question.msg, &msg->question); 66 68 67 msg .id = msg_id++;68 msg .qr = QR_QUERY;69 msg .opcode = OPC_QUERY;70 msg .aa = false;71 msg .tc = false;72 msg .rd = true;73 msg .ra = false;69 msg->id = msg_id++; 70 msg->qr = QR_QUERY; 71 msg->opcode = OPC_QUERY; 72 msg->aa = false; 73 msg->tc = false; 74 msg->rd = true; 75 msg->ra = false; 74 76 75 rc = dns_request( &msg, &amsg);76 if (rc != EOK) 77 rc = dns_request(msg, &amsg); 78 if (rc != EOK) { 77 79 return rc; 80 } 78 81 79 82 list_foreach(amsg->answer, link) { 80 83 dns_rr_t *rr = list_get_instance(link, dns_rr_t, msg); 81 84 82 printf(" - '%s' %u/%u, dsize %u\n",85 log_msg(LOG_DEFAULT, LVL_DEBUG, " - '%s' %u/%u, dsize %u\n", 83 86 rr->name, rr->rtype, rr->rclass, rr->rdata_size); 84 87 … … 94 97 info->name = str_dup(rr->name); 95 98 info->addr.ipv4 = dns_uint32_t_decode(rr->rdata, rr->rdata_size); 96 printf("info->addr = %x\n", info->addr.ipv4); 99 log_msg(LOG_DEFAULT, LVL_DEBUG, "info->addr = %x\n", 100 info->addr.ipv4); 97 101 98 102 dns_message_destroy(amsg); … … 102 106 } 103 107 108 dns_message_destroy(msg); 104 109 dns_message_destroy(amsg); 105 printf("no A/IN found, fail\n");110 log_msg(LOG_DEFAULT, LVL_DEBUG, "No A/IN found, fail\n"); 106 111 107 112 return EIO;
Note:
See TracChangeset
for help on using the changeset viewer.