tinc/src/dummy_device.c

63 lines
1.7 KiB
C
Raw Normal View History

2009-10-24 14:05:12 +00:00
/*
device.c -- Dummy device
Copyright (C) 2011 Guus Sliepen <guus@tinc-vpn.org>
2009-10-24 14:05:12 +00:00
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "system.h"
#include "device.h"
2009-10-24 14:05:12 +00:00
#include "logger.h"
#include "net.h"
static char *device_info = "dummy device";
static uint64_t device_total_in = 0;
static uint64_t device_total_out = 0;
2009-10-24 14:05:12 +00:00
static bool setup_device(void) {
device = "dummy";
iface = "dummy";
2009-10-24 14:05:12 +00:00
logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info);
return true;
}
static void close_device(void) {
2009-10-24 14:05:12 +00:00
}
static bool read_packet(vpn_packet_t *packet) {
2009-10-24 14:05:12 +00:00
return false;
}
static bool write_packet(vpn_packet_t *packet) {
2009-10-24 14:05:12 +00:00
device_total_out += packet->len;
return true;
}
static void dump_device_stats(void) {
2009-10-24 14:05:12 +00:00
logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in);
logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
2009-10-24 14:05:12 +00:00
}
const devops_t dummy_devops = {
.setup = setup_device,
.close = close_device,
.read = read_packet,
.write = write_packet,
.dump_stats = dump_device_stats,
};