diff options
| author | Maciej enczykowski <maze@google.com> | 2019-05-10 01:11:21 -0700 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2019-05-10 01:11:21 -0700 |
| commit | c6125e3fa6d14b1ccd80b18850e961b4c4e5b4a5 (patch) | |
| tree | ac9a90d6280e22785aaca68db210bf5612ea1b13 /tun.c | |
| parent | ef38b0dc2e2f964b2d6b17de65bf79a7867bef73 (diff) | |
| parent | 8addcc0f6360cc3762e9ef27437ded250e785da3 (diff) | |
| download | platform_external_android-clat-android10-qpr1-b-release.tar.gz platform_external_android-clat-android10-qpr1-b-release.tar.bz2 platform_external_android-clat-android10-qpr1-b-release.zip | |
clatd: change to pass in tun filedescriptor via command lineandroid-10.0.0_r29android-10.0.0_r28android-10.0.0_r27android-10.0.0_r26android-10.0.0_r25android-10.0.0_r24android-10.0.0_r23android-10.0.0_r22android-10.0.0_r21android-10.0.0_r20android-10.0.0_r19android-10.0.0_r18android-10.0.0_r16android-10.0.0_r15android10-qpr1-releaseandroid10-qpr1-d-releaseandroid10-qpr1-c-s1-releaseandroid10-qpr1-c-releaseandroid10-qpr1-b-s1-releaseandroid10-qpr1-b-release
am: 8addcc0f63
Change-Id: I7f983ba1b6d54d70db1f2fdec35e38984c7c4388
Diffstat (limited to 'tun.c')
| -rw-r--r-- | tun.c | 29 |
1 files changed, 3 insertions, 26 deletions
@@ -21,20 +21,19 @@ #include <linux/if_tun.h> #include <string.h> #include <sys/ioctl.h> -#include <sys/uio.h> #include <unistd.h> #include "common.h" /* function: tun_open - * tries to open the tunnel device + * tries to open the tunnel device in non-blocking mode */ int tun_open() { int fd; - fd = open("/dev/tun", O_RDWR | O_CLOEXEC); + fd = open("/dev/tun", O_RDWR | O_NONBLOCK | O_CLOEXEC); if (fd < 0) { - fd = open("/dev/net/tun", O_RDWR | O_CLOEXEC); + fd = open("/dev/net/tun", O_RDWR | O_NONBLOCK | O_CLOEXEC); } return fd; @@ -65,25 +64,3 @@ int tun_alloc(char *dev, int fd, size_t len) { strlcpy(dev, ifr.ifr_name, len); return 0; } - -/* function: set_nonblocking - * sets a filedescriptor to non-blocking mode - * fd - the filedescriptor - * returns: 0 on success, -1 on failure - */ -int set_nonblocking(int fd) { - int flags = fcntl(fd, F_GETFL); - if (flags == -1) { - return flags; - } - return fcntl(fd, F_SETFL, flags | O_NONBLOCK); -} - -/* 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 - */ -int send_tun(int fd, clat_packet out, int iov_len) { return writev(fd, out, iov_len); } |
