summaryrefslogtreecommitdiffstats
path: root/tun.c
diff options
context:
space:
mode:
authorGert Doering <gert@greenie.muc.de>2010-01-14 15:21:05 +0100
committerGert Doering <gert@greenie.muc.de>2011-04-24 17:22:38 +0200
commit9bcd2005d1f0368bebf787d95d07abe5fc5125eb (patch)
tree8b1f2d0c0b2aa29c22a0839513018bc1e09e8573 /tun.c
parent24393600b068569e78f69ab36d3ee21f00abea23 (diff)
downloadopenvpn-9bcd2005d1f0368bebf787d95d07abe5fc5125eb.tar.gz
openvpn-9bcd2005d1f0368bebf787d95d07abe5fc5125eb.tar.xz
openvpn-9bcd2005d1f0368bebf787d95d07abe5fc5125eb.zip
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)
Diffstat (limited to 'tun.c')
-rw-r--r--tun.c43
1 files changed, 0 insertions, 43 deletions
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 */