Use 64 bit counters to keep track of bytes sent/received from the virtual network...
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 4 Jun 2010 13:04:08 +0000 (15:04 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 4 Jun 2010 13:04:08 +0000 (15:04 +0200)
src/bsd/device.c
src/cygwin/device.c
src/dummy/device.c
src/linux/device.c
src/mingw/device.c
src/raw_socket/device.c
src/solaris/device.c
src/uml_socket/device.c

index 6674abd209a23aa7763073097081114e263431ee..e8fdc1bc3abc94b603f022f8382c415d39babb96 100644 (file)
@@ -47,8 +47,8 @@ int device_fd = -1;
 char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
 char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
-static int device_total_in = 0;
-static int device_total_out = 0;
+static uint64_t device_total_in = 0;
+static uint64_t device_total_out = 0;
 #if defined(TUNEMU)
 static device_type_t device_type = DEVICE_TYPE_TUNEMU;
 #elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD)
 #if defined(TUNEMU)
 static device_type_t device_type = DEVICE_TYPE_TUNEMU;
 #elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD)
@@ -353,6 +353,6 @@ bool write_packet(vpn_packet_t *packet) {
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(LOG_DEBUG, " total bytes in:  %10d", device_total_in);
-       logger(LOG_DEBUG, " total bytes out: %10d", device_total_out);
+       logger(LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
+       logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
 }
 }
index 958184bdef21f3a1fdbe307052c84ddb68def186..90966cd2419d0a7c724a00dba864ab074e37e47a 100644 (file)
@@ -38,8 +38,8 @@ char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
 
 char *iface = NULL;
 static char *device_info = NULL;
 
-static int device_total_in = 0;
-static int device_total_out = 0;
+static uint64_t device_total_in = 0;
+static uint64_t device_total_out = 0;
 
 static pid_t reader_pid;
 static int sp[2];
 
 static pid_t reader_pid;
 static int sp[2];
@@ -261,6 +261,6 @@ bool write_packet(vpn_packet_t *packet) {
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(LOG_DEBUG, " total bytes in:  %10d", device_total_in);
-       logger(LOG_DEBUG, " total bytes out: %10d", device_total_out);
+       logger(LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
+       logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
 }
 }
index a9600b280af320221d3c34908a1488736b2d1745..c84e899ba400bd77109893b012ea7fc2197ad2da 100644 (file)
@@ -27,8 +27,8 @@ char *device = "dummy";
 char *iface = "dummy";
 static char *device_info = "dummy device";
 
 char *iface = "dummy";
 static char *device_info = "dummy device";
 
-static int device_total_in = 0;
-static int device_total_out = 0;
+static uint64_t device_total_in = 0;
+static uint64_t device_total_out = 0;
 
 bool setup_device(void) {
        logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info);
 
 bool setup_device(void) {
        logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info);
@@ -49,6 +49,6 @@ bool write_packet(vpn_packet_t *packet) {
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(LOG_DEBUG, " total bytes in:  %10d", device_total_in);
-       logger(LOG_DEBUG, " total bytes out: %10d", device_total_out);
+       logger(LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
+       logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
 }
 }
index 6363b126c3d9c4643ff5da7ccfd2d80ebc8c1c81..6c828c01d84f1909ab15ae8093a7ab56c7f71e9e 100644 (file)
@@ -47,8 +47,8 @@ char *iface = NULL;
 static char ifrname[IFNAMSIZ];
 static char *device_info;
 
 static char ifrname[IFNAMSIZ];
 static char *device_info;
 
-static int device_total_in = 0;
-static int device_total_out = 0;
+static uint64_t device_total_in = 0;
+static uint64_t device_total_out = 0;
 
 bool setup_device(void) {
        struct ifreq ifr;
 
 bool setup_device(void) {
        struct ifreq ifr;
@@ -205,6 +205,6 @@ bool write_packet(vpn_packet_t *packet) {
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(LOG_DEBUG, " total bytes in:  %10d", device_total_in);
-       logger(LOG_DEBUG, " total bytes out: %10d", device_total_out);
+       logger(LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
+       logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
 }
 }
index c0f5d296a18c56c7b5b82af43a6be06bb462ae4e..cbaa19e51d2296a3243ee1b1bebbb92ac467e52f 100644 (file)
@@ -38,8 +38,8 @@ char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
 
 char *iface = NULL;
 static char *device_info = NULL;
 
-static int device_total_in = 0;
-static int device_total_out = 0;
+static uint64_t device_total_in = 0;
+static uint64_t device_total_out = 0;
 
 extern char *myport;
 
 
 extern char *myport;
 
@@ -247,6 +247,6 @@ bool write_packet(vpn_packet_t *packet) {
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(LOG_DEBUG, " total bytes in:  %10d", device_total_in);
-       logger(LOG_DEBUG, " total bytes out: %10d", device_total_out);
+       logger(LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
+       logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
 }
 }
index 30bb1845cc2b5bbe4c719ad12b95eab0f4b773c6..f68e461973f6159085d19f5e917d9566e05e7a78 100644 (file)
@@ -35,8 +35,8 @@ char *iface = NULL;
 static char ifrname[IFNAMSIZ];
 static char *device_info;
 
 static char ifrname[IFNAMSIZ];
 static char *device_info;
 
-static int device_total_in = 0;
-static int device_total_out = 0;
+static uint64_t device_total_in = 0;
+static uint64_t device_total_out = 0;
 
 bool setup_device(void) {
        struct ifreq ifr;
 
 bool setup_device(void) {
        struct ifreq ifr;
@@ -123,6 +123,6 @@ bool write_packet(vpn_packet_t *packet) {
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(LOG_DEBUG, " total bytes in:  %10d", device_total_in);
-       logger(LOG_DEBUG, " total bytes out: %10d", device_total_out);
+       logger(LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
+       logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
 }
 }
index e26dc06c4d8ed84bcdc959692d8083ac9b8bf08e..9018c31a0811011ee661aafb88b32846019e3a08 100644 (file)
@@ -38,8 +38,8 @@ char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
 
 char *iface = NULL;
 static char *device_info = NULL;
 
-static int device_total_in = 0;
-static int device_total_out = 0;
+static uint64_t device_total_in = 0;
+static uint64_t device_total_out = 0;
 
 bool setup_device(void) {
        int ip_fd = -1, if_fd = -1;
 
 bool setup_device(void) {
        int ip_fd = -1, if_fd = -1;
@@ -163,6 +163,6 @@ bool write_packet(vpn_packet_t *packet) {
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(LOG_DEBUG, " total bytes in:  %10d", device_total_in);
-       logger(LOG_DEBUG, " total bytes out: %10d", device_total_out);
+       logger(LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
+       logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
 }
 }
index 3523f6471f277521cfd3966d144ef4e0f3bae5f6..59551b4f51b1d94a4d15c69d24dbb6babc8710cf 100644 (file)
@@ -41,8 +41,8 @@ static char *device_info;
 extern char *identname;
 extern bool running;
 
 extern char *identname;
 extern bool running;
 
-static int device_total_in = 0;
-static int device_total_out = 0;
+static uint64_t device_total_in = 0;
+static uint64_t device_total_out = 0;
 
 enum request_type { REQ_NEW_CONTROL };
 
 
 enum request_type { REQ_NEW_CONTROL };
 
@@ -272,6 +272,6 @@ bool write_packet(vpn_packet_t *packet) {
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
 
 void dump_device_stats(void) {
        logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(LOG_DEBUG, " total bytes in:  %10d", device_total_in);
-       logger(LOG_DEBUG, " total bytes out: %10d", device_total_out);
+       logger(LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
+       logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
 }
 }