Changeset 7262f89 in mainline for uspace/srv/net/dnsres/query.c


Ignore:
Timestamp:
2013-04-20T10:42:13Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dc95342
Parents:
f1dcf6d
Message:

Construct domain names, fix some bugs. Parse answer, print resulting hostname and IP address.

File:
1 edited

Legend:

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

    rf1dcf6d r7262f89  
    3636#include <errno.h>
    3737#include <mem.h>
     38#include <str.h>
    3839
     40#include "dns_msg.h"
    3941#include "dns_std.h"
    4042#include "dns_type.h"
     
    4446static uint16_t msg_id;
    4547
     48#include <stdio.h>
    4649int dns_name2host(const char *name, dns_host_info_t *info)
    4750{
     
    7275                return rc;
    7376
    74         return EOK;
     77        list_foreach(amsg->answer, link) {
     78                dns_rr_t *rr = list_get_instance(link, dns_rr_t, msg);
     79
     80                printf(" - '%s' %u/%u, dsize %u\n",
     81                        rr->name, rr->rtype, rr->rclass, rr->rdata_size);
     82
     83                if (rr->rtype == DTYPE_A && rr->rclass == DC_IN) {
     84                        if (rr->rdata_size != sizeof(uint32_t)) {
     85                                printf("rdata_size = %u - fail\n", rr->rdata_size);
     86                                return EIO;
     87                        }
     88
     89                        info->name = str_dup(rr->name);
     90                        info->addr.ipv4 = dns_uint32_t_decode(rr->rdata, rr->rdata_size);
     91                        printf("info->addr = %x\n", info->addr.ipv4);
     92                        return EOK;
     93                }
     94        }
     95
     96        printf("no A/IN found, fail\n");
     97
     98        return EIO;
    7599}
    76100
Note: See TracChangeset for help on using the changeset viewer.