Changes in uspace/app/ping/ping.c [9749e47:a62ceaf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/ping/ping.c
r9749e47 ra62ceaf 37 37 #include <errno.h> 38 38 #include <fibril_synch.h> 39 #include <inet/dnsr.h>40 39 #include <inet/addr.h> 40 #include <inet/host.h> 41 41 #include <inet/inetping.h> 42 42 #include <io/console.h> … … 214 214 int main(int argc, char *argv[]) 215 215 { 216 dnsr_hostinfo_t *hinfo = NULL;217 216 char *asrc = NULL; 218 217 char *adest = NULL; 219 218 char *sdest = NULL; 219 char *host; 220 const char *errmsg; 220 221 ip_ver_t ip_ver = ip_any; 221 222 … … 260 261 } 261 262 262 /* Parse destination address */ 263 rc = inet_addr_parse(argv[optind], &dest_addr); 264 if (rc != EOK) { 265 /* Try interpreting as a host name */ 266 rc = dnsr_name2host(argv[optind], &hinfo, ip_ver); 267 if (rc != EOK) { 268 printf("Error resolving host '%s'.\n", argv[optind]); 269 goto error; 270 } 271 272 dest_addr = hinfo->addr; 263 host = argv[optind]; 264 265 /* Look up host */ 266 rc = inet_host_plookup_one(host, ip_ver, &dest_addr, NULL, &errmsg); 267 if (rc != EOK) { 268 printf("Error resolving host '%s' (%s).\n", host, errmsg); 269 goto error; 273 270 } 274 271 … … 292 289 } 293 290 294 if (hinfo != NULL) { 295 rc = asprintf(&sdest, "%s (%s)", hinfo->cname, adest); 296 if (rc < 0) { 297 printf("Out of memory.\n"); 298 goto error; 299 } 300 } else { 301 sdest = adest; 302 adest = NULL; 291 rc = asprintf(&sdest, "%s (%s)", host, adest); 292 if (rc < 0) { 293 printf("Out of memory.\n"); 294 goto error; 303 295 } 304 296 … … 330 322 free(adest); 331 323 free(sdest); 332 dnsr_hostinfo_destroy(hinfo);333 324 return 0; 334 325 … … 337 328 free(adest); 338 329 free(sdest); 339 dnsr_hostinfo_destroy(hinfo);340 330 return 1; 341 331 }
Note:
See TracChangeset
for help on using the changeset viewer.