Changeset 89ac5513 in mainline for uspace/app


Ignore:
Timestamp:
2013-06-23T19:54:53Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ddb1922
Parents:
3abf0760 (diff), 96cbd18 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
uspace/app
Files:
4 added
4 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/Makefile

    r3abf0760 r89ac5513  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCLUI_PREFIX)/libclui.a \
    32         $(LIBFMTUTIL_PREFIX)/libfmtutil.a
    33 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCLUI_PREFIX) \
    34         -I$(LIBFMTUTIL_PREFIX) -I. -Icmds/ -Icmds/builtins -Icmds/modules
     31LIBS = $(LIBCLUI_PREFIX)/libclui.a $(LIBFMTUTIL_PREFIX)/libfmtutil.a
     32EXTRA_CFLAGS = -I$(LIBCLUI_PREFIX) -I$(LIBFMTUTIL_PREFIX) \
     33        -I. -Icmds/ -Icmds/builtins -Icmds/modules
    3534BINARY = bdsh
    3635
     
    4039        cmds/modules/mkfile/mkfile.c \
    4140        cmds/modules/rm/rm.c \
    42         cmds/modules/bdd/bdd.c \
    4341        cmds/modules/cat/cat.c \
    4442        cmds/modules/touch/touch.c \
  • uspace/app/bdsh/cmds/modules/cmp/cmp.c

    r3abf0760 r89ac5513  
    107107
    108108                if (offset[0] != offset[1] ||
    109                     bcmp(buffer[0], buffer[1], offset[0])) {
     109                    memcmp(buffer[0], buffer[1], offset[0]) != 0) {
    110110                        rc = 1;
    111111                        goto end;
  • uspace/app/bdsh/cmds/modules/modules.h

    r3abf0760 r89ac5513  
    5050#include "mkfile/entry.h"
    5151#include "rm/entry.h"
    52 #include "bdd/entry.h"
    5352#include "cat/entry.h"
    5453#include "touch/entry.h"
     
    7473#include "mkfile/mkfile_def.h"
    7574#include "rm/rm_def.h"
    76 #include "bdd/bdd_def.h"
    7775#include "cat/cat_def.h"
    7876#include "touch/touch_def.h"
  • uspace/app/bdsh/cmds/modules/sleep/sleep.c

    r3abf0760 r89ac5513  
    6767        uint64_t whole_seconds;
    6868        uint64_t frac_seconds;
    69         char *endptr;
     69        const char *endptr;
    7070
    7171        /* Check for whole seconds */
  • uspace/app/blkdump/blkdump.c

    r3abf0760 r89ac5513  
    11/*
    22 * Copyright (c) 2011 Martin Sucha
    3  * Copyright (c) 2010 Jiri Svoboda
     3 * Copyright (c) 2013 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    5252
    5353static void syntax_print(void);
     54static int print_blocks(aoff64_t block_offset, aoff64_t block_count, size_t block_size);
     55static int print_toc(void);
    5456static void print_hex_row(uint8_t *data, size_t length, size_t bytes_per_row);
     57
     58static bool relative = false;
     59static service_id_t service_id;
    5560
    5661int main(int argc, char **argv)
     
    5964        int rc;
    6065        char *dev_path;
    61         service_id_t service_id;
    6266        size_t block_size;
    6367        char *endptr;
     
    6569        aoff64_t block_count = 1;
    6670        aoff64_t dev_nblocks;
    67         uint8_t *data;
    68         size_t data_offset;
    69         aoff64_t current;
    70         aoff64_t limit;
    71         bool relative = false;
     71        bool toc = false;
    7272       
    7373        if (argc < 2) {
     
    7979        --argc; ++argv;
    8080
     81        if (str_cmp(*argv, "--toc") == 0) {
     82                --argc; ++argv;
     83                toc = true;
     84                goto devname;
     85        }
     86
    8187        if (str_cmp(*argv, "--relative") == 0) {
    8288                --argc; ++argv;
     
    120126        }
    121127
     128devname:
    122129        if (argc != 1) {
    123130                printf(NAME ": Error, unexpected argument.\n");
     
    153160        printf("Device %s has %" PRIuOFF64 " blocks, %" PRIuOFF64 " bytes each\n", dev_path, dev_nblocks, (aoff64_t) block_size);
    154161
     162        if (toc)
     163                rc = print_toc();
     164        else
     165                rc = print_blocks(block_offset, block_count, block_size);
     166
     167        block_fini(service_id);
     168
     169        return rc;
     170}
     171
     172static int print_blocks(aoff64_t block_offset, aoff64_t block_count, size_t block_size)
     173{
     174        uint8_t *data;
     175        aoff64_t current;
     176        aoff64_t limit;
     177        size_t data_offset;
     178        int rc;
     179
    155180        data = malloc(block_size);
    156181        if (data == NULL) {
    157182                printf(NAME ": Error allocating data buffer of %" PRIuOFF64 " bytes", (aoff64_t) block_size);
    158                 block_fini(service_id);
    159183                return 3;
    160184        }
    161        
     185
    162186        limit = block_offset + block_count;
    163187        for (current = block_offset; current < limit; current++) {
     
    168192                        return 3;
    169193                }
    170                
     194
    171195                printf("---- Block %" PRIuOFF64 " (at %" PRIuOFF64 ") ----\n", current, current*block_size);
    172                
     196
    173197                for (data_offset = 0; data_offset < block_size; data_offset += 16) {
    174198                        if (relative) {
     
    183207                printf("\n");
    184208        }
    185        
     209
    186210        free(data);
    187 
    188         block_fini(service_id);
     211        return 0;
     212}
     213
     214static int print_toc(void)
     215{
     216        toc_block_t *toc;
     217
     218        toc = block_get_toc(service_id, 0);
     219        if (toc == NULL)
     220                return 1;
     221
     222        printf("TOC size: %" PRIu16 " bytes\n", toc->size);
     223        printf("First session: %" PRIu8 "\n", toc->first_session);
     224        printf("Last_session: %" PRIu8 "\n", toc->last_session);
    189225
    190226        return 0;
  • uspace/app/inet/inet.c

    r3abf0760 r89ac5513  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3636
    3737#include <errno.h>
     38#include <inet/addr.h>
    3839#include <inet/inetcfg.h>
    3940#include <loc.h>
     
    5455}
    5556
    56 static int naddr_parse(const char *text, inet_naddr_t *naddr)
    57 {
    58         unsigned long a[4], bits;
    59         char *cp = (char *)text;
    60         int i;
    61 
    62         for (i = 0; i < 3; i++) {
    63                 a[i] = strtoul(cp, &cp, 10);
    64                 if (*cp != '.')
    65                         return EINVAL;
    66                 ++cp;
    67         }
    68 
    69         a[3] = strtoul(cp, &cp, 10);
    70         if (*cp != '/')
    71                 return EINVAL;
    72         ++cp;
    73 
    74         bits = strtoul(cp, &cp, 10);
    75         if (*cp != '\0')
    76                 return EINVAL;
    77 
    78         naddr->ipv4 = 0;
    79         for (i = 0; i < 4; i++) {
    80                 if (a[i] > 255)
    81                         return EINVAL;
    82                 naddr->ipv4 = (naddr->ipv4 << 8) | a[i];
    83         }
    84 
    85         if (bits > 31)
    86                 return EINVAL;
    87 
    88         naddr->bits = bits;
    89         return EOK;
    90 }
    91 
    92 static int addr_parse(const char *text, inet_addr_t *addr)
    93 {
    94         unsigned long a[4];
    95         char *cp = (char *)text;
    96         int i;
    97 
    98         for (i = 0; i < 3; i++) {
    99                 a[i] = strtoul(cp, &cp, 10);
    100                 if (*cp != '.')
    101                         return EINVAL;
    102                 ++cp;
    103         }
    104 
    105         a[3] = strtoul(cp, &cp, 10);
    106         if (*cp != '\0')
    107                 return EINVAL;
    108 
    109         addr->ipv4 = 0;
    110         for (i = 0; i < 4; i++) {
    111                 if (a[i] > 255)
    112                         return EINVAL;
    113                 addr->ipv4 = (addr->ipv4 << 8) | a[i];
    114         }
    115 
    116         return EOK;
    117 }
    118 
    119 static int naddr_format(inet_naddr_t *naddr, char **bufp)
    120 {
    121         int rc;
    122 
    123         rc = asprintf(bufp, "%d.%d.%d.%d/%d", naddr->ipv4 >> 24,
    124             (naddr->ipv4 >> 16) & 0xff, (naddr->ipv4 >> 8) & 0xff,
    125             naddr->ipv4 & 0xff, naddr->bits);
    126 
    127         if (rc < 0)
    128                 return ENOMEM;
    129 
    130         return EOK;
    131 }
    132 
    133 static int addr_format(inet_addr_t *addr, char **bufp)
    134 {
    135         int rc;
    136 
    137         rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24,
    138             (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff,
    139             addr->ipv4 & 0xff);
    140 
    141         if (rc < 0)
    142                 return ENOMEM;
    143 
    144         return EOK;
    145 }
    146 
    14757static int addr_create_static(int argc, char *argv[])
    14858{
     
    17888        }
    17989
    180         rc = naddr_parse(addr_spec, &naddr);
     90        rc = inet_naddr_parse(addr_spec, &naddr);
    18191        if (rc != EOK) {
    18292                printf(NAME ": Invalid network address format '%s'.\n",
     
    267177        route_name = argv[2];
    268178
    269         rc = naddr_parse(dest_str, &dest);
     179        rc = inet_naddr_parse(dest_str, &dest);
    270180        if (rc != EOK) {
    271181                printf(NAME ": Invalid network address format '%s'.\n",
     
    274184        }
    275185
    276         rc = addr_parse(router_str, &router);
     186        rc = inet_addr_parse(router_str, &router);
    277187        if (rc != EOK) {
    278188                printf(NAME ": Invalid address format '%s'.\n", router_str);
     
    366276                }
    367277
    368                 rc = naddr_format(&ainfo.naddr, &astr);
     278                rc = inet_naddr_format(&ainfo.naddr, &astr);
    369279                if (rc != EOK) {
    370280                        printf("Memory allocation failed.\n");
     
    430340                }
    431341
    432                 rc = naddr_format(&srinfo.dest, &dest_str);
     342                rc = inet_naddr_format(&srinfo.dest, &dest_str);
    433343                if (rc != EOK) {
    434344                        printf("Memory allocation failed.\n");
     
    437347                }
    438348
    439                 rc = addr_format(&srinfo.router, &router_str);
     349                rc = inet_addr_format(&srinfo.router, &router_str);
    440350                if (rc != EOK) {
    441351                        printf("Memory allocation failed.\n");
  • uspace/app/init/init.c

    r3abf0760 r89ac5513  
    359359        srv_start("/srv/tcp");
    360360        srv_start("/srv/udp");
     361        srv_start("/srv/dnsrsrv");
    361362       
    362363        srv_start("/srv/clipboard");
  • uspace/app/nettest1/nettest1.c

    r3abf0760 r89ac5513  
    4646#include <arg_parse.h>
    4747
     48#include <inet/dnsr.h>
    4849#include <net/in.h>
    4950#include <net/in6.h>
     
    7576        printf(
    7677            "Network Networking test 1 aplication - sockets\n"
    77             "Usage: echo [options] numeric_address\n"
     78            "Usage: nettest1 [options] host\n"
    7879            "Where options are:\n"
    7980            "-f protocol_family | --family=protocol_family\n"
     
    290291        struct sockaddr_in address_in;
    291292        struct sockaddr_in6 address_in6;
     293        dnsr_hostinfo_t *hinfo;
    292294        uint8_t *address_start;
    293295
     
    319321        }
    320322
    321         /* If not before the last argument containing the address */
     323        /* If not before the last argument containing the host */
    322324        if (index >= argc) {
    323                 printf("Command line error: missing address\n");
     325                printf("Command line error: missing host name\n");
    324326                nettest1_print_help();
    325327                return EINVAL;
     
    348350        }
    349351
    350         /* Parse the last argument which should contain the address */
     352        /* Parse the last argument which should contain the host/address */
    351353        rc = inet_pton(family, argv[argc - 1], address_start);
    352354        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_name2host(argv[argc - 1], &hinfo);
     357                if (rc != EOK) {
     358                        printf("Error resolving host '%s'.\n", argv[argc - 1]);
     359                        return rc;
     360                }
     361               
     362                rc = inet_addr_sockaddr_in(&hinfo->addr, &address_in);
     363                if (rc != EOK) {
     364                        printf("Host '%s' not resolved as IPv4 address.\n", argv[argc - 1]);
     365                        return rc;
     366                }
    355367        }
    356368
  • uspace/app/nettest2/nettest2.c

    r3abf0760 r89ac5513  
    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
  • uspace/app/nettest3/nettest3.c

    r3abf0760 r89ac5513  
    3939#include <str.h>
    4040
     41#include <inet/dnsr.h>
    4142#include <net/in.h>
    4243#include <net/in6.h>
     
    6061        int fd;
    6162        char *endptr;
     63        dnsr_hostinfo_t *hinfo;
    6264
    6365        port = 7;
     
    7577                rc = inet_pton(AF_INET, argv[1], (uint8_t *)&addr.sin_addr.s_addr);
    7678                if (rc != EOK) {
    77                         fprintf(stderr, "Error parsing address\n");
    78                         return 1;
     79                        /* Try interpreting as a host name */
     80                        rc = dnsr_name2host(argv[1], &hinfo);
     81                        if (rc != EOK) {
     82                                printf("Error resolving host '%s'.\n", argv[1]);
     83                                return rc;
     84                        }
     85                       
     86                        rc = inet_addr_sockaddr_in(&hinfo->addr, &addr);
     87                        if (rc != EOK) {
     88                                printf("Host '%s' not resolved as IPv4 address.\n", argv[1]);
     89                                return rc;
     90                        }
    7991                }
    8092                printf("result: rc=%d, family=%d, addr=%x\n", rc,
  • uspace/app/nterm/conn.c

    r3abf0760 r89ac5513  
    3333 */
    3434
     35#include <byteorder.h>
    3536#include <stdbool.h>
    3637#include <errno.h>
    3738#include <fibril.h>
     39#include <inet/dnsr.h>
    3840#include <net/socket.h>
    3941#include <stdio.h>
     
    7476{
    7577        struct sockaddr_in addr;
     78        dnsr_hostinfo_t *hinfo = NULL;
    7679        int rc;
    7780        char *endptr;
     
    8184        rc = inet_pton(addr.sin_family, addr_s, (uint8_t *)&addr.sin_addr);
    8285        if (rc != EOK) {
    83                 printf("Invalid addres %s\n", addr_s);
    84                 return EINVAL;
     86                /* Try interpreting as a host name */
     87                rc = dnsr_name2host(addr_s, &hinfo);
     88                if (rc != EOK) {
     89                        printf("Error resolving host '%s'.\n", addr_s);
     90                        goto error;
     91                }
     92               
     93                rc = inet_addr_sockaddr_in(&hinfo->addr, &addr);
     94                if (rc != EOK) {
     95                        printf("Host '%s' not resolved as IPv4 address.\n", addr_s);
     96                        return rc;
     97                }
    8598        }
    8699
     
    88101        if (*endptr != '\0') {
    89102                printf("Invalid port number %s\n", port_s);
    90                 return EINVAL;
     103                goto error;
    91104        }
    92105
     
    95108                goto error;
    96109
    97         printf("Connecting to address %s port %u\n", addr_s, ntohs(addr.sin_port));
     110        printf("Connecting to host %s port %u\n", addr_s, ntohs(addr.sin_port));
    98111
    99112        rc = connect(conn_fd, (struct sockaddr *)&addr, sizeof(addr));
  • uspace/app/nterm/nterm.c

    r3abf0760 r89ac5513  
    104104static void print_syntax(void)
    105105{
    106         printf("syntax: nterm <ip-address> <port>\n");
     106        printf("syntax: nterm <host> <port>\n");
    107107}
    108108
  • uspace/app/ping/ping.c

    r3abf0760 r89ac5513  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3737#include <errno.h>
    3838#include <fibril_synch.h>
     39#include <inet/dnsr.h>
     40#include <inet/addr.h>
    3941#include <inet/inetping.h>
    4042#include <io/console.h>
     
    6163};
    6264
    63 static inet_addr_t src_addr;
    64 static inet_addr_t dest_addr;
     65static uint32_t src;
     66static uint32_t dest;
    6567
    6668static bool ping_repeat = false;
     
    6870static void print_syntax(void)
    6971{
    70         printf("syntax: " NAME " [-r] <addr>\n");
    71 }
    72 
    73 static int addr_parse(const char *text, inet_addr_t *addr)
    74 {
    75         unsigned long a[4];
    76         char *cp = (char *)text;
    77         int i;
    78 
    79         for (i = 0; i < 3; i++) {
    80                 a[i] = strtoul(cp, &cp, 10);
    81                 if (*cp != '.')
    82                         return EINVAL;
    83                 ++cp;
    84         }
    85 
    86         a[3] = strtoul(cp, &cp, 10);
    87         if (*cp != '\0')
    88                 return EINVAL;
    89 
    90         addr->ipv4 = 0;
    91         for (i = 0; i < 4; i++) {
    92                 if (a[i] > 255)
    93                         return EINVAL;
    94                 addr->ipv4 = (addr->ipv4 << 8) | a[i];
    95         }
    96 
    97         return EOK;
    98 }
    99 
    100 static int addr_format(inet_addr_t *addr, char **bufp)
    101 {
    102         int rc;
    103 
    104         rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24,
    105             (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff,
    106             addr->ipv4 & 0xff);
    107 
    108         if (rc < 0)
    109                 return ENOMEM;
    110 
    111         return EOK;
     72        printf("syntax: " NAME " [-r] <host>\n");
    11273}
    11374
     
    12283static int ping_ev_recv(inetping_sdu_t *sdu)
    12384{
    124         char *asrc, *adest;
    125         int rc;
    126 
    127         rc = addr_format(&sdu->src, &asrc);
     85        inet_addr_t src_addr;
     86        inet_addr_unpack(sdu->src, &src_addr);
     87       
     88        inet_addr_t dest_addr;
     89        inet_addr_unpack(sdu->dest, &dest_addr);
     90       
     91        char *asrc;
     92        int rc = inet_addr_format(&src_addr, &asrc);
    12893        if (rc != EOK)
    12994                return ENOMEM;
    130 
    131         rc = addr_format(&sdu->dest, &adest);
     95       
     96        char *adest;
     97        rc = inet_addr_format(&dest_addr, &adest);
    13298        if (rc != EOK) {
    13399                free(asrc);
    134100                return ENOMEM;
    135101        }
     102       
    136103        printf("Received ICMP echo reply: from %s to %s, seq. no %u, "
    137104            "payload size %zu\n", asrc, adest, sdu->seq_no, sdu->size);
    138 
    139         if (!ping_repeat) {
     105       
     106        if (!ping_repeat)
    140107                ping_signal_done();
    141         }
    142 
     108       
    143109        free(asrc);
    144110        free(adest);
     
    151117        int rc;
    152118
    153         sdu.src = src_addr;
    154         sdu.dest = dest_addr;
     119        sdu.src = src;
     120        sdu.dest = dest;
    155121        sdu.seq_no = seq_no;
    156122        sdu.data = (void *) "foo";
     
    213179int main(int argc, char *argv[])
    214180{
     181        dnsr_hostinfo_t *hinfo = NULL;
     182        char *asrc = NULL;
     183        char *adest = NULL;
     184        char *sdest = NULL;
    215185        int rc;
    216186        int argi;
     
    220190                printf(NAME ": Failed connecting to internet ping service "
    221191                    "(%d).\n", rc);
    222                 return 1;
     192                goto error;
    223193        }
    224194
     
    233203        if (argc - argi != 1) {
    234204                print_syntax();
    235                 return 1;
     205                goto error;
    236206        }
    237207
    238208        /* Parse destination address */
    239         rc = addr_parse(argv[argi], &dest_addr);
    240         if (rc != EOK) {
    241                 printf(NAME ": Invalid address format.\n");
    242                 print_syntax();
    243                 return 1;
    244         }
    245 
     209        inet_addr_t dest_addr;
     210        rc = inet_addr_parse(argv[argi], &dest_addr);
     211        if (rc != EOK) {
     212                /* Try interpreting as a host name */
     213                rc = dnsr_name2host(argv[argi], &hinfo);
     214                if (rc != EOK) {
     215                        printf(NAME ": Error resolving host '%s'.\n", argv[argi]);
     216                        goto error;
     217                }
     218               
     219                dest_addr = hinfo->addr;
     220        }
     221       
     222        rc = inet_addr_pack(&dest_addr, &dest);
     223        if (rc != EOK) {
     224                printf(NAME ": Destination '%s' is not an IPv4 address.\n",
     225                    argv[argi]);
     226                goto error;
     227        }
     228       
    246229        /* Determine source address */
    247         rc = inetping_get_srcaddr(&dest_addr, &src_addr);
     230        rc = inetping_get_srcaddr(dest, &src);
    248231        if (rc != EOK) {
    249232                printf(NAME ": Failed determining source address.\n");
    250                 return 1;
    251         }
     233                goto error;
     234        }
     235       
     236        inet_addr_t src_addr;
     237        inet_addr_unpack(src, &src_addr);
     238       
     239        rc = inet_addr_format(&src_addr, &asrc);
     240        if (rc != EOK) {
     241                printf(NAME ": Out of memory.\n");
     242                goto error;
     243        }
     244       
     245        rc = inet_addr_format(&dest_addr, &adest);
     246        if (rc != EOK) {
     247                printf(NAME ": Out of memory.\n");
     248                goto error;
     249        }
     250       
     251        if (hinfo != NULL) {
     252                rc = asprintf(&sdest, "%s (%s)", hinfo->cname, adest);
     253                if (rc < 0) {
     254                        printf(NAME ": Out of memory.\n");
     255                        goto error;
     256                }
     257        } else {
     258                sdest = adest;
     259                adest = NULL;
     260        }
     261
     262        printf("Sending ICMP echo request from %s to %s.\n",
     263            asrc, sdest);
    252264
    253265        fid_t fid;
     
    257269                if (fid == 0) {
    258270                        printf(NAME ": Failed creating transmit fibril.\n");
    259                         return 1;
     271                        goto error;
    260272                }
    261273
     
    265277                if (fid == 0) {
    266278                        printf(NAME ": Failed creating input fibril.\n");
    267                         return 1;
     279                        goto error;
    268280                }
    269281
     
    283295        if (rc == ETIMEOUT) {
    284296                printf(NAME ": Echo request timed out.\n");
    285                 return 1;
    286         }
    287 
     297                goto error;
     298        }
     299
     300        free(asrc);
     301        free(adest);
     302        free(sdest);
     303        dnsr_hostinfo_destroy(hinfo);
    288304        return 0;
     305       
     306error:
     307        free(asrc);
     308        free(adest);
     309        free(sdest);
     310        dnsr_hostinfo_destroy(hinfo);
     311        return 1;
    289312}
    290313
Note: See TracChangeset for help on using the changeset viewer.