clatd: change to pass in tun filedescriptor via command line
Test: atest clatd_test, built and installed on aosp_blueline device
connected to ipv6-only wifi network: ping 8.8.8.8 still works
and it is via v4-wlan0 clat tun interface
Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8c9e235e9a5bf1a1436e8dc3af8d0aa86f6dc1a5
diff --git a/tun.h b/tun.h
index 95650fa..05f62c1 100644
--- a/tun.h
+++ b/tun.h
@@ -18,7 +18,10 @@
#ifndef __TUN_H__
#define __TUN_H__
+#include <fcntl.h>
#include <linux/if.h>
+#include <sys/uio.h>
+#include <unistd.h>
#include "common.h"
#include "ring.h"
@@ -29,9 +32,19 @@
struct packet_ring ring;
};
+// tun_open and tun_alloc are defined in tun.c and only used by clatd_microbenchmark.c
int tun_open();
int tun_alloc(char *dev, int fd, size_t len);
-int send_tun(int fd, clat_packet out, int iov_len);
-int set_nonblocking(int fd);
+
+/* function: send_tun
+ * sends a clat_packet to a tun interface
+ * fd - the tun filedescriptor
+ * out - the packet to send
+ * iov_len - the number of entries in the clat_packet
+ * returns: number of bytes read on success, -1 on failure
+ */
+static inline int send_tun(int fd, clat_packet out, int iov_len) {
+ return writev(fd, out, iov_len);
+}
#endif