X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fbsd%2Fdevice.c;h=4b33d7617f4a3b8f1e4e64d658cfa7fca671e152;hb=72642b40b3ad476101622da202b6f977a32b472f;hp=f8a559686f75b7b55a2b7b1b1309450a7761a264;hpb=19be9cf7150858311f7898fa3fb525d692d02f64;p=tinc diff --git a/src/bsd/device.c b/src/bsd/device.c index f8a55968..4b33d761 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -33,7 +33,12 @@ #include "bsd/tunemu.h" #endif -#define DEFAULT_DEVICE "/dev/tun0" +#define DEFAULT_TUN_DEVICE "/dev/tun0" +#if defined(HAVE_FREEBSD) || defined(HAVE_NETBSD) +#define DEFAULT_TAP_DEVICE "/dev/tap0" +#else +#define DEFAULT_TAP_DEVICE "/dev/tun0" +#endif typedef enum device_type { DEVICE_TYPE_TUN, @@ -61,8 +66,12 @@ static device_type_t device_type = DEVICE_TYPE_TUN; static bool setup_device(void) { char *type; - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) - device = xstrdup(DEFAULT_DEVICE); + if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { + if(routing_mode == RMODE_ROUTER) + device = xstrdup(DEFAULT_TUN_DEVICE); + else + device = xstrdup(DEFAULT_TAP_DEVICE); + } if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); @@ -229,6 +238,7 @@ static bool read_packet(vpn_packet_t *packet) { return false; } + memset(packet->data, 0, 12); packet->len = inlen + 14; break; @@ -260,6 +270,7 @@ static bool read_packet(vpn_packet_t *packet) { return false; } + memset(packet->data, 0, 12); packet->len = inlen + 10; break; }