summaryrefslogtreecommitdiff
path: root/src/openvpn/tun.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvpn/tun.c')
-rw-r--r--src/openvpn/tun.c54
1 files changed, 21 insertions, 33 deletions
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 75a156c..a4f7779 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -16,9 +16,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program (see the file COPYING included with this
+ * distribution); if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
@@ -559,9 +560,7 @@ is_tun_p2p(const struct tuntap *tt)
{
bool tun = false;
- if (tt->type == DEV_TYPE_TAP
- || (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET)
- || tt->type == DEV_TYPE_NULL )
+ if (tt->type == DEV_TYPE_TAP || (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET))
{
tun = false;
}
@@ -695,8 +694,7 @@ init_tun(const char *dev, /* --dev option */
* make sure they do not clash with our virtual subnet.
*/
- for (curele = local_public; curele; curele = curele->ai_next)
- {
+ for (curele = local_public; curele; curele = curele->ai_next) {
if (curele->ai_family == AF_INET)
{
check_addr_clash("local",
@@ -707,8 +705,7 @@ init_tun(const char *dev, /* --dev option */
}
}
- for (curele = remote_public; curele; curele = curele->ai_next)
- {
+ for (curele = remote_public; curele; curele = curele->ai_next) {
if (curele->ai_family == AF_INET)
{
check_addr_clash("remote",
@@ -843,7 +840,7 @@ delete_route_connected_v6_net(struct tuntap *tt,
#endif /* if defined(_WIN32) || defined(TARGET_DARWIN) || defined(TARGET_NETBSD) || defined(TARGET_OPENBSD) */
#if defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) \
- || defined(TARGET_OPENBSD)
+ || defined(TARGET_OPENBSD) || defined(__FreeBSD_kernel__)
/* we can't use true subnet mode on tun on all platforms, as that
* conflicts with IPv6 (wants to use ND then, which we don't do),
* but the OSes want "a remote address that is different from ours"
@@ -1039,8 +1036,7 @@ do_ifconfig(struct tuntap *tt,
struct buffer out = alloc_buf_gc(64, &gc);
char *top;
- switch (tt->topology)
- {
+ switch (tt->topology) {
case TOP_NET30:
top = "net30";
break;
@@ -1412,7 +1408,7 @@ do_ifconfig(struct tuntap *tt,
add_route_connected_v6_net(tt, es);
}
-#elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY)
+#elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) || defined(__FreeBSD_kernel__)
in_addr_t remote_end; /* for "virtual" subnet topology */
@@ -1653,11 +1649,11 @@ write_tun_header(struct tuntap *tt, uint8_t *buf, int len)
{
u_int32_t type;
struct iovec iv[2];
- struct openvpn_iphdr *iph;
+ struct ip *iph;
- iph = (struct openvpn_iphdr *) buf;
+ iph = (struct ip *) buf;
- if (OPENVPN_IPH_GET_VER(iph->version_len) == 6)
+ if (iph->ip_v == 6)
{
type = htonl(AF_INET6);
}
@@ -1839,14 +1835,12 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
/* Prefer IPv6 DNS servers,
* Android will use the DNS server in the order we specify*/
- for (int i = 0; i < tt->options.dns6_len; i++)
- {
+ for (int i = 0; i < tt->options.dns6_len; i++) {
management_android_control(management, "DNS6SERVER",
print_in6_addr(tt->options.dns6[i], 0, &gc));
}
- for (int i = 0; i < tt->options.dns_len; i++)
- {
+ for (int i = 0; i < tt->options.dns_len; i++) {
management_android_control(management, "DNSSERVER",
print_in_addr_t(tt->options.dns[i], 0, &gc));
}
@@ -2260,9 +2254,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
{
ptr = dev;
while (*ptr && !isdigit((int) *ptr))
- {
ptr++;
- }
ppa = atoi(ptr);
}
@@ -2770,7 +2762,7 @@ read_tun(struct tuntap *tt, uint8_t *buf, int len)
}
}
-#elif defined(TARGET_FREEBSD)
+#elif defined(TARGET_FREEBSD)||defined(__FreeBSD_kernel__)
static inline int
freebsd_modify_read_write_return(int len)
@@ -3285,10 +3277,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
{
/* ensure that dev name is "tap+<digits>" *only* */
p = &dev[3];
- while (isdigit(*p) )
- {
- p++;
- }
+ while (isdigit(*p) ) p++;
if (*p != '\0')
{
msg( M_FATAL, "TAP device name must be '--dev tapNNNN'" );
@@ -5466,9 +5455,7 @@ write_dhcp_u32_array(struct buffer *buf, const int type, const uint32_t *data, c
buf_write_u8(buf, type);
buf_write_u8(buf, size);
for (i = 0; i < len; ++i)
- {
buf_write_u32(buf, data[i]);
- }
}
}
@@ -6237,7 +6224,10 @@ close_tun(struct tuntap *tt)
}
#endif
- dhcp_release(tt);
+ if (tt->options.dhcp_release)
+ {
+ dhcp_release(tt);
+ }
if (tt->hand != NULL)
{
@@ -6297,12 +6287,10 @@ ascii2ipset(const char *name)
int i;
ASSERT(IPW32_SET_N == SIZE(ipset_names));
for (i = 0; i < IPW32_SET_N; ++i)
- {
if (!strcmp(name, ipset_names[i].short_form))
{
return i;
}
- }
return -1;
}