~ubuntu-branches/ubuntu/trusty/libnl3/trusty

« back to all changes in this revision

Viewing changes to src/nl-util-addr.c

  • Committer: Bazaar Package Importer
  • Author(s): Heiko Stuebner
  • Date: 2011-05-21 19:25:13 UTC
  • Revision ID: james.westby@ubuntu.com-20110521192513-1ieyu9w9kym4bt16
Tags: upstream-3.0
ImportĀ upstreamĀ versionĀ 3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * src/nl-util-addr.c     Address Helper
 
3
 *
 
4
 *      This library is free software; you can redistribute it and/or
 
5
 *      modify it under the terms of the GNU Lesser General Public
 
6
 *      License as published by the Free Software Foundation version 2.1
 
7
 *      of the License.
 
8
 *
 
9
 * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch>
 
10
 */
 
11
 
 
12
#include <netlink/cli/utils.h>
 
13
 
 
14
int main(int argc, char *argv[])
 
15
{
 
16
        int err;
 
17
        char host[256];
 
18
        struct nl_addr *a;
 
19
 
 
20
        if (argc < 2) {
 
21
                fprintf(stderr, "Usage: nl-util-addr <address>\n");
 
22
                return -1;
 
23
        }
 
24
 
 
25
        a = nl_cli_addr_parse(argv[1], AF_UNSPEC);
 
26
        err = nl_addr_resolve(a, host, sizeof(host));
 
27
        if (err != 0)
 
28
                nl_cli_fatal(err, "Unable to resolve address \"%s\": %s",
 
29
                      argv[1], nl_geterror(err));
 
30
 
 
31
        printf("%s\n", host);
 
32
 
 
33
        return 0;
 
34
}