Changeset 959d2ec in mainline
- Timestamp:
- 2013-05-08T10:29:45Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d242cb6
- Parents:
- 9f029aa
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/dnsres/dnsres.c
r9f029aa r959d2ec 50 50 int rc; 51 51 dnsr_hostinfo_t *hinfo; 52 char *hname; 52 53 char *saddr; 53 54 … … 57 58 } 58 59 59 rc = dnsr_name2host(argv[1], &hinfo); 60 hname = argv[1]; 61 62 rc = dnsr_name2host(hname, &hinfo); 60 63 if (rc != EOK) { 61 64 printf(NAME ": Error resolving '%s'.\n", argv[1]); … … 70 73 } 71 74 72 printf("Host name: %s address: %s\n", hinfo->name, saddr); 75 printf("Host name: %s\n", hname); 76 if (str_cmp(hname, hinfo->cname) != 0) 77 printf("Canonical name: %s\n", hinfo->cname); 78 printf("Address: %s\n", saddr); 79 73 80 dnsr_hostinfo_destroy(hinfo); 74 81 free(saddr); -
uspace/app/ping/ping.c
r9f029aa r959d2ec 234 234 235 235 if (hinfo != NULL) { 236 rc = asprintf(&sdest, "%s (%s)", hinfo-> name, adest);236 rc = asprintf(&sdest, "%s (%s)", hinfo->cname, adest); 237 237 if (rc < 0) { 238 238 printf(NAME ": Out of memory.\n"); -
uspace/lib/c/generic/dnsr.c
r9f029aa r959d2ec 71 71 { 72 72 async_exch_t *exch = dnsr_exchange_begin(); 73 char cname_buf[DNSR_NAME_MAX_SIZE + 1]; 74 ipc_call_t cnreply; 75 size_t act_size; 73 76 dnsr_hostinfo_t *info; 74 77 … … 76 79 aid_t req = async_send_0(exch, DNSR_NAME2HOST, &answer); 77 80 sysarg_t retval = async_data_write_start(exch, name, str_size(name)); 81 aid_t cnreq = async_data_read(exch, cname_buf, DNSR_NAME_MAX_SIZE, 82 &cnreply); 78 83 79 84 dnsr_exchange_end(exch); … … 81 86 if (retval != EOK) { 82 87 async_forget(req); 88 async_forget(cnreq); 83 89 return retval; 84 90 } 85 91 86 92 async_wait_for(req, &retval); 93 if (retval != EOK) { 94 async_forget(cnreq); 95 return EIO; 96 } 97 98 async_wait_for(cnreq, &retval); 87 99 if (retval != EOK) 88 100 return EIO; … … 92 104 return ENOMEM; 93 105 94 info->name = str_dup(name); 106 act_size = IPC_GET_ARG2(cnreply); 107 assert(act_size <= DNSR_NAME_MAX_SIZE); 108 cname_buf[act_size] = '\0'; 109 110 info->cname = str_dup(cname_buf); 95 111 info->addr.ipv4 = IPC_GET_ARG1(answer); 96 112 … … 104 120 return; 105 121 106 free(info-> name);122 free(info->cname); 107 123 free(info); 108 124 } -
uspace/lib/c/include/inet/dnsr.h
r9f029aa r959d2ec 38 38 #include <inet/inet.h> 39 39 40 enum { 41 DNSR_NAME_MAX_SIZE = 255 42 }; 43 40 44 typedef struct { 41 /** Host name */42 char * name;45 /** Host canonical name */ 46 char *cname; 43 47 /** Host address */ 44 48 inet_addr_t addr; -
uspace/srv/net/dnsrsrv/dns_type.h
r9f029aa r959d2ec 113 113 typedef struct { 114 114 /** Host name */ 115 char * name;115 char *cname; 116 116 /** Host address */ 117 117 inet_addr_t addr; -
uspace/srv/net/dnsrsrv/dnsrsrv.c
r9f029aa r959d2ec 89 89 char *name; 90 90 dns_host_info_t *hinfo; 91 ipc_callid_t rcallid; 92 size_t size; 93 sysarg_t retval; 94 size_t act_size; 91 95 int rc; 92 96 … … 100 104 } 101 105 106 if (!async_data_read_receive(&rcallid, &size)) { 107 async_answer_0(rcallid, EREFUSED); 108 async_answer_0(callid, EREFUSED); 109 return; 110 } 111 102 112 rc = dns_name2host(name, &hinfo); 103 113 if (rc != EOK) { 114 async_answer_0(rcallid, rc); 104 115 async_answer_0(callid, rc); 105 116 return; 106 117 } 107 118 108 async_answer_1(callid, EOK, hinfo->addr.ipv4); 119 act_size = str_size(hinfo->cname); 120 if (act_size > size) { 121 async_answer_0(rcallid, EOVERFLOW); 122 async_answer_0(callid, EOVERFLOW); 123 return; 124 } 125 126 retval = async_data_read_finalize(rcallid, hinfo->cname, act_size); 127 async_answer_1(callid, retval, hinfo->addr.ipv4); 109 128 110 129 dns_hostinfo_destroy(hinfo); -
uspace/srv/net/dnsrsrv/query.c
r9f029aa r959d2ec 127 127 } 128 128 129 info-> name = str_dup(rr->name);129 info->cname = str_dup(rr->name); 130 130 info->addr.ipv4 = dns_uint32_t_decode(rr->rdata, rr->rdata_size); 131 131 log_msg(LOG_DEFAULT, LVL_DEBUG, "info->name = '%s' " 132 "info->addr = %x", info-> name, info->addr.ipv4);132 "info->addr = %x", info->cname, info->addr.ipv4); 133 133 134 134 dns_message_destroy(msg); … … 148 148 void dns_hostinfo_destroy(dns_host_info_t *info) 149 149 { 150 free(info-> name);150 free(info->cname); 151 151 free(info); 152 152 }
Note:
See TracChangeset
for help on using the changeset viewer.