diff options
author | Gert Doering <gert@greenie.muc.de> | 2010-01-14 15:21:05 +0100 |
---|---|---|
committer | Gert Doering <gert@greenie.muc.de> | 2011-04-24 17:22:38 +0200 |
commit | 9bcd2005d1f0368bebf787d95d07abe5fc5125eb (patch) | |
tree | 8b1f2d0c0b2aa29c22a0839513018bc1e09e8573 /tun.c | |
parent | 24393600b068569e78f69ab36d3ee21f00abea23 (diff) | |
download | openvpn-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.c | 43 |
1 files changed, 0 insertions, 43 deletions
@@ -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 */ |