oops
[libnl.git] / src / nl-util-addr.c
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-2006 Thomas Graf <tgraf@suug.ch>
10  */
11
12 #include "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_addr_parse(argv[1], AF_UNSPEC);
26         if (a == NULL) {
27                 fprintf(stderr, "Cannot parse address \"%s\"\n", argv[1]);
28                 return -1;
29         }
30
31         err = nl_addr_resolve(a, host, sizeof(host));
32         if (err != 0) {
33                 fprintf(stderr, "Cannot resolve address \"%s\": %d\n",
34                         argv[1], err);
35                 return -1;
36         }
37
38         printf("%s\n", host);
39
40         return 0;
41 }