Add iface.[ch]

This commit is contained in:
Adrien Gallouët
2017-03-07 10:33:28 +00:00
parent eb5c6853c1
commit 195908d379
6 changed files with 36 additions and 25 deletions

View File

@@ -239,29 +239,6 @@ tun_write(int fd, const void *data, size_t size)
#endif
}
int
tun_set_mtu(char *dev_name, int mtu)
{
struct ifreq ifr = {
.ifr_mtu = mtu,
};
str_cpy(ifr.ifr_name, dev_name, IFNAMSIZ - 1);
int fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1)
return -1;
int ret = ioctl(fd, SIOCSIFMTU, &ifr);
int err = errno;
close(fd);
errno = err;
return ret;
}
int
tun_set_persist(int fd, int on)
{