From 4cbda53c050966e2ae9965c1e9742f06ca3eee77 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 27 Jun 2013 19:57:45 +0200 Subject: [rootfs-stage32] Add rdns tool for reverse DNS lookups --- remote/rootfs/rootfs-stage32/rdns.c | 28 +++++++++++++++++++++++ remote/rootfs/rootfs-stage32/rootfs-stage32.build | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 remote/rootfs/rootfs-stage32/rdns.c (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage32/rdns.c b/remote/rootfs/rootfs-stage32/rdns.c new file mode 100644 index 00000000..218f7400 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/rdns.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + if (argc != 2) { + fprintf(stderr,"usage: %s \n", argv[0]); + return 1; + } + + struct hostent *he; + struct in_addr ipv4addr; + struct in6_addr ipv6addr; + + inet_pton(AF_INET, argv[1], &ipv4addr); + he = gethostbyaddr(&ipv4addr, sizeof ipv4addr, AF_INET); + if (he == NULL) return 2; + if (he->h_name == NULL) return 3; + printf("%s\n", he->h_name); + + return 0; +} + diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index d3cddcd9..bd018adc 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -25,6 +25,10 @@ build() { perror "${BIN} not found on the system! Please install it." fi done + # Compile rdns + mkdir -p "$MODULE_BUILD_DIR/opt/openslx/bin" + gcc -o "$MODULE_BUILD_DIR/opt/openslx/bin/rdns" "$MODULE_DIR/rdns.c" || perror "Compiling rdns failed." + REQUIRED_BINARIES+=" rdns" pinfo "Searching libraries from config file in system... (could take some time)" for LIB in ${REQUIRED_LIBRARIES} -- cgit v1.2.3-55-g7522