Changeset 287d729 in mainline for uspace/app/nettest1/nettest1.c
- Timestamp:
- 2013-04-25T06:45:04Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fff7ef4
- Parents:
- c55cbbf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nettest1/nettest1.c
rc55cbbf r287d729 46 46 #include <arg_parse.h> 47 47 48 #include <inet/dnsr.h> 48 49 #include <net/in.h> 49 50 #include <net/in6.h> … … 75 76 printf( 76 77 "Network Networking test 1 aplication - sockets\n" 77 "Usage: echo [options] numeric_address\n"78 "Usage: nettest1 [options] host\n" 78 79 "Where options are:\n" 79 80 "-f protocol_family | --family=protocol_family\n" … … 290 291 struct sockaddr_in address_in; 291 292 struct sockaddr_in6 address_in6; 293 dnsr_hostinfo_t *hinfo; 292 294 uint8_t *address_start; 293 295 … … 319 321 } 320 322 321 /* If not before the last argument containing the address*/323 /* If not before the last argument containing the host */ 322 324 if (index >= argc) { 323 printf("Command line error: missing address\n");325 printf("Command line error: missing host name\n"); 324 326 nettest1_print_help(); 325 327 return EINVAL; … … 348 350 } 349 351 350 /* Parse the last argument which should contain the address */352 /* Parse the last argument which should contain the host/address */ 351 353 rc = inet_pton(family, argv[argc - 1], address_start); 352 354 if (rc != EOK) { 353 fprintf(stderr, "Address parse error %d\n", rc); 354 return rc; 355 /* Try interpreting as a host name */ 356 rc = dnsr_init(); 357 if (rc != EOK) { 358 printf("Failed connecting DNS resolution " 359 "service (%d).\n", rc); 360 return rc; 361 } 362 363 rc = dnsr_name2host(argv[argc - 1], &hinfo); 364 if (rc != EOK) { 365 printf("Error resolving host '%s'.\n", argv[argc - 1]); 366 return rc; 367 } 368 369 address_in.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 355 370 } 356 371
Note:
See TracChangeset
for help on using the changeset viewer.