Simplify logging, update copyrights and some minor cleanups.

This commit is contained in:
Guus Sliepen 2003-07-12 17:41:48 +00:00
parent 2a7f11c0e9
commit 5db596c684
55 changed files with 501 additions and 555 deletions

3
THANKS
View file

@ -23,8 +23,9 @@ We would like to thank
* Ivo van Dong (for help during the early versions of tinc)
* Jeroen Ubbink (for help testing tinc on Free- and NetBSD)
* LarstiQ (for help testing tinc on MacOS/X)
* Marc A. Lehmann (for bitching and valid criticism)
* Marc A. Lehmann (for criticism)
* Teemu Kiviniemi (for his lzo compression patch)
* Flynn Marquardt (for help testing tinc on Solaris 2.6)
for their help, support and ideas. Thank you guys!

View file

@ -2,17 +2,10 @@
# This file sets up the tap device.
# It gives you the freedom to do anything you want with it.
# Use the correct name for the tap device:
# For the Linux tun/tap device $INTERFACE is set to the right name,
# but for ethertap and FreeBSD this is tap0, tap1, tap2 etcetera,
# for Solaris and OpenBSD it is tun0, tun1, etcetera.
# Set hardware ethernet address, needed on Linux when in router mode
ifconfig $INTERFACE hw ether fe:fd:0:0:0:0
# The environment variable $INTERFACE is set to the right name
# on most platforms, but if it doesn't work try to set it manually.
# Give it the right ip and netmask. Remember, the subnet of the
# tap device must be larger than that of the individual Subnets
# as defined in the host configuration file!
ifconfig $INTERFACE 192.168.1.1 netmask 255.255.0.0
# Disable ARP, needed on Linux when in router mode
ifconfig $INTERFACE -arp

View file

@ -15,11 +15,8 @@ Name = alpha
# May be used multiple times for redundance.
ConnectTo = beta
# The tap device tinc will use. Required.
# The tap device tinc will use.
# Default is /dev/tap0 for ethertap or FreeBSD,
# /dev/tun0 for Solaris and OpenBSD,
# and /dev/net/tun for Linux tun/tap device.
Device = /dev/net/tun
# The file in which the private key for this host is stored. Required.
PrivateKeyFile = /etc/tinc/example/rsa_key.priv

View file

@ -1,5 +1,5 @@
\input texinfo @c -*-texinfo-*-
@c $Id: tinc.texi,v 1.8.4.37 2003/06/12 11:08:40 guus Exp $
@c $Id: tinc.texi,v 1.8.4.38 2003/07/12 17:41:45 guus Exp $
@c %**start of header
@setfilename tinc.info
@settitle tinc Manual
@ -14,11 +14,11 @@
This is the info manual for tinc, a Virtual Private Network daemon.
Copyright @copyright{} 1998-2002 Ivo Timmermans
Copyright @copyright{} 1998-2003 Ivo Timmermans
<ivo@@o2w.nl>, Guus Sliepen <guus@@sliepen.eu.org> and
Wessel Dankers <wsl@@nl.linux.org>.
$Id: tinc.texi,v 1.8.4.37 2003/06/12 11:08:40 guus Exp $
$Id: tinc.texi,v 1.8.4.38 2003/07/12 17:41:45 guus Exp $
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
@ -39,11 +39,11 @@ permission notice identical to this one.
@page
@vskip 0pt plus 1filll
@cindex copyright
Copyright @copyright{} 1998-2002 Ivo Timmermans
Copyright @copyright{} 1998-2003 Ivo Timmermans
<ivo@@o2w.nl>, Guus Sliepen <guus@@sliepen.eu.org> and
Wessel Dankers <wsl@@nl.linux.org>.
$Id: tinc.texi,v 1.8.4.37 2003/06/12 11:08:40 guus Exp $
$Id: tinc.texi,v 1.8.4.38 2003/07/12 17:41:45 guus Exp $
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are

View file

@ -29,7 +29,7 @@
library for inclusion into tinc (http://tinc.nl.linux.org/) by
Guus Sliepen <guus@sliepen.eu.org>.
$Id: avl_tree.h,v 1.1.2.7 2002/09/09 22:32:27 guus Exp $
$Id: avl_tree.h,v 1.1.2.8 2003/07/12 17:41:45 guus Exp $
*/

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: dropin.c,v 1.1.2.12 2002/09/09 21:49:16 guus Exp $
$Id: dropin.c,v 1.1.2.13 2003/07/12 17:41:45 guus Exp $
*/
#include "config.h"

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: dropin.h,v 1.1.2.9 2002/09/09 21:49:16 guus Exp $
$Id: dropin.h,v 1.1.2.10 2003/07/12 17:41:45 guus Exp $
*/
#ifndef __DROPIN_H__

View file

@ -5,7 +5,7 @@
* See getaddrinfo.c and getnameinfo.c.
*/
/* $Id: fake-gai-errnos.h,v 1.1.2.1 2002/07/12 11:45:21 guus Exp $ */
/* $Id: fake-gai-errnos.h,v 1.1.2.2 2003/07/12 17:41:45 guus Exp $ */
/* for old netdb.h */
#ifndef EAI_NODATA

View file

@ -1,4 +1,4 @@
/* $Id: fake-getnameinfo.h,v 1.1.2.1 2002/07/12 11:45:21 guus Exp $ */
/* $Id: fake-getnameinfo.h,v 1.1.2.2 2003/07/12 17:41:45 guus Exp $ */
#ifndef _FAKE_GETNAMEINFO_H
#define _FAKE_GETNAMEINFO_H

View file

@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: list.c,v 1.1.2.13 2002/09/09 22:32:27 guus Exp $
$Id: list.c,v 1.1.2.14 2003/07/12 17:41:45 guus Exp $
*/
#include "config.h"

View file

@ -1,8 +1,8 @@
/*
conf.c -- configuration code
Copyright (C) 1998 Robert van der Meulen
1998-2002 Ivo Timmermans <ivo@o2w.nl>
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
1998-2003 Ivo Timmermans <ivo@o2w.nl>
2000-2003 Guus Sliepen <guus@sliepen.eu.org>
2000 Cris van Pelt <tribbel@arise.dhs.org>
This program is free software; you can redistribute it and/or modify
@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: conf.c,v 1.9.4.64 2003/07/11 16:12:59 guus Exp $
$Id: conf.c,v 1.9.4.65 2003/07/12 17:41:45 guus Exp $
*/
#include "config.h"
@ -170,7 +170,7 @@ int get_config_bool(config_t *cfg, int *result)
return 1;
}
logger(DEBUG_ALWAYS, LOG_ERR, _("\"yes\" or \"no\" expected for configuration variable %s in %s line %d"),
logger(LOG_ERR, _("\"yes\" or \"no\" expected for configuration variable %s in %s line %d"),
cfg->variable, cfg->file, cfg->line);
return 0;
@ -186,7 +186,7 @@ int get_config_int(config_t *cfg, int *result)
if(sscanf(cfg->value, "%d", result) == 1)
return 1;
logger(DEBUG_ALWAYS, LOG_ERR, _("Integer expected for configuration variable %s in %s line %d"),
logger(LOG_ERR, _("Integer expected for configuration variable %s in %s line %d"),
cfg->variable, cfg->file, cfg->line);
return 0;
@ -220,7 +220,7 @@ int get_config_address(config_t *cfg, struct addrinfo **result)
return 1;
}
logger(DEBUG_ALWAYS, LOG_ERR, _("Hostname or IP address expected for configuration variable %s in %s line %d"),
logger(LOG_ERR, _("Hostname or IP address expected for configuration variable %s in %s line %d"),
cfg->variable, cfg->file, cfg->line);
return 0;
@ -238,7 +238,7 @@ int get_config_subnet(config_t *cfg, subnet_t ** result)
subnet = str2net(cfg->value);
if(!subnet) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Subnet expected for configuration variable %s in %s line %d"),
logger(LOG_ERR, _("Subnet expected for configuration variable %s in %s line %d"),
cfg->variable, cfg->file, cfg->line);
return 0;
}
@ -249,7 +249,7 @@ int get_config_subnet(config_t *cfg, subnet_t ** result)
&& maskcheck(&subnet->net.ipv4.address, subnet->net.ipv4.prefixlength, sizeof(ipv4_t)))
|| ((subnet->type == SUBNET_IPV6)
&& maskcheck(&subnet->net.ipv6.address, subnet->net.ipv6.prefixlength, sizeof(ipv6_t)))) {
logger(DEBUG_ALWAYS, LOG_ERR, _ ("Network address and prefix length do not match for configuration variable %s in %s line %d"),
logger(LOG_ERR, _ ("Network address and prefix length do not match for configuration variable %s in %s line %d"),
cfg->variable, cfg->file, cfg->line);
free(subnet);
return 0;
@ -348,7 +348,7 @@ int read_config_file(avl_tree_t *config_tree, const char *fname)
fp = fopen(fname, "r");
if(!fp) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Cannot open config file %s: %s"), fname,
logger(LOG_ERR, _("Cannot open config file %s: %s"), fname,
strerror(errno));
return -3;
}
@ -386,7 +386,7 @@ int read_config_file(avl_tree_t *config_tree, const char *fname)
value = strtok(NULL, "\t\n\r =");
if(!value || value[0] == '#') {
logger(DEBUG_ALWAYS, LOG_ERR, _("No value for variable `%s' on line %d while reading config file %s"),
logger(LOG_ERR, _("No value for variable `%s' on line %d while reading config file %s"),
variable, lineno, fname);
break;
}
@ -421,7 +421,7 @@ int read_server_config()
x = read_config_file(config_tree, fname);
if(x == -1) { /* System error: complain */
logger(DEBUG_ALWAYS, LOG_ERR, _("Failed to read `%s': %s"), fname, strerror(errno));
logger(LOG_ERR, _("Failed to read `%s': %s"), fname, strerror(errno));
}
free(fname);
@ -438,7 +438,7 @@ int is_safe_path(const char *file)
char l[MAXBUFSIZE];
if(*file != '/') {
logger(DEBUG_ALWAYS, LOG_ERR, _("`%s' is not an absolute path"), file);
logger(LOG_ERR, _("`%s' is not an absolute path"), file);
return 0;
}
@ -454,21 +454,21 @@ int is_safe_path(const char *file)
check1:
if(lstat(f, &s) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Couldn't stat `%s': %s"), f, strerror(errno));
logger(LOG_ERR, _("Couldn't stat `%s': %s"), f, strerror(errno));
return 0;
}
if(s.st_uid != geteuid()) {
logger(DEBUG_ALWAYS, LOG_ERR, _("`%s' is owned by UID %d instead of %d"),
logger(LOG_ERR, _("`%s' is owned by UID %d instead of %d"),
f, s.st_uid, geteuid());
return 0;
}
if(S_ISLNK(s.st_mode)) {
logger(DEBUG_ALWAYS, LOG_WARNING, _("Warning: `%s' is a symlink"), f);
logger(LOG_WARNING, _("Warning: `%s' is a symlink"), f);
if(readlink(f, l, MAXBUFSIZE) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Unable to read symbolic link `%s': %s"), f,
logger(LOG_ERR, _("Unable to read symbolic link `%s': %s"), f,
strerror(errno));
return 0;
}
@ -482,7 +482,7 @@ check1:
check2:
if(lstat(f, &s) < 0 && errno != ENOENT) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Couldn't stat `%s': %s"), f, strerror(errno));
logger(LOG_ERR, _("Couldn't stat `%s': %s"), f, strerror(errno));
return 0;
}
@ -490,16 +490,16 @@ check2:
return 1;
if(s.st_uid != geteuid()) {
logger(DEBUG_ALWAYS, LOG_ERR, _("`%s' is owned by UID %d instead of %d"),
logger(LOG_ERR, _("`%s' is owned by UID %d instead of %d"),
f, s.st_uid, geteuid());
return 0;
}
if(S_ISLNK(s.st_mode)) {
logger(DEBUG_ALWAYS, LOG_WARNING, _("Warning: `%s' is a symlink"), f);
logger(LOG_WARNING, _("Warning: `%s' is a symlink"), f);
if(readlink(f, l, MAXBUFSIZE) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Unable to read symbolic link `%s': %s"), f,
logger(LOG_ERR, _("Unable to read symbolic link `%s': %s"), f,
strerror(errno));
return 0;
}
@ -510,7 +510,7 @@ check2:
if(s.st_mode & 0007) {
/* Accessible by others */
logger(DEBUG_ALWAYS, LOG_ERR, _("`%s' has unsecure permissions"), f);
logger(LOG_ERR, _("`%s' has unsecure permissions"), f);
return 0;
}

View file

@ -1,7 +1,7 @@
/*
conf.h -- header for conf.c
Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <ivo@o2w.nl>
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: conf.h,v 1.6.4.37 2003/07/06 23:16:28 guus Exp $
$Id: conf.h,v 1.6.4.38 2003/07/12 17:41:45 guus Exp $
*/
#ifndef __TINC_CONF_H__

View file

@ -1,7 +1,7 @@
/*
connection.c -- connection list management
Copyright (C) 2000-2002 Guus Sliepen <guus@sliepen.eu.org>,
2000-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2000-2003 Guus Sliepen <guus@sliepen.eu.org>,
2000-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: connection.c,v 1.1.2.38 2003/07/06 23:16:28 guus Exp $
$Id: connection.c,v 1.1.2.39 2003/07/12 17:41:45 guus Exp $
*/
#include "config.h"
@ -124,15 +124,15 @@ void dump_connections(void)
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Connections:"));
logger(LOG_DEBUG, _("Connections:"));
for(node = connection_tree->head; node; node = node->next) {
c = (connection_t *) node->data;
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" %s at %s options %lx socket %d status %04x"),
logger(LOG_DEBUG, _(" %s at %s options %lx socket %d status %04x"),
c->name, c->hostname, c->options, c->socket, c->status);
}
logger(DEBUG_ALWAYS, LOG_DEBUG, _("End of connections."));
logger(LOG_DEBUG, _("End of connections."));
}
int read_connection_config(connection_t *c)

View file

@ -1,7 +1,7 @@
/*
connection.h -- header for connection.c
Copyright (C) 2000-2002 Guus Sliepen <guus@sliepen.eu.org>,
2000-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2000-2003 Guus Sliepen <guus@sliepen.eu.org>,
2000-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: connection.h,v 1.1.2.32 2003/07/06 23:16:28 guus Exp $
$Id: connection.h,v 1.1.2.33 2003/07/12 17:41:45 guus Exp $
*/
#ifndef __TINC_CONNECTION_H__

View file

@ -1,7 +1,7 @@
/*
device.c -- Stub for Cygwin environment
Copyright (C) 2002 Ivo Timmermans <ivo@o2w.nl>,
2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2002-2003 Ivo Timmermans <ivo@o2w.nl>,
2002-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.6 2003/07/06 22:11:33 guus Exp $
$Id: device.c,v 1.1.2.7 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -59,13 +59,13 @@ int setup_device(void)
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
return -1;
}
device_info = _("Stub device for Cygwin environment");
logger(DEBUG_ALWAYS, LOG_INFO, _("%s is a %s"), device, device_info);
logger(LOG_INFO, _("%s is a %s"), device, device_info);
return 0;
}
@ -84,7 +84,7 @@ int read_packet(vpn_packet_t *packet)
cp();
if((lenin = read(device_fd, packet->data, MTU)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -93,7 +93,7 @@ int read_packet(vpn_packet_t *packet)
device_total_in += packet->len;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
device_info);
return 0;
@ -103,11 +103,11 @@ int write_packet(vpn_packet_t *packet)
{
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Writing packet of %d bytes to %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
if(write(device_fd, packet->data, packet->len) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
strerror(errno));
return -1;
}
@ -121,7 +121,7 @@ void dump_device_stats(void)
{
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
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);
}

View file

@ -1,7 +1,7 @@
/*
device.c -- Interaction with MacOS/X tun device
Copyright (C) 2001-2002 Ivo Timmermans <ivo@o2w.nl>,
2001-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2001-2003 Ivo Timmermans <ivo@o2w.nl>,
2001-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.7 2003/07/06 22:11:33 guus Exp $
$Id: device.c,v 1.1.2.8 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -50,9 +50,6 @@ char *device_info;
int device_total_in = 0;
int device_total_out = 0;
/*
open the local ethertap device
*/
int setup_device(void)
{
cp();
@ -64,13 +61,13 @@ int setup_device(void)
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
return -1;
}
device_info = _("MacOS/X tun device");
logger(DEBUG_ALWAYS, LOG_INFO, _("%s is a %s"), device, device_info);
logger(LOG_INFO, _("%s is a %s"), device, device_info);
return 0;
}
@ -82,10 +79,6 @@ void close_device(void)
close(device_fd);
}
/*
read, encrypt and send data that is
available through the ethertap device
*/
int read_packet(vpn_packet_t *packet)
{
int lenin;
@ -93,7 +86,7 @@ int read_packet(vpn_packet_t *packet)
cp();
if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -105,7 +98,7 @@ int read_packet(vpn_packet_t *packet)
device_total_in += packet->len;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Read packet of %d bytes from %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"),
packet->len, device_info);
return 0;
@ -115,11 +108,11 @@ int write_packet(vpn_packet_t *packet)
{
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Writing packet of %d bytes to %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
if(write(device_fd, packet->data + 14, packet->len - 14) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while writing to %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while writing to %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -131,7 +124,7 @@ void dump_device_stats(void)
{
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
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);
}

View file

@ -1,7 +1,7 @@
/*
net.h -- generic header for device.c
Copyright (C) 2001-2002 Ivo Timmermans <zarq@iname.com>
2001-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2001-2003 Ivo Timmermans <zarq@iname.com>
2001-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.h,v 1.1.2.7 2002/09/09 21:24:31 guus Exp $
$Id: device.h,v 1.1.2.8 2003/07/12 17:41:45 guus Exp $
*/
#ifndef __TINC_DEVICE_H__

View file

@ -1,7 +1,7 @@
/*
edge.c -- edge tree management
Copyright (C) 2000-2002 Guus Sliepen <guus@sliepen.eu.org>,
2000-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2000-2003 Guus Sliepen <guus@sliepen.eu.org>,
2000-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: edge.c,v 1.1.2.20 2003/07/06 23:16:28 guus Exp $
$Id: edge.c,v 1.1.2.21 2003/07/12 17:41:45 guus Exp $
*/
#include "config.h"
@ -154,18 +154,18 @@ void dump_edges(void)
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Edges:"));
logger(LOG_DEBUG, _("Edges:"));
for(node = node_tree->head; node; node = node->next) {
n = (node_t *) node->data;
for(node2 = n->edge_tree->head; node2; node2 = node2->next) {
e = (edge_t *) node2->data;
address = sockaddr2hostname(&e->address);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" %s to %s at %s options %lx weight %d"),
logger(LOG_DEBUG, _(" %s to %s at %s options %lx weight %d"),
e->from->name, e->to->name, address, e->options, e->weight);
free(address);
}
}
logger(DEBUG_ALWAYS, LOG_DEBUG, _("End of edges."));
logger(LOG_DEBUG, _("End of edges."));
}

View file

@ -1,7 +1,7 @@
/*
edge.h -- header for edge.c
Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.eu.org>,
2001-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2001-2003 Guus Sliepen <guus@sliepen.eu.org>,
2001-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: edge.h,v 1.1.2.12 2003/07/06 23:16:28 guus Exp $
$Id: edge.h,v 1.1.2.13 2003/07/12 17:41:45 guus Exp $
*/
#ifndef __TINC_EDGE_H__

View file

@ -1,7 +1,7 @@
/*
event.c -- event queue
Copyright (C) 2002 Guus Sliepen <guus@sliepen.eu.org>,
2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2002-2003 Guus Sliepen <guus@sliepen.eu.org>,
2002-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: event.c,v 1.1.4.7 2003/07/06 23:16:28 guus Exp $
$Id: event.c,v 1.1.4.8 2003/07/12 17:41:45 guus Exp $
*/
#include "config.h"

View file

@ -1,7 +1,7 @@
/*
event.h -- header for event.c
Copyright (C) 2002 Guus Sliepen <guus@sliepen.eu.org>,
2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2002-2003 Guus Sliepen <guus@sliepen.eu.org>,
2002-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: event.h,v 1.1.4.5 2003/07/06 23:16:28 guus Exp $
$Id: event.h,v 1.1.4.6 2003/07/12 17:41:45 guus Exp $
*/
#ifndef __TINC_EVENT_H__

View file

@ -1,7 +1,7 @@
/*
device.c -- Interaction with FreeBSD tap device
Copyright (C) 2001-2002 Ivo Timmermans <ivo@o2w.nl>,
2001-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2001-2003 Ivo Timmermans <ivo@o2w.nl>,
2001-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.10 2003/07/06 22:11:34 guus Exp $
$Id: device.c,v 1.1.2.11 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -50,9 +50,6 @@ char *device_info;
int device_total_in = 0;
int device_total_out = 0;
/*
open the local ethertap device
*/
int setup_device(void)
{
cp();
@ -64,13 +61,13 @@ int setup_device(void)
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
return -1;
}
device_info = _("FreeBSD tap device");
logger(DEBUG_ALWAYS, LOG_INFO, _("%s is a %s"), device, device_info);
logger(LOG_INFO, _("%s is a %s"), device, device_info);
return 0;
}
@ -82,10 +79,6 @@ void close_device(void)
close(device_fd);
}
/*
read, encrypt and send data that is
available through the ethertap device
*/
int read_packet(vpn_packet_t *packet)
{
int lenin;
@ -93,7 +86,7 @@ int read_packet(vpn_packet_t *packet)
cp();
if((lenin = read(device_fd, packet->data, MTU)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -102,7 +95,7 @@ int read_packet(vpn_packet_t *packet)
device_total_in += packet->len;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Read packet of %d bytes from %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"),
packet->len, device_info);
return 0;
@ -112,11 +105,11 @@ int write_packet(vpn_packet_t *packet)
{
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Writing packet of %d bytes to %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
if(write(device_fd, packet->data, packet->len) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while writing to %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while writing to %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -128,7 +121,7 @@ void dump_device_stats(void)
{
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
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);
}

View file

@ -1,7 +1,7 @@
/*
graph.c -- graph algorithms
Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.eu.org>,
2001-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2001-2003 Guus Sliepen <guus@sliepen.eu.org>,
2001-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: graph.c,v 1.1.2.23 2003/07/06 22:11:31 guus Exp $
$Id: graph.c,v 1.1.2.24 2003/07/12 17:41:45 guus Exp $
*/
/* We need to generate two trees from the graph:
@ -95,7 +95,7 @@ void mst_kruskal(void)
if(!edge_weight_tree->head)
return;
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Running Kruskal's algorithm:");
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Running Kruskal's algorithm:");
/* Clear visited status on nodes */
@ -131,7 +131,7 @@ void mst_kruskal(void)
safe_edges++;
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, " Adding edge %s - %s weight %d", e->from->name,
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, " Adding edge %s - %s weight %d", e->from->name,
e->to->name, e->weight);
if(skipped) {
@ -141,7 +141,7 @@ void mst_kruskal(void)
}
}
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Done, counted %d nodes and %d safe edges.", nodes,
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Done, counted %d nodes and %d safe edges.", nodes,
safe_edges);
}
@ -259,12 +259,13 @@ void sssp_bfs(void)
if(n->status.visited != n->status.reachable) {
n->status.reachable = !n->status.reachable;
if(n->status.reachable)
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Node %s (%s) became reachable"),
if(n->status.reachable) {
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became reachable"),
n->name, n->hostname);
else
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Node %s (%s) became unreachable"),
} else {
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became unreachable"),
n->name, n->hostname);
}
n->status.validkey = 0;
n->status.waitingforkey = 0;

View file

@ -1,7 +1,7 @@
/*
graph.h -- header for graph.c
Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.eu.org>,
2001-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2001-2003 Guus Sliepen <guus@sliepen.eu.org>,
2001-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: graph.h,v 1.1.2.4 2002/06/21 10:11:12 guus Exp $
$Id: graph.h,v 1.1.2.5 2003/07/12 17:41:45 guus Exp $
*/
extern void graph(void);

View file

@ -1,7 +1,7 @@
/*
device.c -- Interaction with Linux ethertap and tun/tap device
Copyright (C) 2001-2002 Ivo Timmermans <ivo@o2w.nl>,
2001-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2001-2003 Ivo Timmermans <ivo@o2w.nl>,
2001-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.16 2003/07/06 22:11:35 guus Exp $
$Id: device.c,v 1.1.2.17 2003/07/12 17:41:48 guus Exp $
*/
#include "config.h"
@ -67,9 +67,6 @@ char *device_info;
int device_total_in = 0;
int device_total_out = 0;
/*
open the local ethertap device
*/
int setup_device(void)
{
struct ifreq ifr;
@ -88,7 +85,7 @@ int setup_device(void)
device_fd = open(device, O_RDWR | O_NONBLOCK);
if(device_fd < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
return -1;
}
@ -113,7 +110,7 @@ int setup_device(void)
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
interface = ifrname;
} else if(!ioctl(device_fd, (('T' << 8) | 202), (void *) &ifr)) {
logger(DEBUG_ALWAYS, LOG_WARNING, _("Old ioctl() request was needed for %s"), device);
logger(LOG_WARNING, _("Old ioctl() request was needed for %s"), device);
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
interface = ifrname;
} else
@ -126,7 +123,7 @@ int setup_device(void)
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
}
logger(DEBUG_ALWAYS, LOG_INFO, _("%s is a %s"), device, device_info);
logger(LOG_INFO, _("%s is a %s"), device, device_info);
return 0;
}
@ -138,10 +135,6 @@ void close_device(void)
close(device_fd);
}
/*
read, encrypt and send data that is
available through the ethertap device
*/
int read_packet(vpn_packet_t *packet)
{
int lenin;
@ -153,7 +146,7 @@ int read_packet(vpn_packet_t *packet)
lenin = read(device_fd, packet->data + 10, MTU - 10);
if(lenin <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"),
logger(LOG_ERR, _("Error while reading from %s %s: %s"),
device_info, device, strerror(errno));
return -1;
}
@ -164,7 +157,7 @@ int read_packet(vpn_packet_t *packet)
lenin = read(device_fd, packet->data, MTU);
if(lenin <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"),
logger(LOG_ERR, _("Error while reading from %s %s: %s"),
device_info, device, strerror(errno));
return -1;
}
@ -175,7 +168,7 @@ int read_packet(vpn_packet_t *packet)
lenin = read(device_fd, packet->data - 2, MTU + 2);
if(lenin <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"),
logger(LOG_ERR, _("Error while reading from %s %s: %s"),
device_info, device, strerror(errno));
return -1;
}
@ -186,7 +179,7 @@ int read_packet(vpn_packet_t *packet)
device_total_in += packet->len;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
device_info);
return 0;
@ -196,21 +189,21 @@ int write_packet(vpn_packet_t *packet)
{
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Writing packet of %d bytes to %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
switch(device_type) {
case DEVICE_TYPE_TUN:
packet->data[10] = packet->data[11] = 0;
if(write(device_fd, packet->data + 10, packet->len - 10) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
strerror(errno));
return -1;
}
break;
case DEVICE_TYPE_TAP:
if(write(device_fd, packet->data, packet->len) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
strerror(errno));
return -1;
}
@ -219,7 +212,7 @@ int write_packet(vpn_packet_t *packet)
*(short int *)(packet->data - 2) = packet->len;
if(write(device_fd, packet->data - 2, packet->len + 2) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
strerror(errno));
return -1;
}
@ -235,7 +228,7 @@ void dump_device_stats(void)
{
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
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);
}

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: logger.c,v 1.1.2.2 2003/07/06 23:16:28 guus Exp $
$Id: logger.c,v 1.1.2.3 2003/07/12 17:41:45 guus Exp $
*/
#include <stdio.h>
@ -30,7 +30,7 @@
#include "system.h"
volatile int debug_level = DEBUG_NOTHING;
int debug_level = DEBUG_NOTHING;
static int logmode = LOGMODE_STDERR;
static pid_t logpid;
extern char *logfilename;
@ -57,7 +57,11 @@ void openlogger(const char *ident, int mode) {
}
}
void vlogger(int priority, const char *format, va_list ap) {
void logger(int priority, const char *format, ...) {
va_list ap;
va_start(ap, format);
switch(logmode) {
case LOGMODE_STDERR:
vfprintf(stderr, format, ap);
@ -80,6 +84,8 @@ void vlogger(int priority, const char *format, va_list ap) {
#endif
break;
}
va_end(ap);
}
void closelogger(void) {

View file

@ -23,21 +23,11 @@ enum {
LOGMODE_SYSLOG
};
extern volatile int debug_level;
extern int debug_level;
extern void openlogger(const char *, int);
extern void vlogger(int, const char *, va_list ap);
extern void logger(int, const char *, ...);
extern void closelogger(void);
/* Inline logger function because it's used quite often */
static inline void logger(int level, int priority, const char *format, ...) {
va_list ap;
if(level == DEBUG_ALWAYS || debug_level >= level) {
va_start(ap, format);
vlogger(priority, format, ap);
va_end(ap);
}
}
#define ifdebug(l) if(debug_level >= DEBUG_##l)
#endif /* __TINC_LOGGER_H__ */

View file

@ -1,7 +1,7 @@
/*
meta.c -- handle the meta communication
Copyright (C) 2000-2002 Guus Sliepen <guus@sliepen.eu.org>,
2000-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2000-2003 Guus Sliepen <guus@sliepen.eu.org>,
2000-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: meta.c,v 1.1.2.34 2003/07/06 22:11:31 guus Exp $
$Id: meta.c,v 1.1.2.35 2003/07/12 17:41:45 guus Exp $
*/
#include "config.h"
@ -48,7 +48,7 @@ int send_meta(connection_t *c, char *buffer, int length)
cp();
logger(DEBUG_META, LOG_DEBUG, _("Sending %d bytes of metadata to %s (%s)"), length,
ifdebug(META) logger(LOG_DEBUG, _("Sending %d bytes of metadata to %s (%s)"), length,
c->name, c->hostname);
if(c->status.encryptout) {
@ -63,7 +63,7 @@ int send_meta(connection_t *c, char *buffer, int length)
if(result <= 0) {
if(errno == EINTR)
continue;
logger(DEBUG_ALWAYS, LOG_ERR, _("Sending meta data to %s (%s) failed: %s"), c->name,
logger(LOG_ERR, _("Sending meta data to %s (%s) failed: %s"), c->name,
c->hostname, strerror(errno));
return -1;
}
@ -101,13 +101,13 @@ int receive_meta(connection_t *c)
cp();
if(getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &x, &l) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("This is a bug: %s:%d: %d:%s %s (%s)"), __FILE__,
logger(LOG_ERR, _("This is a bug: %s:%d: %d:%s %s (%s)"), __FILE__,
__LINE__, c->socket, strerror(errno), c->name, c->hostname);
return -1;
}
if(x) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Metadata socket error for %s (%s): %s"),
logger(LOG_ERR, _("Metadata socket error for %s (%s): %s"),
c->name, c->hostname, strerror(x));
return -1;
}
@ -125,12 +125,12 @@ int receive_meta(connection_t *c)
if(lenin <= 0) {
if(lenin == 0) {
logger(DEBUG_CONNECTIONS, LOG_NOTICE, _("Connection closed by %s (%s)"),
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection closed by %s (%s)"),
c->name, c->hostname);
} else if(errno == EINTR)
return 0;
else
logger(DEBUG_ALWAYS, LOG_ERR, _("Metadata socket read error for %s (%s): %s"),
logger(LOG_ERR, _("Metadata socket read error for %s (%s): %s"),
c->name, c->hostname, strerror(errno));
return -1;
@ -193,7 +193,7 @@ int receive_meta(connection_t *c)
}
if(c->buflen >= MAXBUFSIZE) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Metadata read buffer overflow for %s (%s)"),
logger(LOG_ERR, _("Metadata read buffer overflow for %s (%s)"),
c->name, c->hostname);
return -1;
}

View file

@ -1,7 +1,7 @@
/*
meta.h -- header for meta.c
Copyright (C) 2000-2002 Guus Sliepen <guus@sliepen.eu.org>,
2000-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2000-2003 Guus Sliepen <guus@sliepen.eu.org>,
2000-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: meta.h,v 1.1.2.8 2002/09/09 21:24:34 guus Exp $
$Id: meta.h,v 1.1.2.9 2003/07/12 17:41:45 guus Exp $
*/
#ifndef __TINC_META_H__

View file

@ -1,7 +1,7 @@
/*
net.c -- most of the network code
Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net.c,v 1.35.4.189 2003/07/06 23:16:28 guus Exp $
$Id: net.c,v 1.35.4.190 2003/07/12 17:41:45 guus Exp $
*/
#include "config.h"
@ -91,14 +91,14 @@ static void purge(void)
cp();
logger(DEBUG_PROTOCOL, LOG_DEBUG, _("Purging unreachable nodes"));
ifdebug(PROTOCOL) logger(LOG_DEBUG, _("Purging unreachable nodes"));
for(nnode = node_tree->head; nnode; nnode = nnext) {
nnext = nnode->next;
n = (node_t *) nnode->data;
if(!n->status.reachable) {
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Purging node %s (%s)"), n->name,
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, _("Purging node %s (%s)"), n->name,
n->hostname);
for(snode = n->subnet_tree->head; snode; snode = snext) {
@ -179,7 +179,7 @@ void terminate_connection(connection_t *c, int report)
if(c->status.remove)
return;
logger(DEBUG_CONNECTIONS, LOG_NOTICE, _("Closing connection with %s (%s)"),
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Closing connection with %s (%s)"),
c->name, c->hostname);
c->status.remove = 1;
@ -232,7 +232,7 @@ static void check_dead_connections(void)
if(c->last_ping_time + pingtimeout < now) {
if(c->status.active) {
if(c->status.pinged) {
logger(DEBUG_CONNECTIONS, LOG_INFO, _("%s (%s) didn't respond to PING"),
ifdebug(CONNECTIONS) logger(LOG_INFO, _("%s (%s) didn't respond to PING"),
c->name, c->hostname);
c->status.timeout = 1;
terminate_connection(c, 1);
@ -241,12 +241,12 @@ static void check_dead_connections(void)
}
} else {
if(c->status.remove) {
logger(DEBUG_ALWAYS, LOG_WARNING, _("Old connection_t for %s (%s) status %04x still lingering, deleting..."),
logger(LOG_WARNING, _("Old connection_t for %s (%s) status %04x still lingering, deleting..."),
c->name, c->hostname, c->status);
connection_del(c);
continue;
}
logger(DEBUG_CONNECTIONS, LOG_WARNING, _("Timeout from %s (%s) during authentication"),
ifdebug(CONNECTIONS) logger(LOG_WARNING, _("Timeout from %s (%s) during authentication"),
c->name, c->hostname);
terminate_connection(c, 0);
}
@ -287,7 +287,7 @@ static void check_network_activity(fd_set * f)
if(!result)
finish_connecting(c);
else {
logger(DEBUG_CONNECTIONS, LOG_DEBUG,
ifdebug(CONNECTIONS) logger(LOG_DEBUG,
_("Error while connecting to %s (%s): %s"),
c->name, c->hostname, strerror(result));
close(c->socket);
@ -341,7 +341,7 @@ void main_loop(void)
if(r < 0) {
if(errno != EINTR && errno != EAGAIN) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while waiting for input: %s"),
logger(LOG_ERR, _("Error while waiting for input: %s"),
strerror(errno));
cp_trace();
dump_connections();
@ -372,7 +372,7 @@ void main_loop(void)
/* Should we regenerate our key? */
if(keyexpires < now) {
logger(DEBUG_STATUS, LOG_INFO, _("Regenerating symmetric key"));
ifdebug(STATUS) logger(LOG_INFO, _("Regenerating symmetric key"));
RAND_pseudo_bytes(myself->key, myself->keylength);
EVP_DecryptInit_ex(&packet_ctx, myself->cipher, NULL, myself->key, myself->key + myself->cipher->key_len);
@ -388,7 +388,7 @@ void main_loop(void)
}
if(sigalrm) {
logger(DEBUG_ALWAYS, LOG_INFO, _("Flushing event queue"));
logger(LOG_INFO, _("Flushing event queue"));
while(event_tree->head) {
event = (event_t *) event_tree->head->data;
@ -412,7 +412,7 @@ void main_loop(void)
init_configuration(&config_tree);
if(read_server_config()) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Unable to reread configuration file, exitting."));
logger(LOG_ERR, _("Unable to reread configuration file, exitting."));
exit(1);
}

View file

@ -1,7 +1,7 @@
/*
net.h -- header for net.c
Copyright (C) 1998-2002 Ivo Timmermans <zarq@iname.com>
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <zarq@iname.com>
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net.h,v 1.9.4.62 2003/07/11 16:13:00 guus Exp $
$Id: net.h,v 1.9.4.63 2003/07/12 17:41:46 guus Exp $
*/
#ifndef __TINC_NET_H__

View file

@ -1,7 +1,7 @@
/*
net_packet.c -- Handles in- and outgoing VPN packets
Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net_packet.c,v 1.1.2.32 2003/07/06 23:16:28 guus Exp $
$Id: net_packet.c,v 1.1.2.33 2003/07/12 17:41:46 guus Exp $
*/
#include "config.h"
@ -133,7 +133,7 @@ static void receive_packet(node_t *n, vpn_packet_t *packet)
{
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Received packet of %d bytes from %s (%s)"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Received packet of %d bytes from %s (%s)"),
packet->len, n->name, n->hostname);
route_incoming(n, packet);
@ -159,7 +159,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
(char *) &inpkt->seqno, inpkt->len, hmac, NULL);
if(memcmp(hmac, (char *) &inpkt->seqno + inpkt->len, myself->maclength)) {
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Got unauthenticated packet from %s (%s)"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Got unauthenticated packet from %s (%s)"),
n->name, n->hostname);
return;
}
@ -188,13 +188,13 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
if(inpkt->seqno != n->received_seqno + 1) {
if(inpkt->seqno >= n->received_seqno + sizeof(n->late) * 8) {
logger(DEBUG_ALWAYS, LOG_WARNING, _("Lost %d packets from %s (%s)"),
logger(LOG_WARNING, _("Lost %d packets from %s (%s)"),
inpkt->seqno - n->received_seqno - 1, n->name, n->hostname);
memset(n->late, 0, sizeof(n->late));
} else if (inpkt->seqno <= n->received_seqno) {
if(inpkt->seqno <= n->received_seqno - sizeof(n->late) * 8 || !(n->late[(inpkt->seqno / 8) % sizeof(n->late)] & (1 << inpkt->seqno % 8))) {
logger(DEBUG_ALWAYS, LOG_WARNING, _("Got late or replayed packet from %s (%s), seqno %d, last received %d"),
logger(LOG_WARNING, _("Got late or replayed packet from %s (%s), seqno %d, last received %d"),
n->name, n->hostname, inpkt->seqno, n->received_seqno);
} else
for(i = n->received_seqno + 1; i < inpkt->seqno; i++)
@ -214,7 +214,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
outpkt = pkt[nextpkt++];
if((outpkt->len = uncompress_packet(outpkt->data, inpkt->data, inpkt->len, myself->compression)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while uncompressing packet from %s (%s)"),
logger(LOG_ERR, _("Error while uncompressing packet from %s (%s)"),
n->name, n->hostname);
return;
}
@ -255,7 +255,7 @@ static void send_udppacket(node_t *n, vpn_packet_t *inpkt)
/* Make sure we have a valid key */
if(!n->status.validkey) {
logger(DEBUG_TRAFFIC, LOG_INFO,
ifdebug(TRAFFIC) logger(LOG_INFO,
_("No valid key known yet for %s (%s), queueing packet"),
n->name, n->hostname);
@ -286,7 +286,7 @@ static void send_udppacket(node_t *n, vpn_packet_t *inpkt)
outpkt = pkt[nextpkt++];
if((outpkt->len = compress_packet(outpkt->data, inpkt->data, inpkt->len, n->compression)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while compressing packet to %s (%s)"),
logger(LOG_ERR, _("Error while compressing packet to %s (%s)"),
n->name, n->hostname);
return;
}
@ -337,15 +337,15 @@ static void send_udppacket(node_t *n, vpn_packet_t *inpkt)
if(priorityinheritance && origpriority != priority
&& listen_socket[sock].sa.sa.sa_family == AF_INET) {
priority = origpriority;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Setting outgoing packet priority to %d"), priority);
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Setting outgoing packet priority to %d"), priority);
if(setsockopt(listen_socket[sock].udp, SOL_IP, IP_TOS, &priority, sizeof(priority))) /* SO_PRIORITY doesn't seem to work */
logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "setsockopt",
logger(LOG_ERR, _("System call `%s' failed: %s"), "setsockopt",
strerror(errno));
}
#endif
if((sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, &(n->address.sa), SALEN(n->address.sa))) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error sending packet to %s (%s): %s"), n->name,
logger(LOG_ERR, _("Error sending packet to %s (%s): %s"), n->name,
n->hostname, strerror(errno));
return;
}
@ -362,16 +362,16 @@ void send_packet(node_t *n, vpn_packet_t *packet)
cp();
logger(DEBUG_TRAFFIC, LOG_ERR, _("Sending packet of %d bytes to %s (%s)"),
ifdebug(TRAFFIC) logger(LOG_ERR, _("Sending packet of %d bytes to %s (%s)"),
packet->len, n->name, n->hostname);
if(n == myself) {
logger(DEBUG_TRAFFIC, LOG_NOTICE, _("Packet is looping back to us!"));
ifdebug(TRAFFIC) logger(LOG_NOTICE, _("Packet is looping back to us!"));
return;
}
if(!n->status.reachable) {
logger(DEBUG_TRAFFIC, LOG_INFO, _("Node %s (%s) is not reachable"),
ifdebug(TRAFFIC) logger(LOG_INFO, _("Node %s (%s) is not reachable"),
n->name, n->hostname);
return;
}
@ -379,7 +379,7 @@ void send_packet(node_t *n, vpn_packet_t *packet)
via = (n->via == myself) ? n->nexthop : n->via;
if(via != n)
logger(DEBUG_TRAFFIC, LOG_ERR, _("Sending packet to %s via %s (%s)"),
ifdebug(TRAFFIC) logger(LOG_ERR, _("Sending packet to %s via %s (%s)"),
n->name, via->name, n->via->hostname);
if((myself->options | via->options) & OPTION_TCPONLY) {
@ -398,7 +398,7 @@ void broadcast_packet(node_t *from, vpn_packet_t *packet)
cp();
logger(DEBUG_TRAFFIC, LOG_INFO, _("Broadcasting packet of %d bytes from %s (%s)"),
ifdebug(TRAFFIC) logger(LOG_INFO, _("Broadcasting packet of %d bytes from %s (%s)"),
packet->len, from->name, from->hostname);
for(node = connection_tree->head; node; node = node->next) {
@ -415,7 +415,7 @@ void flush_queue(node_t *n)
cp();
logger(DEBUG_TRAFFIC, LOG_INFO, _("Flushing queue for %s (%s)"), n->name, n->hostname);
ifdebug(TRAFFIC) logger(LOG_INFO, _("Flushing queue for %s (%s)"), n->name, n->hostname);
for(node = n->queue->head; node; node = next) {
next = node->next;
@ -436,21 +436,21 @@ void handle_incoming_vpn_data(int sock)
cp();
if(getsockopt(sock, SOL_SOCKET, SO_ERROR, &x, &l) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("This is a bug: %s:%d: %d:%s"),
logger(LOG_ERR, _("This is a bug: %s:%d: %d:%s"),
__FILE__, __LINE__, sock, strerror(errno));
cp_trace();
exit(1);
}
if(x) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Incoming data socket error: %s"), strerror(x));
logger(LOG_ERR, _("Incoming data socket error: %s"), strerror(x));
return;
}
pkt.len = recvfrom(sock, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen);
if(pkt.len <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Receiving packet failed: %s"), strerror(errno));
logger(LOG_ERR, _("Receiving packet failed: %s"), strerror(errno));
return;
}
@ -460,7 +460,7 @@ void handle_incoming_vpn_data(int sock)
if(!n) {
hostname = sockaddr2hostname(&from);
logger(DEBUG_ALWAYS, LOG_WARNING, _("Received UDP packet from unknown source %s"),
logger(LOG_WARNING, _("Received UDP packet from unknown source %s"),
hostname);
free(hostname);
return;

View file

@ -1,7 +1,7 @@
/*
net_setup.c -- Setup.
Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net_setup.c,v 1.1.2.33 2003/07/06 22:11:32 guus Exp $
$Id: net_setup.c,v 1.1.2.34 2003/07/12 17:41:46 guus Exp $
*/
#include "config.h"
@ -107,7 +107,7 @@ int read_rsa_public_key(connection_t *c)
fp = fopen(fname, "r");
if(!fp) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error reading RSA public key file `%s': %s"),
logger(LOG_ERR, _("Error reading RSA public key file `%s': %s"),
fname, strerror(errno));
free(fname);
return -1;
@ -124,7 +124,7 @@ int read_rsa_public_key(connection_t *c)
fp = fopen(fname, "r");
if(!fp) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error reading RSA public key file `%s': %s"),
logger(LOG_ERR, _("Error reading RSA public key file `%s': %s"),
fname, strerror(errno));
free(fname);
return -1;
@ -139,7 +139,7 @@ int read_rsa_public_key(connection_t *c)
return 0;
}
logger(DEBUG_ALWAYS, LOG_ERR, _("Reading RSA public key file `%s' failed: %s"),
logger(LOG_ERR, _("Reading RSA public key file `%s' failed: %s"),
fname, strerror(errno));
return -1;
} else {
@ -179,7 +179,7 @@ int read_rsa_public_key(connection_t *c)
if(c->rsa_key)
return 0;
logger(DEBUG_ALWAYS, LOG_ERR, _("No public key for %s specified!"), c->name);
logger(LOG_ERR, _("No public key for %s specified!"), c->name);
return -1;
}
@ -207,7 +207,7 @@ int read_rsa_private_key(void)
fp = fopen(fname, "r");
if(!fp) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error reading RSA private key file `%s': %s"),
logger(LOG_ERR, _("Error reading RSA private key file `%s': %s"),
fname, strerror(errno));
free(fname);
return -1;
@ -219,7 +219,7 @@ int read_rsa_private_key(void)
fclose(fp);
if(!myself->connection->rsa_key) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Reading RSA private key file `%s' failed: %s"),
logger(LOG_ERR, _("Reading RSA private key file `%s' failed: %s"),
fname, strerror(errno));
return -1;
}
@ -256,12 +256,12 @@ int setup_myself(void)
myself->connection->protocol_version = PROT_CURRENT;
if(!get_config_string(lookup_config(config_tree, "Name"), &name)) { /* Not acceptable */
logger(DEBUG_ALWAYS, LOG_ERR, _("Name for tinc daemon required!"));
logger(LOG_ERR, _("Name for tinc daemon required!"));
return -1;
}
if(check_id(name)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Invalid name for myself!"));
logger(LOG_ERR, _("Invalid name for myself!"));
free(name);
return -1;
}
@ -273,7 +273,7 @@ int setup_myself(void)
return -1;
if(read_connection_config(myself->connection)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Cannot open host configuration file for myself!"));
logger(LOG_ERR, _("Cannot open host configuration file for myself!"));
return -1;
}
@ -329,7 +329,7 @@ int setup_myself(void)
else if(!strcasecmp(mode, "hub"))
routing_mode = RMODE_HUB;
else {
logger(DEBUG_ALWAYS, LOG_ERR, _("Invalid routing mode!"));
logger(LOG_ERR, _("Invalid routing mode!"));
return -1;
}
free(mode);
@ -340,7 +340,7 @@ int setup_myself(void)
&priorityinheritance);
#if !defined(SOL_IP) || !defined(IP_TOS)
if(priorityinheritance)
logger(DEBUG_ALWAYS, LOG_WARNING, _("PriorityInheritance not supported on this platform"));
logger(LOG_WARNING, _("PriorityInheritance not supported on this platform"));
#endif
if(!get_config_int(lookup_config(config_tree, "MACExpire"), &macexpire))
@ -350,7 +350,7 @@ int setup_myself(void)
(lookup_config(myself->connection->config_tree, "MaxTimeout"),
&maxtimeout)) {
if(maxtimeout <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Bogus maximum timeout!"));
logger(LOG_ERR, _("Bogus maximum timeout!"));
return -1;
}
} else
@ -364,7 +364,7 @@ int setup_myself(void)
else if(!strcasecmp(afname, "any"))
addressfamily = AF_UNSPEC;
else {
logger(DEBUG_ALWAYS, LOG_ERR, _("Invalid address family!"));
logger(LOG_ERR, _("Invalid address family!"));
return -1;
}
free(afname);
@ -382,7 +382,7 @@ int setup_myself(void)
myself->cipher = EVP_get_cipherbyname(cipher);
if(!myself->cipher) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Unrecognized cipher type!"));
logger(LOG_ERR, _("Unrecognized cipher type!"));
return -1;
}
}
@ -417,7 +417,7 @@ int setup_myself(void)
myself->digest = EVP_get_digestbyname(digest);
if(!myself->digest) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Unrecognized digest type!"));
logger(LOG_ERR, _("Unrecognized digest type!"));
return -1;
}
}
@ -431,10 +431,10 @@ int setup_myself(void)
&myself->maclength)) {
if(myself->digest) {
if(myself->maclength > myself->digest->md_size) {
logger(DEBUG_ALWAYS, LOG_ERR, _("MAC length exceeds size of digest!"));
logger(LOG_ERR, _("MAC length exceeds size of digest!"));
return -1;
} else if(myself->maclength < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Bogus MAC length!"));
logger(LOG_ERR, _("Bogus MAC length!"));
return -1;
}
}
@ -449,7 +449,7 @@ int setup_myself(void)
(lookup_config(myself->connection->config_tree, "Compression"),
&myself->compression)) {
if(myself->compression < 0 || myself->compression > 11) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Bogus compression level!"));
logger(LOG_ERR, _("Bogus compression level!"));
return -1;
}
} else
@ -481,7 +481,7 @@ int setup_myself(void)
err = getaddrinfo(address, myport, &hint, &ai);
if(err || !ai) {
logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "getaddrinfo",
logger(LOG_ERR, _("System call `%s' failed: %s"), "getaddrinfo",
gai_strerror(err));
return -1;
}
@ -501,9 +501,9 @@ int setup_myself(void)
if(listen_socket[listen_sockets].udp < 0)
continue;
if(debug_level >= DEBUG_CONNECTIONS) {
ifdebug(CONNECTIONS) {
hostname = sockaddr2hostname((sockaddr_t *) aip->ai_addr);
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Listening on %s"), hostname);
logger(LOG_NOTICE, _("Listening on %s"), hostname);
free(hostname);
}
@ -514,9 +514,9 @@ int setup_myself(void)
freeaddrinfo(ai);
if(listen_sockets)
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Ready"));
logger(LOG_NOTICE, _("Ready"));
else {
logger(DEBUG_ALWAYS, LOG_ERR, _("Unable to create any listening socket!"));
logger(LOG_ERR, _("Unable to create any listening socket!"));
return -1;
}

View file

@ -1,7 +1,7 @@
/*
net_socket.c -- Handle various kinds of sockets.
Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net_socket.c,v 1.1.2.25 2003/07/06 22:11:32 guus Exp $
$Id: net_socket.c,v 1.1.2.26 2003/07/12 17:41:46 guus Exp $
*/
#include "config.h"
@ -99,7 +99,7 @@ int setup_listen_socket(sockaddr_t *sa)
nfd = socket(sa->sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
if(nfd < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Creating metasocket failed: %s"), strerror(errno));
logger(LOG_ERR, _("Creating metasocket failed: %s"), strerror(errno));
return -1;
}
@ -107,7 +107,7 @@ int setup_listen_socket(sockaddr_t *sa)
if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0) {
close(nfd);
logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "fcntl",
logger(LOG_ERR, _("System call `%s' failed: %s"), "fcntl",
strerror(errno));
return -1;
}
@ -134,19 +134,19 @@ int setup_listen_socket(sockaddr_t *sa)
if(setsockopt(nfd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr))) {
close(nfd);
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't bind to interface %s: %s"), interface,
logger(LOG_ERR, _("Can't bind to interface %s: %s"), interface,
strerror(errno));
return -1;
}
#else
logger(DEBUG_ALWAYS, LOG_WARNING, _("BindToInterface not supported on this platform"));
logger(LOG_WARNING, _("BindToInterface not supported on this platform"));
#endif
}
if(bind(nfd, &sa->sa, SALEN(sa->sa))) {
close(nfd);
addrstr = sockaddr2hostname(sa);
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't bind to %s/tcp: %s"), addrstr,
logger(LOG_ERR, _("Can't bind to %s/tcp: %s"), addrstr,
strerror(errno));
free(addrstr);
return -1;
@ -154,7 +154,7 @@ int setup_listen_socket(sockaddr_t *sa)
if(listen(nfd, 3)) {
close(nfd);
logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "listen",
logger(LOG_ERR, _("System call `%s' failed: %s"), "listen",
strerror(errno));
return -1;
}
@ -177,14 +177,14 @@ int setup_vpn_in_socket(sockaddr_t *sa)
nfd = socket(sa->sa.sa_family, SOCK_DGRAM, IPPROTO_UDP);
if(nfd < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Creating UDP socket failed: %s"), strerror(errno));
logger(LOG_ERR, _("Creating UDP socket failed: %s"), strerror(errno));
return -1;
}
flags = fcntl(nfd, F_GETFL);
if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0) {
close(nfd);
logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "fcntl",
logger(LOG_ERR, _("System call `%s' failed: %s"), "fcntl",
strerror(errno));
return -1;
}
@ -200,7 +200,7 @@ int setup_vpn_in_socket(sockaddr_t *sa)
if(setsockopt(nfd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr))) {
close(nfd);
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't bind to interface %s: %s"), interface,
logger(LOG_ERR, _("Can't bind to interface %s: %s"), interface,
strerror(errno));
return -1;
}
@ -210,7 +210,7 @@ int setup_vpn_in_socket(sockaddr_t *sa)
if(bind(nfd, &sa->sa, SALEN(sa->sa))) {
close(nfd);
addrstr = sockaddr2hostname(sa);
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't bind to %s/udp: %s"), addrstr,
logger(LOG_ERR, _("Can't bind to %s/udp: %s"), addrstr,
strerror(errno));
free(addrstr);
return -1;
@ -236,7 +236,7 @@ void retry_outgoing(outgoing_t *outgoing)
event->data = outgoing;
event_add(event);
logger(DEBUG_CONNECTIONS, LOG_NOTICE,
ifdebug(CONNECTIONS) logger(LOG_NOTICE,
_("Trying to re-establish outgoing connection in %d seconds"),
outgoing->timeout);
}
@ -245,7 +245,7 @@ void finish_connecting(connection_t *c)
{
cp();
logger(DEBUG_CONNECTIONS, LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
c->last_ping_time = now;
@ -262,7 +262,7 @@ void do_outgoing_connection(connection_t *c)
begin:
if(!c->outgoing->ai) {
if(!c->outgoing->cfg) {
logger(DEBUG_CONNECTIONS, LOG_ERR, _("Could not set up a meta connection to %s"),
ifdebug(CONNECTIONS) logger(LOG_ERR, _("Could not set up a meta connection to %s"),
c->name);
c->status.remove = 1;
retry_outgoing(c->outgoing);
@ -297,13 +297,13 @@ begin:
c->hostname = sockaddr2hostname(&c->address);
logger(DEBUG_CONNECTIONS, LOG_INFO, _("Trying to connect to %s (%s)"), c->name,
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Trying to connect to %s (%s)"), c->name,
c->hostname);
c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
if(c->socket == -1) {
logger(DEBUG_CONNECTIONS, LOG_ERR, _("Creating socket for %s failed: %s"), c->hostname,
ifdebug(CONNECTIONS) logger(LOG_ERR, _("Creating socket for %s failed: %s"), c->hostname,
strerror(errno));
goto begin;
@ -326,7 +326,7 @@ begin:
flags = fcntl(c->socket, F_GETFL);
if(fcntl(c->socket, F_SETFL, flags | O_NONBLOCK) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno));
logger(LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno));
}
/* Connect */
@ -341,7 +341,7 @@ begin:
close(c->socket);
logger(DEBUG_CONNECTIONS, LOG_ERR, _("%s: %s"), c->hostname, strerror(errno));
ifdebug(CONNECTIONS) logger(LOG_ERR, _("%s: %s"), c->hostname, strerror(errno));
goto begin;
}
@ -362,7 +362,7 @@ void setup_outgoing_connection(outgoing_t *outgoing)
if(n)
if(n->connection) {
logger(DEBUG_CONNECTIONS, LOG_INFO, _("Already connected to %s"), outgoing->name);
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Already connected to %s"), outgoing->name);
n->connection->outgoing = outgoing;
return;
@ -381,7 +381,7 @@ void setup_outgoing_connection(outgoing_t *outgoing)
outgoing->cfg = lookup_config(c->config_tree, "Address");
if(!outgoing->cfg) {
logger(DEBUG_ALWAYS, LOG_ERR, _("No address specified for %s"), c->name);
logger(LOG_ERR, _("No address specified for %s"), c->name);
free_connection(c);
free(outgoing->name);
free(outgoing);
@ -411,7 +411,7 @@ int handle_new_meta_connection(int sock)
fd = accept(sock, &sa.sa, &len);
if(fd < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Accepting a new connection failed: %s"),
logger(LOG_ERR, _("Accepting a new connection failed: %s"),
strerror(errno));
return -1;
}
@ -429,7 +429,7 @@ int handle_new_meta_connection(int sock)
c->socket = fd;
c->last_ping_time = now;
logger(DEBUG_CONNECTIONS, LOG_NOTICE, _("Connection from %s"), c->hostname);
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection from %s"), c->hostname);
connection_add(c);
@ -452,7 +452,7 @@ void try_outgoing_connections(void)
get_config_string(cfg, &name);
if(check_id(name)) {
logger(DEBUG_ALWAYS, LOG_ERR,
logger(LOG_ERR,
_("Invalid name for outgoing connection in %s line %d"),
cfg->file, cfg->line);
free(name);

View file

@ -1,7 +1,7 @@
/*
device.c -- Interaction with NetBSD tun device
Copyright (C) 2001-2002 Ivo Timmermans <ivo@o2w.nl>,
2001-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2001-2003 Ivo Timmermans <ivo@o2w.nl>,
2001-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.9 2003/07/06 22:11:35 guus Exp $
$Id: device.c,v 1.1.2.10 2003/07/12 17:41:48 guus Exp $
*/
#include "config.h"
@ -55,9 +55,6 @@ char *device_info;
int device_total_in = 0;
int device_total_out = 0;
/*
open the local ethertap device
*/
int setup_device(void)
{
cp();
@ -68,13 +65,13 @@ int setup_device(void)
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
return -1;
}
device_info = _("NetBSD tun device");
logger(DEBUG_ALWAYS, LOG_INFO, _("%s is a %s"), device, device_info);
logger(LOG_INFO, _("%s is a %s"), device, device_info);
return 0;
}
@ -93,7 +90,7 @@ int read_packet(vpn_packet_t *packet)
cp();
if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -105,7 +102,7 @@ int read_packet(vpn_packet_t *packet)
device_total_in += packet->len;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
device_info);
}
@ -116,11 +113,11 @@ int write_packet(vpn_packet_t *packet)
{
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Writing packet of %d bytes to %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
if(write(device_fd, packet->data + 14, packet->len - 14) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
strerror(errno));
return -1;
}
@ -132,7 +129,7 @@ void dump_device_stats(void)
{
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
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);
}

View file

@ -1,7 +1,7 @@
/*
netutl.c -- some supporting network utility code
Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <ivo@o2w.nl>
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: netutl.c,v 1.12.4.45 2003/07/06 22:11:32 guus Exp $
$Id: netutl.c,v 1.12.4.46 2003/07/12 17:41:46 guus Exp $
*/
#include "config.h"
@ -67,7 +67,7 @@ struct addrinfo *str2addrinfo(char *address, char *service, int socktype)
err = getaddrinfo(address, service, &hint, &ai);
if(err) {
logger(DEBUG_ALWAYS, LOG_WARNING, _("Error looking up %s port %s: %s\n"), address,
logger(LOG_WARNING, _("Error looking up %s port %s: %s\n"), address,
service, gai_strerror(err));
return NULL;
}
@ -92,7 +92,7 @@ sockaddr_t str2sockaddr(char *address, char *port)
err = getaddrinfo(address, port, &hint, &ai);
if(err || !ai) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error looking up %s port %s: %s\n"), address, port,
logger(LOG_ERR, _("Error looking up %s port %s: %s\n"), address, port,
gai_strerror(err));
cp_trace();
raise(SIGFPE);
@ -117,7 +117,7 @@ void sockaddr2str(sockaddr_t *sa, char **addrstr, char **portstr)
err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
if(err) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while translating addresses: %s"),
logger(LOG_ERR, _("Error while translating addresses: %s"),
gai_strerror(err));
cp_trace();
raise(SIGFPE);
@ -145,7 +145,7 @@ char *sockaddr2hostname(sockaddr_t *sa)
err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port),
hostnames ? 0 : (NI_NUMERICHOST | NI_NUMERICSERV));
if(err) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while looking up hostname: %s"),
logger(LOG_ERR, _("Error while looking up hostname: %s"),
gai_strerror(err));
}
@ -186,7 +186,7 @@ int sockaddrcmp(sockaddr_t *a, sockaddr_t *b)
return memcmp(&a->in6.sin6_port, &b->in6.sin6_port, sizeof(a->in6.sin6_port));
default:
logger(DEBUG_ALWAYS, LOG_ERR, _("sockaddrcmp() was called with unknown address family %d, exitting!"),
logger(LOG_ERR, _("sockaddrcmp() was called with unknown address family %d, exitting!"),
a->sa.sa_family);
cp_trace();
raise(SIGFPE);

View file

@ -1,7 +1,7 @@
/*
netutl.h -- header file for netutl.c
Copyright (C) 1998-2002 Ivo Timmermans <zarq@iname.com>
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <zarq@iname.com>
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: netutl.h,v 1.2.4.14 2002/09/09 21:24:41 guus Exp $
$Id: netutl.h,v 1.2.4.15 2003/07/12 17:41:46 guus Exp $
*/
#ifndef __TINC_NETUTL_H__

View file

@ -1,7 +1,7 @@
/*
node.c -- node tree management
Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.eu.org>,
2001-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2001-2003 Guus Sliepen <guus@sliepen.eu.org>,
2001-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: node.c,v 1.1.2.21 2003/07/06 23:16:28 guus Exp $
$Id: node.c,v 1.1.2.22 2003/07/12 17:41:46 guus Exp $
*/
#include "config.h"
@ -173,16 +173,16 @@ void dump_nodes(void)
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Nodes:"));
logger(LOG_DEBUG, _("Nodes:"));
for(node = node_tree->head; node; node = node->next) {
n = (node_t *) node->data;
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" %s at %s cipher %d digest %d maclength %d compression %d options %lx status %04x nexthop %s via %s"),
logger(LOG_DEBUG, _(" %s at %s cipher %d digest %d maclength %d compression %d options %lx status %04x nexthop %s via %s"),
n->name, n->hostname, n->cipher ? n->cipher->nid : 0,
n->digest ? n->digest->type : 0, n->maclength, n->compression,
n->options, n->status, n->nexthop ? n->nexthop->name : "-",
n->via ? n->via->name : "-");
}
logger(DEBUG_ALWAYS, LOG_DEBUG, _("End of nodes."));
logger(LOG_DEBUG, _("End of nodes."));
}

View file

@ -1,7 +1,7 @@
/*
node.h -- header for node.c
Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.eu.org>,
2001-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2001-2003 Guus Sliepen <guus@sliepen.eu.org>,
2001-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: node.h,v 1.1.2.23 2003/07/06 23:16:28 guus Exp $
$Id: node.h,v 1.1.2.24 2003/07/12 17:41:46 guus Exp $
*/
#ifndef __TINC_NODE_H__

View file

@ -1,7 +1,7 @@
/*
device.c -- Interaction with OpenBSD tun device
Copyright (C) 2001-2002 Ivo Timmermans <ivo@o2w.nl>,
2001-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2001-2003 Ivo Timmermans <ivo@o2w.nl>,
2001-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.14 2003/07/06 22:11:37 guus Exp $
$Id: device.c,v 1.1.2.15 2003/07/12 17:41:48 guus Exp $
*/
#include "config.h"
@ -55,9 +55,6 @@ char *device_info;
int device_total_in = 0;
int device_total_out = 0;
/*
open the local ethertap device
*/
int setup_device(void)
{
cp();
@ -68,13 +65,13 @@ int setup_device(void)
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
return -1;
}
device_info = _("OpenBSD tun device");
logger(DEBUG_ALWAYS, LOG_INFO, _("%s is a %s"), device, device_info);
logger(LOG_INFO, _("%s is a %s"), device, device_info);
return 0;
}
@ -95,7 +92,7 @@ int read_packet(vpn_packet_t *packet)
cp();
if((lenin = readv(device_fd, vector, 2)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -112,7 +109,7 @@ int read_packet(vpn_packet_t *packet)
break;
default:
logger(DEBUG_TRAFFIC, LOG_ERR,
ifdebug(TRAFFIC) logger(LOG_ERR,
_ ("Unknown address family %d while reading packet from %s %s"),
ntohl(type), device_info, device);
return -1;
@ -122,7 +119,7 @@ int read_packet(vpn_packet_t *packet)
device_total_in += packet->len;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
device_info);
}
@ -137,7 +134,7 @@ int write_packet(vpn_packet_t *packet)
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Writing packet of %d bytes to %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
af = (packet->data[12] << 8) + packet->data[13];
@ -150,7 +147,7 @@ int write_packet(vpn_packet_t *packet)
type = htonl(AF_INET6);
break;
default:
logger(DEBUG_TRAFFIC, LOG_ERR,
ifdebug(TRAFFIC) logger(LOG_ERR,
_("Unknown address family %d while writing packet to %s %s"),
af, device_info, device);
return -1;
@ -162,7 +159,7 @@ int write_packet(vpn_packet_t *packet)
vector[1].iov_len = packet->len - 14;
if(writev(device_fd, vector, 2) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
strerror(errno));
return -1;
}
@ -174,7 +171,7 @@ void dump_device_stats(void)
{
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
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);
}

View file

@ -1,7 +1,7 @@
/*
process.c -- process management functions
Copyright (C) 1999-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1999-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: process.c,v 1.1.2.53 2003/07/11 16:13:00 guus Exp $
$Id: process.c,v 1.1.2.54 2003/07/12 17:41:46 guus Exp $
*/
#include "config.h"
@ -67,7 +67,7 @@ extern int do_purge;
static void memory_full(int size)
{
logger(DEBUG_ALWAYS, LOG_ERR, _("Memory exhausted (couldn't allocate %d bytes), exitting."), size);
logger(LOG_ERR, _("Memory exhausted (couldn't allocate %d bytes), exitting."), size);
cp_trace();
exit(1);
}
@ -96,10 +96,10 @@ void cleanup_and_exit(int c)
close_network_connections();
if(debug_level > DEBUG_NOTHING)
ifdebug(CONNECTIONS)
dump_device_stats();
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Terminating"));
logger(LOG_NOTICE, _("Terminating"));
closelog();
exit(c);
@ -202,7 +202,7 @@ int detach(void)
openlogger(identname, use_logfile?LOGMODE_FILE:(do_detach?LOGMODE_SYSLOG:LOGMODE_STDERR));
logger(DEBUG_ALWAYS, LOG_NOTICE, _("tincd %s (%s %s) starting, debug level %d"),
logger(LOG_NOTICE, _("tincd %s (%s %s) starting, debug level %d"),
VERSION, __DATE__, __TIME__, debug_level);
xalloc_fail_func = memory_full;
@ -217,6 +217,8 @@ static void _execute_script(const char *scriptname, char **envp)
__attribute__ ((noreturn));
static void _execute_script(const char *scriptname, char **envp)
{
int save_errno;
cp();
while(*envp)
@ -232,10 +234,12 @@ static void _execute_script(const char *scriptname, char **envp)
execl(scriptname, NULL);
/* No return on success */
save_errno = errno;
openlogger(identname, use_logfile?LOGMODE_FILE:(do_detach?LOGMODE_SYSLOG:LOGMODE_STDERR));
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not execute `%s': %s"), scriptname,
strerror(errno));
exit(errno);
logger(LOG_ERR, _("Could not execute `%s': %s"), scriptname,
strerror(save_errno));
exit(save_errno);
}
/*
@ -260,35 +264,35 @@ int execute_script(const char *name, char **envp)
pid = fork();
if(pid < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "fork",
logger(LOG_ERR, _("System call `%s' failed: %s"), "fork",
strerror(errno));
return -1;
}
if(pid) {
logger(DEBUG_STATUS, LOG_INFO, _("Executing script %s"), name);
ifdebug(STATUS) logger(LOG_INFO, _("Executing script %s"), name);
free(scriptname);
if(waitpid(pid, &status, 0) == pid) {
if(WIFEXITED(status)) { /* Child exited by itself */
if(WEXITSTATUS(status)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Process %d (%s) exited with non-zero status %d"),
logger(LOG_ERR, _("Process %d (%s) exited with non-zero status %d"),
pid, name, WEXITSTATUS(status));
return -1;
} else
return 0;
} else if(WIFSIGNALED(status)) { /* Child was killed by a signal */
logger(DEBUG_ALWAYS, LOG_ERR, _("Process %d (%s) was killed by signal %d (%s)"), pid,
logger(LOG_ERR, _("Process %d (%s) was killed by signal %d (%s)"), pid,
name, WTERMSIG(status), strsignal(WTERMSIG(status)));
return -1;
} else { /* Something strange happened */
logger(DEBUG_ALWAYS, LOG_ERR, _("Process %d (%s) terminated abnormally"), pid,
logger(LOG_ERR, _("Process %d (%s) terminated abnormally"), pid,
name);
return -1;
}
} else if (errno != EINTR) {
logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "waitpid",
logger(LOG_ERR, _("System call `%s' failed: %s"), "waitpid",
strerror(errno));
return -1;
}
@ -309,20 +313,20 @@ int execute_script(const char *name, char **envp)
static RETSIGTYPE sigterm_handler(int a)
{
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got TERM signal"));
logger(LOG_NOTICE, _("Got TERM signal"));
cleanup_and_exit(0);
}
static RETSIGTYPE sigquit_handler(int a)
{
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got QUIT signal"));
logger(LOG_NOTICE, _("Got QUIT signal"));
cleanup_and_exit(0);
}
static RETSIGTYPE fatal_signal_square(int a)
{
logger(DEBUG_ALWAYS, LOG_ERR, _("Got another fatal signal %d (%s): not restarting."), a,
logger(LOG_ERR, _("Got another fatal signal %d (%s): not restarting."), a,
strsignal(a));
cp_trace();
exit(1);
@ -331,11 +335,11 @@ static RETSIGTYPE fatal_signal_square(int a)
static RETSIGTYPE fatal_signal_handler(int a)
{
struct sigaction act;
logger(DEBUG_ALWAYS, LOG_ERR, _("Got fatal signal %d (%s)"), a, strsignal(a));
logger(LOG_ERR, _("Got fatal signal %d (%s)"), a, strsignal(a));
cp_trace();
if(do_detach) {
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Trying to re-execute in 5 seconds..."));
logger(LOG_NOTICE, _("Trying to re-execute in 5 seconds..."));
act.sa_handler = fatal_signal_square;
act.sa_mask = emptysigset;
@ -347,26 +351,26 @@ static RETSIGTYPE fatal_signal_handler(int a)
remove_pid(pidfilename);
execvp(g_argv[0], g_argv);
} else {
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Not restarting."));
logger(LOG_NOTICE, _("Not restarting."));
exit(1);
}
}
static RETSIGTYPE sighup_handler(int a)
{
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got HUP signal"));
logger(LOG_NOTICE, _("Got HUP signal"));
sighup = 1;
}
static RETSIGTYPE sigint_handler(int a)
{
if(saved_debug_level != -1) {
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Reverting to old debug level (%d)"),
logger(LOG_NOTICE, _("Reverting to old debug level (%d)"),
saved_debug_level);
debug_level = saved_debug_level;
saved_debug_level = -1;
} else {
logger(DEBUG_ALWAYS, LOG_NOTICE,
logger(LOG_NOTICE,
_("Temporarily setting debug level to 5. Kill me with SIGINT again to go back to level %d."),
debug_level);
saved_debug_level = debug_level;
@ -376,7 +380,7 @@ static RETSIGTYPE sigint_handler(int a)
static RETSIGTYPE sigalrm_handler(int a)
{
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got ALRM signal"));
logger(LOG_NOTICE, _("Got ALRM signal"));
sigalrm = 1;
}
@ -401,13 +405,13 @@ static RETSIGTYPE sigwinch_handler(int a)
static RETSIGTYPE unexpected_signal_handler(int a)
{
logger(DEBUG_ALWAYS, LOG_WARNING, _("Got unexpected signal %d (%s)"), a, strsignal(a));
logger(LOG_WARNING, _("Got unexpected signal %d (%s)"), a, strsignal(a));
cp_trace();
}
static RETSIGTYPE ignore_signal_handler(int a)
{
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Ignored signal %d (%s)"), a, strsignal(a));
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, _("Ignored signal %d (%s)"), a, strsignal(a));
}
static struct {

View file

@ -1,7 +1,7 @@
/*
process.h -- header file for process.c
Copyright (C) 1999-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1999-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: process.h,v 1.1.2.14 2003/07/06 23:16:28 guus Exp $
$Id: process.h,v 1.1.2.15 2003/07/12 17:41:46 guus Exp $
*/
#ifndef __TINC_PROCESS_H__

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol.c,v 1.28.4.139 2003/07/06 23:16:28 guus Exp $
$Id: protocol.c,v 1.28.4.140 2003/07/12 17:41:46 guus Exp $
*/
#include "config.h"
@ -95,18 +95,18 @@ int send_request(connection_t *c, const char *format, ...)
va_end(args);
if(len < 0 || len > MAXBUFSIZE - 1) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Output buffer overflow while sending request to %s (%s)"),
logger(LOG_ERR, _("Output buffer overflow while sending request to %s (%s)"),
c->name, c->hostname);
return -1;
}
if(debug_level >= DEBUG_PROTOCOL) {
ifdebug(PROTOCOL) {
sscanf(buffer, "%d", &request);
if(debug_level >= DEBUG_META)
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Sending %s to %s (%s): %s"),
ifdebug(META)
logger(LOG_DEBUG, _("Sending %s to %s (%s): %s"),
request_name[request], c->name, c->hostname, buffer);
else
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Sending %s to %s (%s)"), request_name[request],
logger(LOG_DEBUG, _("Sending %s to %s (%s)"), request_name[request],
c->name, c->hostname);
}
@ -125,14 +125,14 @@ int forward_request(connection_t *from)
cp();
if(debug_level >= DEBUG_PROTOCOL) {
ifdebug(PROTOCOL) {
sscanf(from->buffer, "%d", &request);
if(debug_level >= DEBUG_META)
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Forwarding %s from %s (%s): %s"),
ifdebug(META)
logger(LOG_DEBUG, _("Forwarding %s from %s (%s): %s"),
request_name[request], from->name, from->hostname,
from->buffer);
else
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Forwarding %s from %s (%s)"),
logger(LOG_DEBUG, _("Forwarding %s from %s (%s)"),
request_name[request], from->name, from->hostname);
}
@ -149,28 +149,28 @@ int receive_request(connection_t *c)
if(sscanf(c->buffer, "%d", &request) == 1) {
if((request < 0) || (request >= LAST) || !request_handlers[request]) {
if(debug_level >= DEBUG_META)
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Unknown request from %s (%s): %s"),
ifdebug(META)
logger(LOG_DEBUG, _("Unknown request from %s (%s): %s"),
c->name, c->hostname, c->buffer);
else
logger(DEBUG_ALWAYS, LOG_ERR, _("Unknown request from %s (%s)"),
logger(LOG_ERR, _("Unknown request from %s (%s)"),
c->name, c->hostname);
return -1;
} else {
if(debug_level >= DEBUG_PROTOCOL) {
if(debug_level >= DEBUG_META)
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Got %s from %s (%s): %s"),
ifdebug(PROTOCOL) {
ifdebug(META)
logger(LOG_DEBUG, _("Got %s from %s (%s): %s"),
request_name[request], c->name, c->hostname,
c->buffer);
else
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Got %s from %s (%s)"),
logger(LOG_DEBUG, _("Got %s from %s (%s)"),
request_name[request], c->name, c->hostname);
}
}
if((c->allow_request != ALL) && (c->allow_request != request)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Unauthorized request from %s (%s)"), c->name,
logger(LOG_ERR, _("Unauthorized request from %s (%s)"), c->name,
c->hostname);
return -1;
}
@ -178,12 +178,12 @@ int receive_request(connection_t *c)
if(request_handlers[request] (c))
/* Something went wrong. Probably scriptkiddies. Terminate. */
{
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while processing %s from %s (%s)"),
logger(LOG_ERR, _("Error while processing %s from %s (%s)"),
request_name[request], c->name, c->hostname);
return -1;
}
} else {
logger(DEBUG_ALWAYS, LOG_ERR, _("Bogus data received from %s (%s)"),
logger(LOG_ERR, _("Bogus data received from %s (%s)"),
c->name, c->hostname);
return -1;
}
@ -229,7 +229,7 @@ int seen_request(char *request)
p.request = request;
if(avl_search(past_request_tree, &p)) {
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Already seen request"));
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, _("Already seen request"));
return 1;
} else {
new = (past_request_t *) xmalloc(sizeof(*new));
@ -259,6 +259,6 @@ void age_past_requests(void)
}
if(left || deleted)
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Aging past requests: deleted %d, left %d\n"),
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, _("Aging past requests: deleted %d, left %d\n"),
deleted, left);
}

View file

@ -1,7 +1,7 @@
/*
protocol_auth.c -- handle the meta-protocol, authentication
Copyright (C) 1999-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1999-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol_auth.c,v 1.1.4.22 2003/07/06 23:16:29 guus Exp $
$Id: protocol_auth.c,v 1.1.4.23 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -65,7 +65,7 @@ int id_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d " MAX_STRING " %d", name, &c->protocol_version) != 2) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "ID", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "ID", c->name,
c->hostname);
return -1;
}
@ -73,7 +73,7 @@ int id_h(connection_t *c)
/* Check if identity is a valid name */
if(check_id(name)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s): %s"), "ID", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ID", c->name,
c->hostname, "invalid name");
return -1;
}
@ -82,7 +82,7 @@ int id_h(connection_t *c)
if(c->name) {
if(strcmp(c->name, name)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Peer %s is %s instead of %s"), c->hostname, name,
logger(LOG_ERR, _("Peer %s is %s instead of %s"), c->hostname, name,
c->name);
return -1;
}
@ -92,7 +92,7 @@ int id_h(connection_t *c)
/* Check if version matches */
if(c->protocol_version != myself->connection->protocol_version) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Peer %s (%s) uses incompatible version %d"),
logger(LOG_ERR, _("Peer %s (%s) uses incompatible version %d"),
c->name, c->hostname, c->protocol_version);
return -1;
}
@ -110,7 +110,7 @@ int id_h(connection_t *c)
bla = read_connection_config(c);
if(bla) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Peer %s had unknown identity (%s)"), c->hostname,
logger(LOG_ERR, _("Peer %s had unknown identity (%s)"), c->hostname,
c->name);
return -1;
}
@ -166,10 +166,10 @@ int send_metakey(connection_t *c)
c->outkey[0] &= 0x7F;
if(debug_level >= DEBUG_SCARY_THINGS) {
ifdebug(SCARY_THINGS) {
bin2hex(c->outkey, buffer, len);
buffer[len * 2] = '\0';
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Generated random meta key (unencrypted): %s"),
logger(LOG_DEBUG, _("Generated random meta key (unencrypted): %s"),
buffer);
}
@ -181,7 +181,7 @@ int send_metakey(connection_t *c)
*/
if(RSA_public_encrypt(len, c->outkey, buffer, c->rsa_key, RSA_NO_PADDING) != len) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error during encryption of meta key for %s (%s)"),
logger(LOG_ERR, _("Error during encryption of meta key for %s (%s)"),
c->name, c->hostname);
return -1;
}
@ -221,7 +221,7 @@ int metakey_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, buffer) != 5) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "METAKEY", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "METAKEY", c->name,
c->hostname);
return -1;
}
@ -231,7 +231,7 @@ int metakey_h(connection_t *c)
/* Check if the length of the meta key is all right */
if(strlen(buffer) != len * 2) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Possible intruder %s (%s): %s"), c->name, c->hostname, "wrong keylength");
logger(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name, c->hostname, "wrong keylength");
return -1;
}
@ -250,15 +250,15 @@ int metakey_h(connection_t *c)
/* Decrypt the meta key */
if(RSA_private_decrypt(len, buffer, c->inkey, myself->connection->rsa_key, RSA_NO_PADDING) != len) { /* See challenge() */
logger(DEBUG_ALWAYS, LOG_ERR, _("Error during encryption of meta key for %s (%s)"),
logger(LOG_ERR, _("Error during encryption of meta key for %s (%s)"),
c->name, c->hostname);
return -1;
}
if(debug_level >= DEBUG_SCARY_THINGS) {
ifdebug(SCARY_THINGS) {
bin2hex(c->inkey, buffer, len);
buffer[len * 2] = '\0';
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Received random meta key (unencrypted): %s"), buffer);
logger(LOG_DEBUG, _("Received random meta key (unencrypted): %s"), buffer);
}
/* All incoming requests will now be encrypted. */
@ -269,7 +269,7 @@ int metakey_h(connection_t *c)
c->incipher = EVP_get_cipherbynid(cipher);
if(!c->incipher) {
logger(DEBUG_ALWAYS, LOG_ERR, _("%s (%s) uses unknown cipher!"), c->name, c->hostname);
logger(LOG_ERR, _("%s (%s) uses unknown cipher!"), c->name, c->hostname);
return -1;
}
@ -289,12 +289,12 @@ int metakey_h(connection_t *c)
c->indigest = EVP_get_digestbynid(digest);
if(!c->indigest) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Node %s (%s) uses unknown digest!"), c->name, c->hostname);
logger(LOG_ERR, _("Node %s (%s) uses unknown digest!"), c->name, c->hostname);
return -1;
}
if(c->inmaclength > c->indigest->md_size || c->inmaclength < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("%s (%s) uses bogus MAC length!"), c->name, c->hostname);
logger(LOG_ERR, _("%s (%s) uses bogus MAC length!"), c->name, c->hostname);
return -1;
}
} else {
@ -348,7 +348,7 @@ int challenge_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d " MAX_STRING, buffer) != 1) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "CHALLENGE", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "CHALLENGE", c->name,
c->hostname);
return -1;
}
@ -358,7 +358,7 @@ int challenge_h(connection_t *c)
/* Check if the length of the challenge is all right */
if(strlen(buffer) != len * 2) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
logger(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
c->hostname, "wrong challenge length");
return -1;
}
@ -412,7 +412,7 @@ int chal_reply_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d " MAX_STRING, hishash) != 1) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "CHAL_REPLY", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "CHAL_REPLY", c->name,
c->hostname);
return -1;
}
@ -420,7 +420,7 @@ int chal_reply_h(connection_t *c)
/* Check if the length of the hash is all right */
if(strlen(hishash) != c->outdigest->md_size * 2) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
logger(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
c->hostname, _("wrong challenge reply length"));
return -1;
}
@ -438,13 +438,13 @@ int chal_reply_h(connection_t *c)
/* Verify the incoming hash with the calculated hash */
if(memcmp(hishash, myhash, c->outdigest->md_size)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
logger(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
c->hostname, _("wrong challenge reply"));
if(debug_level >= DEBUG_SCARY_THINGS) {
ifdebug(SCARY_THINGS) {
bin2hex(myhash, hishash, SHA_DIGEST_LENGTH);
hishash[SHA_DIGEST_LENGTH * 2] = '\0';
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Expected challenge reply: %s"), hishash);
logger(LOG_DEBUG, _("Expected challenge reply: %s"), hishash);
}
return -1;
@ -516,7 +516,7 @@ int ack_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d " MAX_STRING " %d %lx", hisport, &weight, &options) != 3) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "ACK", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "ACK", c->name,
c->hostname);
return -1;
}
@ -532,7 +532,7 @@ int ack_h(connection_t *c)
} else {
if(n->connection) {
/* Oh dear, we already have a connection to this node. */
logger(DEBUG_CONNECTIONS, LOG_DEBUG, _("Established a second connection with %s (%s), closing old connection"),
ifdebug(CONNECTIONS) logger(LOG_DEBUG, _("Established a second connection with %s (%s), closing old connection"),
n->name, n->hostname);
terminate_connection(n->connection, 0);
/* Run graph algorithm to purge key and make sure up/down scripts are rerun with new IP addresses and stuff */
@ -549,7 +549,7 @@ int ack_h(connection_t *c)
c->allow_request = ALL;
c->status.active = 1;
logger(DEBUG_CONNECTIONS, LOG_NOTICE, _("Connection with %s (%s) activated"), c->name,
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection with %s (%s) activated"), c->name,
c->hostname);
/* Send him everything we know */

View file

@ -1,7 +1,7 @@
/*
protocol_edge.c -- handle the meta-protocol, edges
Copyright (C) 1999-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1999-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol_edge.c,v 1.1.4.16 2003/07/06 22:11:32 guus Exp $
$Id: protocol_edge.c,v 1.1.4.17 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -79,7 +79,7 @@ int add_edge_h(connection_t *c)
if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %lx %d",
from_name, to_name, to_address, to_port, &options, &weight) != 6) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "ADD_EDGE", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "ADD_EDGE", c->name,
c->hostname);
return -1;
}
@ -87,13 +87,13 @@ int add_edge_h(connection_t *c)
/* Check if names are valid */
if(check_id(from_name)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_EDGE", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_EDGE", c->name,
c->hostname, _("invalid name"));
return -1;
}
if(check_id(to_name)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_EDGE", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_EDGE", c->name,
c->hostname, _("invalid name"));
return -1;
}
@ -130,12 +130,12 @@ int add_edge_h(connection_t *c)
if(e) {
if(e->weight != weight || e->options != options || sockaddrcmp(&e->address, &address)) {
if(from == myself) {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) for ourself which does not match existing entry"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) for ourself which does not match existing entry"),
"ADD_EDGE", c->name, c->hostname);
send_add_edge(c, e);
return 0;
} else {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) which does not match existing entry"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) which does not match existing entry"),
"ADD_EDGE", c->name, c->hostname);
edge_del(e);
graph();
@ -143,7 +143,7 @@ int add_edge_h(connection_t *c)
} else
return 0;
} else if(from == myself) {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) for ourself which does not exist"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) for ourself which does not exist"),
"ADD_EDGE", c->name, c->hostname);
e = new_edge();
e->from = from;
@ -190,7 +190,7 @@ int del_edge_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING, from_name, to_name) != 2) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "DEL_EDGE", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "DEL_EDGE", c->name,
c->hostname);
return -1;
}
@ -198,13 +198,13 @@ int del_edge_h(connection_t *c)
/* Check if names are valid */
if(check_id(from_name)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s): %s"), "DEL_EDGE", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s): %s"), "DEL_EDGE", c->name,
c->hostname, _("invalid name"));
return -1;
}
if(check_id(to_name)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s): %s"), "DEL_EDGE", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s): %s"), "DEL_EDGE", c->name,
c->hostname, _("invalid name"));
return -1;
}
@ -217,7 +217,7 @@ int del_edge_h(connection_t *c)
from = lookup_node(from_name);
if(!from) {
logger(DEBUG_PROTOCOL, LOG_ERR, _("Got %s from %s (%s) which does not appear in the edge tree"),
ifdebug(PROTOCOL) logger(LOG_ERR, _("Got %s from %s (%s) which does not appear in the edge tree"),
"DEL_EDGE", c->name, c->hostname);
return 0;
}
@ -225,7 +225,7 @@ int del_edge_h(connection_t *c)
to = lookup_node(to_name);
if(!to) {
logger(DEBUG_PROTOCOL, LOG_ERR, _("Got %s from %s (%s) which does not appear in the edge tree"),
ifdebug(PROTOCOL) logger(LOG_ERR, _("Got %s from %s (%s) which does not appear in the edge tree"),
"DEL_EDGE", c->name, c->hostname);
return 0;
}
@ -235,13 +235,13 @@ int del_edge_h(connection_t *c)
e = lookup_edge(from, to);
if(!e) {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) which does not appear in the edge tree"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) which does not appear in the edge tree"),
"DEL_EDGE", c->name, c->hostname);
return 0;
}
if(e->from == myself) {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) for ourself"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) for ourself"),
"DEL_EDGE", c->name, c->hostname);
send_add_edge(c, e); /* Send back a correction */
return 0;

View file

@ -1,7 +1,7 @@
/*
protocol_key.c -- handle the meta-protocol, key exchange
Copyright (C) 1999-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1999-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol_key.c,v 1.1.4.17 2003/07/06 22:11:32 guus Exp $
$Id: protocol_key.c,v 1.1.4.18 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -67,7 +67,7 @@ int key_changed_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d %*x " MAX_STRING, name) != 1) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "KEY_CHANGED",
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "KEY_CHANGED",
c->name, c->hostname);
return -1;
}
@ -78,7 +78,7 @@ int key_changed_h(connection_t *c)
n = lookup_node(name);
if(!n) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got %s from %s (%s) origin %s which does not exist"),
logger(LOG_ERR, _("Got %s from %s (%s) origin %s which does not exist"),
"KEY_CHANGED", c->name, c->hostname, name);
return -1;
}
@ -109,7 +109,7 @@ int req_key_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d " MAX_STRING " " MAX_STRING, from_name, to_name) != 2) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "REQ_KEY", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "REQ_KEY", c->name,
c->hostname);
return -1;
}
@ -117,7 +117,7 @@ int req_key_h(connection_t *c)
from = lookup_node(from_name);
if(!from) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got %s from %s (%s) origin %s which does not exist in our connection list"),
logger(LOG_ERR, _("Got %s from %s (%s) origin %s which does not exist in our connection list"),
"REQ_KEY", c->name, c->hostname, from_name);
return -1;
}
@ -125,7 +125,7 @@ int req_key_h(connection_t *c)
to = lookup_node(to_name);
if(!to) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got %s from %s (%s) destination %s which does not exist in our connection list"),
logger(LOG_ERR, _("Got %s from %s (%s) destination %s which does not exist in our connection list"),
"REQ_KEY", c->name, c->hostname, to_name);
return -1;
}
@ -173,7 +173,7 @@ int ans_key_h(connection_t *c)
if(sscanf(c->buffer, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d",
from_name, to_name, key, &cipher, &digest, &maclength,
&compression) != 7) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "ANS_KEY", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "ANS_KEY", c->name,
c->hostname);
return -1;
}
@ -181,7 +181,7 @@ int ans_key_h(connection_t *c)
from = lookup_node(from_name);
if(!from) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got %s from %s (%s) origin %s which does not exist in our connection list"),
logger(LOG_ERR, _("Got %s from %s (%s) origin %s which does not exist in our connection list"),
"ANS_KEY", c->name, c->hostname, from_name);
return -1;
}
@ -189,7 +189,7 @@ int ans_key_h(connection_t *c)
to = lookup_node(to_name);
if(!to) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got %s from %s (%s) destination %s which does not exist in our connection list"),
logger(LOG_ERR, _("Got %s from %s (%s) destination %s which does not exist in our connection list"),
"ANS_KEY", c->name, c->hostname, to_name);
return -1;
}
@ -220,13 +220,13 @@ int ans_key_h(connection_t *c)
from->cipher = EVP_get_cipherbynid(cipher);
if(!from->cipher) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Node %s (%s) uses unknown cipher!"), from->name,
logger(LOG_ERR, _("Node %s (%s) uses unknown cipher!"), from->name,
from->hostname);
return -1;
}
if(from->keylength != from->cipher->key_len + from->cipher->iv_len) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Node %s (%s) uses wrong keylength!"), from->name,
logger(LOG_ERR, _("Node %s (%s) uses wrong keylength!"), from->name,
from->hostname);
return -1;
}
@ -240,13 +240,13 @@ int ans_key_h(connection_t *c)
from->digest = EVP_get_digestbynid(digest);
if(!from->digest) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Node %s (%s) uses unknown digest!"), from->name,
logger(LOG_ERR, _("Node %s (%s) uses unknown digest!"), from->name,
from->hostname);
return -1;
}
if(from->maclength > from->digest->md_size || from->maclength < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Node %s (%s) uses bogus MAC length!"),
logger(LOG_ERR, _("Node %s (%s) uses bogus MAC length!"),
from->name, from->hostname);
return -1;
}
@ -255,7 +255,7 @@ int ans_key_h(connection_t *c)
}
if(compression < 0 || compression > 11) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Node %s (%s) uses bogus compression level!"), from->name, from->hostname);
logger(LOG_ERR, _("Node %s (%s) uses bogus compression level!"), from->name, from->hostname);
return -1;
}

View file

@ -1,7 +1,7 @@
/*
protocol_misc.c -- handle the meta-protocol, miscellaneous functions
Copyright (C) 1999-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1999-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol_misc.c,v 1.1.4.9 2003/07/06 23:16:29 guus Exp $
$Id: protocol_misc.c,v 1.1.4.10 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -40,18 +40,6 @@
#include "system.h"
/* Status strings */
static char (*status_text[]) = {
"Warning",
};
/* Error strings */
static char (*error_text[]) = {
"Error",
};
/* Status and error notification routines */
int send_status(connection_t *c, int statusno, char *statusstring)
@ -59,7 +47,7 @@ int send_status(connection_t *c, int statusno, char *statusstring)
cp();
if(!statusstring)
statusstring = status_text[statusno];
statusstring = "Status";
return send_request(c, "%d %d %s", STATUS, statusno, statusstring);
}
@ -72,13 +60,13 @@ int status_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d %d " MAX_STRING, &statusno, statusstring) != 2) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "STATUS",
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "STATUS",
c->name, c->hostname);
return -1;
}
logger(DEBUG_STATUS, LOG_NOTICE, _("Status message from %s (%s): %s: %s"),
c->name, c->hostname, status_text[statusno], statusstring);
ifdebug(STATUS) logger(LOG_NOTICE, _("Status message from %s (%s): %d: %s"),
c->name, c->hostname, statusno, statusstring);
return 0;
}
@ -88,7 +76,7 @@ int send_error(connection_t *c, int err, char *errstring)
cp();
if(!errstring)
errstring = strerror(err);
errstring = "Error";
return send_request(c, "%d %d %s", ERROR, err, errstring);
}
@ -101,13 +89,13 @@ int error_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d %d " MAX_STRING, &err, errorstring) != 2) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "ERROR",
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "ERROR",
c->name, c->hostname);
return -1;
}
logger(DEBUG_ERROR, LOG_NOTICE, _("Error message from %s (%s): %s: %s"),
c->name, c->hostname, strerror(err), errorstring);
ifdebug(ERROR) logger(LOG_NOTICE, _("Error message from %s (%s): %d: %s"),
c->name, c->hostname, err, errorstring);
terminate_connection(c, c->status.active);
@ -193,7 +181,7 @@ int tcppacket_h(connection_t *c)
cp();
if(sscanf(c->buffer, "%*d %hd", &len) != 1) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Got bad %s from %s (%s)"), "PACKET", c->name,
logger(LOG_ERR, _("Got bad %s from %s (%s)"), "PACKET", c->name,
c->hostname);
return -1;
}

View file

@ -1,7 +1,7 @@
/*
protocol_subnet.c -- handle the meta-protocol, subnets
Copyright (C) 1999-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1999-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol_subnet.c,v 1.1.4.10 2003/07/06 22:11:33 guus Exp $
$Id: protocol_subnet.c,v 1.1.4.11 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -114,7 +114,7 @@ int add_subnet_h(connection_t *c)
/* If we don't know this subnet, but we are the owner, retaliate with a DEL_SUBNET */
if(owner == myself) {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) for ourself"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) for ourself"),
"ADD_SUBNET", c->name, c->hostname);
s->owner = myself;
send_del_subnet(c, s);
@ -176,7 +176,7 @@ int del_subnet_h(connection_t *c)
owner = lookup_node(name);
if(!owner) {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) for %s which is not in our node tree"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) for %s which is not in our node tree"),
"DEL_SUBNET", c->name, c->hostname, name);
return 0;
}
@ -203,7 +203,7 @@ int del_subnet_h(connection_t *c)
free_subnet(s);
if(!find) {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) for %s which does not appear in his subnet tree"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) for %s which does not appear in his subnet tree"),
"DEL_SUBNET", c->name, c->hostname, name);
return 0;
}
@ -211,7 +211,7 @@ int del_subnet_h(connection_t *c)
/* If we are the owner of this subnet, retaliate with an ADD_SUBNET */
if(owner == myself) {
logger(DEBUG_PROTOCOL, LOG_WARNING, _("Got %s from %s (%s) for ourself"),
ifdebug(PROTOCOL) logger(LOG_WARNING, _("Got %s from %s (%s) for ourself"),
"DEL_SUBNET", c->name, c->hostname);
send_add_subnet(c, find);
return 0;

View file

@ -1,7 +1,7 @@
/*
device.c -- raw socket
Copyright (C) 2002 Ivo Timmermans <ivo@o2w.nl>,
2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2002-2003 Ivo Timmermans <ivo@o2w.nl>,
2002-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.6 2003/07/06 22:11:37 guus Exp $
$Id: device.c,v 1.1.2.7 2003/07/12 17:41:48 guus Exp $
*/
#include "config.h"
@ -52,9 +52,6 @@ char *device_info;
int device_total_in = 0;
int device_total_out = 0;
/*
open the local ethertap device
*/
int setup_device(void)
{
struct ifreq ifr;
@ -72,7 +69,7 @@ int setup_device(void)
device_info = _("raw socket");
if((device_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s: %s"), device_info,
logger(LOG_ERR, _("Could not open %s: %s"), device_info,
strerror(errno));
return -1;
}
@ -81,7 +78,7 @@ int setup_device(void)
strncpy(ifr.ifr_ifrn.ifrn_name, interface, IFNAMSIZ);
if(ioctl(device_fd, SIOCGIFINDEX, &ifr)) {
close(device_fd);
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't find interface %s: %s"), interface,
logger(LOG_ERR, _("Can't find interface %s: %s"), interface,
strerror(errno));
return -1;
}
@ -92,11 +89,11 @@ int setup_device(void)
sa.sll_ifindex = ifr.ifr_ifindex;
if(bind(device_fd, (struct sockaddr *) &sa, (socklen_t) sizeof(sa))) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not bind to %s: %s"), device, strerror(errno));
logger(LOG_ERR, _("Could not bind to %s: %s"), device, strerror(errno));
return -1;
}
logger(DEBUG_ALWAYS, LOG_INFO, _("%s is a %s"), device, device_info);
logger(LOG_INFO, _("%s is a %s"), device, device_info);
return 0;
}
@ -108,10 +105,6 @@ void close_device(void)
close(device_fd);
}
/*
read, encrypt and send data that is
available through the ethertap device
*/
int read_packet(vpn_packet_t *packet)
{
int lenin;
@ -119,7 +112,7 @@ int read_packet(vpn_packet_t *packet)
cp();
if((lenin = read(device_fd, packet->data, MTU)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -128,7 +121,7 @@ int read_packet(vpn_packet_t *packet)
device_total_in += packet->len;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
device_info);
}
@ -139,11 +132,11 @@ int write_packet(vpn_packet_t *packet)
{
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Writing packet of %d bytes to %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
if(write(device_fd, packet->data, packet->len) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
strerror(errno));
return -1;
}
@ -157,7 +150,7 @@ void dump_device_stats(void)
{
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
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);
}

View file

@ -1,7 +1,7 @@
/*
route.c -- routing
Copyright (C) 2000-2002 Ivo Timmermans <ivo@o2w.nl>,
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2000-2003 Ivo Timmermans <ivo@o2w.nl>,
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: route.c,v 1.1.2.56 2003/07/07 11:11:33 guus Exp $
$Id: route.c,v 1.1.2.57 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -130,7 +130,7 @@ static void learn_mac(mac_t *address)
/* If we don't know this MAC address yet, store it */
if(!subnet || subnet->owner != myself) {
logger(DEBUG_TRAFFIC, LOG_INFO, _("Learned new MAC address %hx:%hx:%hx:%hx:%hx:%hx"),
ifdebug(TRAFFIC) logger(LOG_INFO, _("Learned new MAC address %hx:%hx:%hx:%hx:%hx:%hx"),
address->x[0], address->x[1], address->x[2], address->x[3],
address->x[4], address->x[5]);
@ -163,7 +163,7 @@ void age_mac(void)
next = node->next;
s = (subnet_t *) node->data;
if(s->type == SUBNET_MAC && s->net.mac.lastseen && s->net.mac.lastseen + macexpire < now) {
logger(DEBUG_TRAFFIC, LOG_INFO, _("MAC address %hx:%hx:%hx:%hx:%hx:%hx expired"),
ifdebug(TRAFFIC) logger(LOG_INFO, _("MAC address %hx:%hx:%hx:%hx:%hx:%hx expired"),
s->net.mac.address.x[0], s->net.mac.address.x[1],
s->net.mac.address.x[2], s->net.mac.address.x[3],
s->net.mac.address.x[4], s->net.mac.address.x[5]);
@ -272,7 +272,7 @@ static node_t *route_ipv4(vpn_packet_t *packet)
subnet = lookup_subnet_ipv4((ipv4_t *) & packet->data[30]);
if(!subnet) {
logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: unknown IPv4 destination address %d.%d.%d.%d"),
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: unknown IPv4 destination address %d.%d.%d.%d"),
packet->data[30], packet->data[31], packet->data[32],
packet->data[33]);
@ -363,7 +363,7 @@ static node_t *route_ipv6(vpn_packet_t *packet)
subnet = lookup_subnet_ipv6((ipv6_t *) & packet->data[38]);
if(!subnet) {
logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
ntohs(*(uint16_t *) & packet->data[38]),
ntohs(*(uint16_t *) & packet->data[40]),
ntohs(*(uint16_t *) & packet->data[42]),
@ -415,7 +415,7 @@ static void route_neighborsol(vpn_packet_t *packet)
if(ns->nd_ns_hdr.icmp6_type != ND_NEIGHBOR_SOLICIT ||
opt->nd_opt_type != ND_OPT_SOURCE_LINKADDR) {
logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: received unknown type neighbor solicitation request"));
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: received unknown type neighbor solicitation request"));
return;
}
@ -432,7 +432,7 @@ static void route_neighborsol(vpn_packet_t *packet)
checksum = inet_checksum(ns, sizeof(*ns) + 8, checksum);
if(checksum) {
logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: checksum error for neighbor solicitation request"));
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: checksum error for neighbor solicitation request"));
return;
}
@ -441,7 +441,7 @@ static void route_neighborsol(vpn_packet_t *packet)
subnet = lookup_subnet_ipv6((ipv6_t *) & ns->nd_ns_target);
if(!subnet) {
logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: neighbor solicitation request for unknown address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: neighbor solicitation request for unknown address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
ntohs(((uint16_t *) & ns->nd_ns_target)[0]),
ntohs(((uint16_t *) & ns->nd_ns_target)[1]),
ntohs(((uint16_t *) & ns->nd_ns_target)[2]),
@ -520,7 +520,7 @@ static void route_arp(vpn_packet_t *packet)
if(ntohs(arp->arp_hrd) != ARPHRD_ETHER || ntohs(arp->arp_pro) != ETHERTYPE_IP ||
arp->arp_hln != ETHER_ADDR_LEN || arp->arp_pln != 4 || ntohs(arp->arp_op) != ARPOP_REQUEST) {
logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: received unknown type ARP request"));
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: received unknown type ARP request"));
return;
}
@ -529,7 +529,7 @@ static void route_arp(vpn_packet_t *packet)
subnet = lookup_subnet_ipv4((ipv4_t *) arp->arp_tpa);
if(!subnet) {
logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: ARP request for unknown address %d.%d.%d.%d"),
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: ARP request for unknown address %d.%d.%d.%d"),
arp->arp_tpa[0], arp->arp_tpa[1], arp->arp_tpa[2],
arp->arp_tpa[3]);
return;
@ -584,7 +584,7 @@ void route_outgoing(vpn_packet_t *packet)
return;
default:
logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
return;
}
if(n)

View file

@ -1,7 +1,7 @@
/*
route.h -- header file for route.c
Copyright (C) 2000-2002 Ivo Timmermans <zarq@iname.com>
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2000-2003 Ivo Timmermans <zarq@iname.com>
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: route.h,v 1.1.2.10 2003/06/11 19:28:35 guus Exp $
$Id: route.h,v 1.1.2.11 2003/07/12 17:41:47 guus Exp $
*/
#ifndef __TINC_ROUTE_H__

View file

@ -1,7 +1,7 @@
/*
device.c -- Interaction with Solaris tun device
Copyright (C) 2001-2002 Ivo Timmermans <ivo@o2w.nl>,
2001-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 2001-2003 Ivo Timmermans <ivo@o2w.nl>,
2001-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.13 2003/07/06 22:11:37 guus Exp $
$Id: device.c,v 1.1.2.14 2003/07/12 17:41:48 guus Exp $
*/
@ -68,7 +68,7 @@ int setup_device(void)
device = DEFAULT_DEVICE;
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
return -1;
}
@ -80,35 +80,35 @@ int setup_device(void)
ppa = atoi(ptr);
if((ip_fd = open("/dev/ip", O_RDWR, 0)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open /dev/ip: %s"), strerror(errno));
logger(LOG_ERR, _("Could not open /dev/ip: %s"), strerror(errno));
return -1;
}
/* Assign a new PPA and get its unit number. */
if((ppa = ioctl(device_fd, TUNNEWPPA, ppa)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't assign new interface: %s"), strerror(errno));
logger(LOG_ERR, _("Can't assign new interface: %s"), strerror(errno));
return -1;
}
if((if_fd = open(device, O_RDWR, 0)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Could not open %s twice: %s"), device,
logger(LOG_ERR, _("Could not open %s twice: %s"), device,
strerror(errno));
return -1;
}
if(ioctl(if_fd, I_PUSH, "ip") < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't push IP module: %s"), strerror(errno));
logger(LOG_ERR, _("Can't push IP module: %s"), strerror(errno));
return -1;
}
/* Assign ppa according to the unit number returned by tun device */
if(ioctl(if_fd, IF_UNITSEL, (char *) &ppa) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't set PPA %d: %s"), ppa, strerror(errno));
logger(LOG_ERR, _("Can't set PPA %d: %s"), ppa, strerror(errno));
return -1;
}
if(ioctl(ip_fd, I_LINK, if_fd) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't link TUN device to IP: %s"), strerror(errno));
logger(LOG_ERR, _("Can't link TUN device to IP: %s"), strerror(errno));
return -1;
}
@ -117,7 +117,7 @@ int setup_device(void)
device_info = _("Solaris tun device");
logger(DEBUG_ALWAYS, LOG_INFO, _("%s is a %s"), device, device_info);
logger(LOG_INFO, _("%s is a %s"), device, device_info);
return 0;
}
@ -136,7 +136,7 @@ int read_packet(vpn_packet_t *packet)
cp();
if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno));
return -1;
}
@ -148,7 +148,7 @@ int read_packet(vpn_packet_t *packet)
device_total_in += packet->len;
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
device_info);
return 0;
@ -158,11 +158,11 @@ int write_packet(vpn_packet_t *packet)
{
cp();
logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Writing packet of %d bytes to %s"),
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
if(write(device_fd, packet->data + 14, packet->len - 14) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Can't write to %s %s: %s"), device_info, packet->len,
logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, packet->len,
strerror(errno));
return -1;
}
@ -176,7 +176,7 @@ void dump_device_stats(void)
{
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
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);
}

View file

@ -1,7 +1,7 @@
/*
subnet.c -- handle subnet lookups and lists
Copyright (C) 2000-2002 Guus Sliepen <guus@sliepen.eu.org>,
2000-2002 Ivo Timmermans <ivo@o2w.nl>
Copyright (C) 2000-2003 Guus Sliepen <guus@sliepen.eu.org>,
2000-2003 Ivo Timmermans <ivo@o2w.nl>
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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: subnet.c,v 1.1.2.45 2003/07/06 23:16:29 guus Exp $
$Id: subnet.c,v 1.1.2.46 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -111,7 +111,7 @@ static int subnet_compare(subnet_t *a, subnet_t *b)
case SUBNET_IPV6:
return subnet_compare_ipv6(a, b);
default:
logger(DEBUG_ALWAYS, LOG_ERR, _("subnet_compare() was called with unknown subnet type %d, exitting!"),
logger(LOG_ERR, _("subnet_compare() was called with unknown subnet type %d, exitting!"),
a->type);
cp_trace();
exit(0);
@ -295,7 +295,7 @@ char *net2str(subnet_t *subnet)
break;
default:
logger(DEBUG_ALWAYS, LOG_ERR,
logger(LOG_ERR,
_("net2str() was called with unknown subnet type %d, exiting!"),
subnet->type);
cp_trace();
@ -411,14 +411,14 @@ void dump_subnets(void)
cp();
logger(DEBUG_ALWAYS, LOG_DEBUG, _("Subnet list:"));
logger(LOG_DEBUG, _("Subnet list:"));
for(node = subnet_tree->head; node; node = node->next) {
subnet = (subnet_t *) node->data;
netstr = net2str(subnet);
logger(DEBUG_ALWAYS, LOG_DEBUG, _(" %s owner %s"), netstr, subnet->owner->name);
logger(LOG_DEBUG, _(" %s owner %s"), netstr, subnet->owner->name);
free(netstr);
}
logger(DEBUG_ALWAYS, LOG_DEBUG, _("End of subnet list."));
logger(LOG_DEBUG, _("End of subnet list."));
}

View file

@ -1,7 +1,7 @@
/*
tincd.c -- the main file for tincd
Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
2000-2002 Guus Sliepen <guus@sliepen.eu.org>
Copyright (C) 1998-2003 Ivo Timmermans <ivo@o2w.nl>
2000-2003 Guus Sliepen <guus@sliepen.eu.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
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: tincd.c,v 1.10.4.71 2003/07/06 23:16:29 guus Exp $
$Id: tincd.c,v 1.10.4.72 2003/07/12 17:41:47 guus Exp $
*/
#include "config.h"
@ -334,7 +334,7 @@ static void make_names(void)
if(!confbase)
asprintf(&confbase, "%s/tinc/%s", CONFDIR, netname);
else
logger(DEBUG_ALWAYS, LOG_INFO, _("Both netname and configuration directory given, using the latter..."));
logger(LOG_INFO, _("Both netname and configuration directory given, using the latter..."));
if(!identname)
asprintf(&identname, "tinc.%s", netname);
@ -367,7 +367,7 @@ int main(int argc, char **argv, char **envp)
if(show_version) {
printf(_("%s version %s (built %s %s, protocol %d)\n"), PACKAGE,
VERSION, __DATE__, __TIME__, PROT_CURRENT);
printf(_("Copyright (C) 1998-2002 Ivo Timmermans, Guus Sliepen and others.\n"
printf(_("Copyright (C) 1998-2003 Ivo Timmermans, Guus Sliepen and others.\n"
"See the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n"
@ -389,11 +389,11 @@ int main(int argc, char **argv, char **envp)
if(do_mlock)
#ifdef HAVE_MLOCKALL
if(mlockall(MCL_CURRENT | MCL_FUTURE)) {
logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "mlockall",
logger(LOG_ERR, _("System call `%s' failed: %s"), "mlockall",
strerror(errno));
#else
{
logger(DEBUG_ALWAYS, LOG_ERR, _("mlockall() not supported on this platform!"));
logger(LOG_ERR, _("mlockall() not supported on this platform!"));
#endif
return -1;
}
@ -417,7 +417,7 @@ int main(int argc, char **argv, char **envp)
exit(1);
if(lzo_init() != LZO_E_OK) {
logger(DEBUG_ALWAYS, LOG_ERR, _("Error initializing LZO compressor!"));
logger(LOG_ERR, _("Error initializing LZO compressor!"));
exit(1);
}
@ -430,14 +430,14 @@ int main(int argc, char **argv, char **envp)
cleanup_and_exit(1);
}
logger(DEBUG_ALWAYS, LOG_ERR, _("Unrecoverable error"));
logger(LOG_ERR, _("Unrecoverable error"));
cp_trace();
if(do_detach) {
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Restarting in %d seconds!"), maxtimeout);
logger(LOG_NOTICE, _("Restarting in %d seconds!"), maxtimeout);
sleep(maxtimeout);
} else {
logger(DEBUG_ALWAYS, LOG_ERR, _("Not restarting."));
logger(LOG_ERR, _("Not restarting."));
exit(1);
}
}