From 431c88102153b8b41a15a1105e291ecf161c030e Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Wed, 18 Nov 2020 13:49:19 +0100
Subject: Started libnet

---
 libnet/inc/net.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 libnet/inc/net.h

(limited to 'libnet/inc')

diff --git a/libnet/inc/net.h b/libnet/inc/net.h
new file mode 100644
index 0000000..836e181
--- /dev/null
+++ b/libnet/inc/net.h
@@ -0,0 +1,25 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#ifndef NET_H
+#define NET_H
+
+#include <socket.h>
+
+#define htonl(l)                                                                                   \
+	((((l)&0xff) << 24) | (((l)&0xff00) << 8) | (((l)&0xff0000) >> 8) |                        \
+	 (((l)&0xff000000) >> 24))
+#define htons(s) ((((s)&0xff) << 8) | (((s)&0xff00) >> 8))
+#define ntohl(l) htonl((l))
+#define ntohs(s) htons((s))
+#define ip(a, b, c, d)                                                                             \
+	((((a)&0xff) << 24) | (((b)&0xff) << 16) | (((c)&0xff) << 8) | (((d)&0xff) << 0))
+
+#define net_open(type) (void *)sys1(SYS_NET_OPEN, (int)(type))
+#define net_close(socket) (void)sys1(SYS_NET_CLOSE, (int)(type))
+#define net_connect(socket, ip_addr, dst_port)                                                     \
+	(int)sys3(SYS_NET_CONNECT, (int)(socket), (int)(ip_addr), (int)(dst_port))
+#define net_send(socket, data, len) (void)sys3(SYS_NET_SEND, (int)(socket), (int)(data), (int)(len))
+
+void dns_request(const char *name, const char *tld);
+
+#endif
-- 
cgit v1.2.3