X-Git-Url: http://git.onelab.eu/?p=libnl.git;a=blobdiff_plain;f=src%2Fnl-util-addr.c;fp=src%2Fnl-util-addr.c;h=9f1279548ff91c34f13ee534bede1347dfc4875d;hp=0000000000000000000000000000000000000000;hb=4cee2ecb3b8afa0637e6f5fe4c57985a4bc740ff;hpb=2df2fbe518d5a221ce6e3ee88a3fb23fb1b94b27 diff --git a/src/nl-util-addr.c b/src/nl-util-addr.c new file mode 100644 index 0000000..9f12795 --- /dev/null +++ b/src/nl-util-addr.c @@ -0,0 +1,41 @@ +/* + * src/nl-util-addr.c Address Helper + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * Copyright (c) 2003-2006 Thomas Graf + */ + +#include "utils.h" + +int main(int argc, char *argv[]) +{ + int err; + char host[256]; + struct nl_addr *a; + + if (argc < 2) { + fprintf(stderr, "Usage: nl-util-addr
\n"); + return -1; + } + + a = nl_addr_parse(argv[1], AF_UNSPEC); + if (a == NULL) { + fprintf(stderr, "Cannot parse address \"%s\"\n", argv[1]); + return -1; + } + + err = nl_addr_resolve(a, host, sizeof(host)); + if (err != 0) { + fprintf(stderr, "Cannot resolve address \"%s\": %d\n", + argv[1], err); + return -1; + } + + printf("%s\n", host); + + return 0; +}