Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nettest2/nettest2.c

    r3e6a98c5 ra2e3ee6  
    4747#include <stdbool.h>
    4848
     49#include <inet/dnsr.h>
    4950#include <net/in.h>
    5051#include <net/in6.h>
     
    7172        printf(
    7273            "Network Networking test 2 aplication - UDP transfer\n"
    73             "Usage: echo [options] address\n"
     74            "Usage: nettest2 [options] host\n"
    7475            "Where options are:\n"
    7576            "-f protocol_family | --family=protocol_family\n"
     
    227228        struct sockaddr_in address_in;
    228229        struct sockaddr_in6 address_in6;
     230        dnsr_hostinfo_t *hinfo;
    229231        socklen_t addrlen;
    230232        uint8_t *address_start;
     
    265267        }
    266268
    267         /* If not before the last argument containing the address */
     269        /* If not before the last argument containing the host */
    268270        if (index >= argc) {
    269                 printf("Command line error: missing address\n");
     271                printf("Command line error: missing host name\n");
    270272                nettest2_print_help();
    271273                return EINVAL;
     
    294296        }
    295297
    296         /* Parse the last argument which should contain the address. */
     298        /* Parse the last argument which should contain the host/address */
    297299        rc = inet_pton(family, argv[argc - 1], address_start);
    298300        if (rc != EOK) {
    299                 fprintf(stderr, "Address parse error %d\n", rc);
    300                 return rc;
     301                /* Try interpreting as a host name */
     302                rc = dnsr_name2host(argv[argc - 1], &hinfo);
     303                if (rc != EOK) {
     304                        printf("Error resolving host '%s'.\n", argv[argc - 1]);
     305                        return rc;
     306                }
     307               
     308                rc = inet_addr_sockaddr_in(&hinfo->addr, &address_in);
     309                if (rc != EOK) {
     310                        printf("Host '%s' not resolved as IPv4 address.\n", argv[argc - 1]);
     311                        return rc;
     312                }
    301313        }
    302314
Note: See TracChangeset for help on using the changeset viewer.