diff options
author | Jonathan Bauer | 2019-08-07 11:34:35 +0200 |
---|---|---|
committer | Jonathan Bauer | 2019-08-07 11:34:35 +0200 |
commit | 8a090d4aff93d1ba69d7d4d8d89795270e85a4d6 (patch) | |
tree | 62220458d6c5a444cf4928dfce744283be8a092d /core/modules/rdns | |
parent | [vmchooser2] add default xsessions.conf (diff) | |
download | mltk-8a090d4aff93d1ba69d7d4d8d89795270e85a4d6.tar.gz mltk-8a090d4aff93d1ba69d7d4d8d89795270e85a4d6.tar.xz mltk-8a090d4aff93d1ba69d7d4d8d89795270e85a4d6.zip |
[rdns] move rdns to its own module
Diffstat (limited to 'core/modules/rdns')
-rw-r--r-- | core/modules/rdns/module.build | 15 | ||||
-rw-r--r-- | core/modules/rdns/module.conf | 4 | ||||
-rw-r--r-- | core/modules/rdns/rdns.c | 28 |
3 files changed, 47 insertions, 0 deletions
diff --git a/core/modules/rdns/module.build b/core/modules/rdns/module.build new file mode 100644 index 00000000..1469a09f --- /dev/null +++ b/core/modules/rdns/module.build @@ -0,0 +1,15 @@ +#!/bin/bash + +fetch_source() { + : +} + +build() { + 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." +} + +post_copy() { + : +} + diff --git a/core/modules/rdns/module.conf b/core/modules/rdns/module.conf new file mode 100644 index 00000000..049b374f --- /dev/null +++ b/core/modules/rdns/module.conf @@ -0,0 +1,4 @@ +#!/bin/bash +REQUIRED_BINARIES=" + rdns +" diff --git a/core/modules/rdns/rdns.c b/core/modules/rdns/rdns.c new file mode 100644 index 00000000..218f7400 --- /dev/null +++ b/core/modules/rdns/rdns.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <errno.h> +#include <netdb.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +int main(int argc, char *argv[]) +{ + if (argc != 2) { + fprintf(stderr,"usage: %s <IPADDRESS>\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; +} + |