/*
device.c -- Interaction BSD tun/tap device
Copyright (C) 2001-2005 Ivo Timmermans,
- 2001-2017 Guus Sliepen <guus@tinc-vpn.org>
+ 2001-2021 Guus Sliepen <guus@tinc-vpn.org>
2009 Grzegorz Dymarek <gregd72002@googlemail.com>
This program is free software; you can redistribute it and/or modify
#include <net/if_utun.h>
#endif
+#if defined(HAVE_FREEBSD) || defined(HAVE_DRAGONFLY)
+#define DEFAULT_TUN_DEVICE "/dev/tun" // Use the autoclone device
+#define DEFAULT_TAP_DEVICE "/dev/tap"
+#else
#define DEFAULT_TUN_DEVICE "/dev/tun0"
#define DEFAULT_TAP_DEVICE "/dev/tap0"
+#endif
typedef enum device_type {
DEVICE_TYPE_TUN,
int device_fd = -1;
char *device = NULL;
char *iface = NULL;
-static char *device_info = NULL;
+static const char *device_info = "OS X utun device";
#if defined(ENABLE_TUNEMU)
static device_type_t device_type = DEVICE_TYPE_TUNEMU;
#elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD) || defined(HAVE_DRAGONFLY)
iface = xstrdup(name);
}
- device_info = "OS X utun device";
-
logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info);
return true;
struct ifreq ifr;
if(ioctl(device_fd, TAPGIFNAME, (void *)&ifr) == 0) {
- if(iface) {
- free(iface);
- }
-
+ free(iface);
iface = xstrdup(ifr.ifr_name);
}
}