]> git.meshlink.io Git - meshlink/blobdiff - src/linux/device.c
Started the implementation of route_meshlink that at the moment routes packets based...
[meshlink] / src / linux / device.c
index 18f1b6e574686219b432566656bc1188d2a8b0c1..6ed1622c08a5f1442174f459e07db4351f93fcdd 100644 (file)
@@ -1,7 +1,7 @@
 /*
     device.c -- Interaction with Linux ethertap and tun/tap device
     Copyright (C) 2001-2005 Ivo Timmermans,
-                  2001-2012 Guus Sliepen <guus@tinc-vpn.org>
+                  2001-2013 Guus Sliepen <guus@tinc-vpn.org>
 
     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
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#include "system.h"
+#include "../system.h"
 
 #include <linux/if_tun.h>
 #define DEFAULT_DEVICE "/dev/net/tun"
 
-#include "conf.h"
-#include "device.h"
-#include "logger.h"
-#include "net.h"
-#include "route.h"
-#include "utils.h"
-#include "xalloc.h"
-#include "device.h"
+#include "../conf.h"
+#include "../device.h"
+#include "../logger.h"
+#include "../names.h"
+#include "../net.h"
+#include "../route.h"
+#include "../utils.h"
+#include "../xalloc.h"
+#include "../device.h"
 
 typedef enum device_type_t {
        DEVICE_TYPE_TUN,
@@ -45,11 +46,6 @@ static char *type = NULL;
 static char ifrname[IFNAMSIZ];
 static char *device_info;
 
-uint64_t device_in_packets = 0;
-uint64_t device_in_bytes = 0;
-uint64_t device_out_packets = 0;
-uint64_t device_out_bytes = 0;
-
 static bool setup_device(void) {
        if(!get_config_string(lookup_config(config_tree, "Device"), &device))
                device = xstrdup(DEFAULT_DEVICE);
@@ -83,6 +79,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)";
@@ -149,9 +147,6 @@ static bool read_packet(vpn_packet_t *packet) {
                        abort();
        }
 
-       device_in_packets++;
-       device_in_bytes += packet->len;
-
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
@@ -182,22 +177,12 @@ static bool write_packet(vpn_packet_t *packet) {
                        abort();
        }
 
-       device_out_packets++;
-       device_out_bytes += packet->len;
-
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_in_bytes);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_out_bytes);
-}
-
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };