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