Changeset 48171fc4 in mainline for uspace/srv/net/dnsrsrv/query.c


Ignore:
Timestamp:
2013-05-03T08:10:02Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a0d97f83
Parents:
fff7ef4
Message:

Single fibril for receiving responses. Request timeout.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/dnsrsrv/query.c

    rfff7ef4 r48171fc4  
    3535
    3636#include <errno.h>
     37#include <io/log.h>
    3738#include <mem.h>
    3839#include <stdlib.h>
     
    4748static uint16_t msg_id;
    4849
    49 #include <stdio.h>
    5050int dns_name2host(const char *name, dns_host_info_t **rinfo)
    5151{
    52         dns_message_t msg;
     52        dns_message_t *msg;
    5353        dns_message_t *amsg;
    5454        dns_question_t question;
     
    6060        question.qclass = DC_IN;
    6161
    62         memset(&msg, 0, sizeof(msg));
     62        msg = calloc(1, sizeof(dns_message_t));
     63        if (msg == NULL)
     64                return ENOMEM;
    6365
    64         list_initialize(&msg.question);
    65         list_append(&question.msg, &msg.question);
     66        list_initialize(&msg->question);
     67        list_append(&question.msg, &msg->question);
    6668
    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;
    7476
    75         rc = dns_request(&msg, &amsg);
    76         if (rc != EOK)
     77        rc = dns_request(msg, &amsg);
     78        if (rc != EOK) {
    7779                return rc;
     80        }
    7881
    7982        list_foreach(amsg->answer, link) {
    8083                dns_rr_t *rr = list_get_instance(link, dns_rr_t, msg);
    8184
    82                 printf(" - '%s' %u/%u, dsize %u\n",
     85                log_msg(LOG_DEFAULT, LVL_DEBUG, " - '%s' %u/%u, dsize %u\n",
    8386                        rr->name, rr->rtype, rr->rclass, rr->rdata_size);
    8487
     
    9497                        info->name = str_dup(rr->name);
    9598                        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);
    97101
    98102                        dns_message_destroy(amsg);
     
    102106        }
    103107
     108        dns_message_destroy(msg);
    104109        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");
    106111
    107112        return EIO;
Note: See TracChangeset for help on using the changeset viewer.