From 9bcd2005d1f0368bebf787d95d07abe5fc5125eb Mon Sep 17 00:00:00 2001 From: Gert Doering Date: Thu, 14 Jan 2010 15:21:05 +0100 Subject: NetBSD fixes - on 4.0 and up, use multi-af mode. On earlier systems that do not have TUNSIFHEAD (and do not have IPv6 capable tunnels), fall back to old IPv4-only code without address-family prepending. (cherry picked from commit 2a57c58b185deb11b0a62c584489fff59258146c) --- tun.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'tun.c') diff --git a/tun.c b/tun.c index 88e1f0f..37560e2 100644 --- a/tun.c +++ b/tun.c @@ -1973,15 +1973,6 @@ read_tun (struct tuntap* tt, uint8_t *buf, int len) * */ -static inline int -netbsd_modify_read_write_return (int len) -{ - if (len > 0) - return len > sizeof (u_int32_t) ? len - sizeof (u_int32_t) : 0; - else - return len; -} - void open_tun (const char *dev, const char *dev_type, const char *dev_node, bool ipv6, struct tuntap *tt) { @@ -2083,46 +2074,12 @@ read_tun (struct tuntap* tt, uint8_t *buf, int len) int write_tun (struct tuntap* tt, uint8_t *buf, int len) { - if (tt->type == DEV_TYPE_TUN) - { - u_int32_t type; - struct iovec iv[2]; - struct openvpn_iphdr *iph; - - iph = (struct openvpn_iphdr *) buf; - - if (tt->ipv6 && OPENVPN_IPH_GET_VER(iph->version_len) == 6) - type = htonl (AF_INET6); - else - type = htonl (AF_INET); - - iv[0].iov_base = (char *)&type; - iv[0].iov_len = sizeof (type); - iv[1].iov_base = buf; - iv[1].iov_len = len; - - return netbsd_modify_read_write_return (writev (tt->fd, iv, 2)); - } - else return write (tt->fd, buf, len); } int read_tun (struct tuntap* tt, uint8_t *buf, int len) { - if (tt->type == DEV_TYPE_TUN) - { - u_int32_t type; - struct iovec iv[2]; - - iv[0].iov_base = (char *)&type; - iv[0].iov_len = sizeof (type); - iv[1].iov_base = buf; - iv[1].iov_len = len; - - return netbsd_modify_read_write_return (readv (tt->fd, iv, 2)); - } - else return read (tt->fd, buf, len); } #endif /* NETBSD_MULTI_AF */ -- cgit