Changeset dc95342 in mainline for uspace/srv/net/dnsres/query.c
- Timestamp:
- 2013-04-22T06:45:49Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 31e9fe0
- Parents:
- 7262f89
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsres/query.c
r7262f89 rdc95342 1 1 /* 2 * Copyright (c) 201 2Jiri Svoboda2 * Copyright (c) 2013 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 #include <errno.h> 37 37 #include <mem.h> 38 #include <stdlib.h> 38 39 #include <str.h> 39 40 … … 47 48 48 49 #include <stdio.h> 49 int dns_name2host(const char *name, dns_host_info_t * info)50 int dns_name2host(const char *name, dns_host_info_t **rinfo) 50 51 { 51 52 dns_message_t msg; 52 53 dns_message_t *amsg; 53 54 dns_question_t question; 55 dns_host_info_t *info; 54 56 int rc; 55 57 … … 81 83 rr->name, rr->rtype, rr->rclass, rr->rdata_size); 82 84 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; 85 if (rr->rtype == DTYPE_A && rr->rclass == DC_IN && 86 rr->rdata_size == sizeof(uint32_t)) { 87 88 info = calloc(1, sizeof(dns_host_info_t)); 89 if (info == NULL) { 90 dns_message_destroy(amsg); 91 return ENOMEM; 87 92 } 88 93 … … 90 95 info->addr.ipv4 = dns_uint32_t_decode(rr->rdata, rr->rdata_size); 91 96 printf("info->addr = %x\n", info->addr.ipv4); 97 98 dns_message_destroy(amsg); 99 *rinfo = info; 92 100 return EOK; 93 101 } 94 102 } 95 103 104 dns_message_destroy(amsg); 96 105 printf("no A/IN found, fail\n"); 97 106 … … 99 108 } 100 109 110 void dns_hostinfo_destroy(dns_host_info_t *info) 111 { 112 free(info->name); 113 free(info); 114 } 115 101 116 /** @} 102 117 */
Note:
See TracChangeset
for help on using the changeset viewer.