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 (at) 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 } 35