summaryrefslogtreecommitdiff
path: root/klibc/klibc/inet/inet_ntoa.c
diff options
context:
space:
mode:
Diffstat (limited to 'klibc/klibc/inet/inet_ntoa.c')
-rw-r--r--klibc/klibc/inet/inet_ntoa.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/klibc/klibc/inet/inet_ntoa.c b/klibc/klibc/inet/inet_ntoa.c
new file mode 100644
index 0000000000..5340aa622a
--- /dev/null
+++ b/klibc/klibc/inet/inet_ntoa.c
@@ -0,0 +1,19 @@
+/*
+ * inet/inet_ntoa.c
+ */
+
+#include <arpa/inet.h>
+#include <stdio.h>
+
+char *inet_ntoa(struct in_addr addr)
+{
+ static char name[16];
+ union {
+ uint8_t b[4];
+ uint32_t l;
+ } a;
+ a.l = addr.s_addr;
+
+ sprintf(name, "%u.%u.%u.%u", a.b[0], a.b[1], a.b[2], a.b[3]);
+ return name;
+}