X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Flinux%2Fdevice.c;h=3c609017e06a63a07817f2b7691ec83748d4e112;hp=cbf215298dd635e8ff1d2cb869c6d93d114e4862;hb=9f4390f5708fa31eb0afa3f5cf45eac80d7b458c;hpb=d1dcdf8eb6f800704be426b1ce6f6c1a8e65ba0d diff --git a/src/linux/device.c b/src/linux/device.c index cbf21529..3c609017 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Linux ethertap and tun/tap device Copyright (C) 2001-2005 Ivo Timmermans, - 2001-2012 Guus Sliepen + 2001-2013 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -94,6 +94,8 @@ static bool setup_device(void) { device_type = DEVICE_TYPE_TUN; device_info = "Linux tun/tap device (tun mode)"; } else { + if (routing_mode == RMODE_ROUTER) + overwrite_mac = true; ifr.ifr_flags = IFF_TAP | IFF_NO_PI; device_type = DEVICE_TYPE_TAP; device_info = "Linux tun/tap device (tap mode)"; @@ -155,6 +157,7 @@ static bool read_packet(vpn_packet_t *packet) { return false; } + memset(packet->data, 0, 12); packet->len = lenin + 10; break; case DEVICE_TYPE_TAP: @@ -210,7 +213,7 @@ static bool write_packet(vpn_packet_t *packet) { } break; case DEVICE_TYPE_ETHERTAP: - *(short int *)(packet->data - 2) = packet->len; + memcpy(packet->data - 2, &packet->len, 2); if(write(device_fd, packet->data - 2, packet->len + 2) < 0) { logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device,