summaryrefslogtreecommitdiff
path: root/package/resolveip/src/resolveip.c
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-10 12:32:29 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-10 12:32:29 +0000
commit9c8997d54dc9df184bfcedeabf0b3c85cf5e6753 (patch)
tree46b83031a0da1b4458317413c00d13c252c72afa /package/resolveip/src/resolveip.c
parenteecf5b17520f6b3b6ffb45ac7dca298d93b27501 (diff)
packages: sort network related packages into package/network/
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33688 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/resolveip/src/resolveip.c')
-rw-r--r--package/resolveip/src/resolveip.c98
1 files changed, 0 insertions, 98 deletions
diff --git a/package/resolveip/src/resolveip.c b/package/resolveip/src/resolveip.c
deleted file mode 100644
index 310f35ffd5..0000000000
--- a/package/resolveip/src/resolveip.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Based on code found at https://dev.openwrt.org/ticket/4876 .
- * Extended by Jo-Philipp Wich <jow@openwrt.org> for use in OpenWrt.
- *
- * You may use this program under the terms of the GPLv2 license.
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-
-
-static void abort_query(int sig)
-{
- exit(1);
-}
-
-static void show_usage(void)
-{
- printf("Usage:\n");
- printf(" resolveip -h\n");
- printf(" resolveip [-t timeout] hostname\n");
- printf(" resolveip -4 [-t timeout] hostname\n");
- printf(" resolveip -6 [-t timeout] hostname\n");
- exit(255);
-}
-
-int main(int argc, char **argv)
-{
- int timeout = 3;
- char opt;
- char ipaddr[INET6_ADDRSTRLEN];
- void *addr;
- struct addrinfo *res, *rp;
- struct sigaction sa = { .sa_handler = &abort_query };
- struct addrinfo hints = {
- .ai_family = AF_UNSPEC,
- .ai_socktype = SOCK_STREAM,
- .ai_protocol = IPPROTO_TCP,
- .ai_flags = 0
- };
-
- while ((opt = getopt(argc, argv, "46t:h")) > -1)
- {
- switch (opt)
- {
- case '4':
- hints.ai_family = AF_INET;
- break;
-
- case '6':
- hints.ai_family = AF_INET6;
- break;
-
- case 't':
- timeout = atoi(optarg);
- if (timeout <= 0)
- show_usage();
- break;
-
- case 'h':
- show_usage();
- break;
- }
- }
-
- if (!argv[optind])
- show_usage();
-
- sigaction(SIGALRM, &sa, NULL);
- alarm(timeout);
-
- if (getaddrinfo(argv[optind], NULL, &hints, &res))
- exit(2);
-
- for (rp = res; rp != NULL; rp = rp->ai_next)
- {
- addr = (rp->ai_family == AF_INET)
- ? (void *)&((struct sockaddr_in *)rp->ai_addr)->sin_addr
- : (void *)&((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr
- ;
-
- if (!inet_ntop(rp->ai_family, addr, ipaddr, INET6_ADDRSTRLEN - 1))
- exit(3);
-
- printf("%s\n", ipaddr);
- }
-
- freeaddrinfo(res);
- exit(0);
-}