X-Git-Url: http://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fraw_socket%2Fdevice.c;h=5cefbce843795f3fe0268142e53ae506ef8d28e1;hb=5dde6461a321ee47b06e33f8203f2acf00a31a51;hp=b96f06f4e46a0f61600fa31168f7aa2471d49bd6;hpb=b069da90d67b49dce041f513a3855b8da3d82f80;p=tinc diff --git a/src/raw_socket/device.c b/src/raw_socket/device.c index b96f06f4..5cefbce8 100644 --- a/src/raw_socket/device.c +++ b/src/raw_socket/device.c @@ -1,7 +1,7 @@ /* device.c -- raw socket Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2006 Guus Sliepen + 2002-2009 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 @@ -13,11 +13,9 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id$ + 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" @@ -32,16 +30,15 @@ #include "xalloc.h" int device_fd = -1; -char *device; -char *iface; +char *device = NULL; +char *iface = NULL; static char ifrname[IFNAMSIZ]; static char *device_info; static int device_total_in = 0; static int device_total_out = 0; -bool setup_device(void) -{ +bool setup_device(void) { struct ifreq ifr; struct sockaddr_ll sa; @@ -85,15 +82,16 @@ bool setup_device(void) return true; } -void close_device(void) -{ +void close_device(void) { cp(); close(device_fd); + + free(device); + free(iface); } -bool read_packet(vpn_packet_t *packet) -{ +bool read_packet(vpn_packet_t *packet) { int lenin; cp(); @@ -114,8 +112,7 @@ bool read_packet(vpn_packet_t *packet) return true; } -bool write_packet(vpn_packet_t *packet) -{ +bool write_packet(vpn_packet_t *packet) { cp(); ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), @@ -132,8 +129,7 @@ bool write_packet(vpn_packet_t *packet) return true; } -void dump_device_stats(void) -{ +void dump_device_stats(void) { cp(); logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);