]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
NetBSD fixes - on 4.0 and up, use multi-af mode. On earlier systems that
authorGert Doering <gert@greenie.muc.de>
Thu, 14 Jan 2010 14:21:05 +0000 (15:21 +0100)
committerGert Doering <gert@greenie.muc.de>
Sun, 24 Apr 2011 15:22:38 +0000 (17:22 +0200)
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

diff --git a/tun.c b/tun.c
index 88e1f0fea9c0ba9353944dc98e358b977a57ba57..37560e2faebbefd2a33d5bdaedd21f2defa40c81 100644 (file)
--- 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 */