* 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!
# 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
# 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
\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
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
@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
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 $
*/
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"
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__
* 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
-/* $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
/* 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
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"
/*
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
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"
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;
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;
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;
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;
}
&& 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;
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;
}
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;
}
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);
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;
}
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;
}
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;
}
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;
}
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;
}
/*
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
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__
/*
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
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"
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)
/*
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
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__
/*
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
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"
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;
}
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;
}
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;
{
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;
}
{
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);
}
/*
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
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"
int device_total_in = 0;
int device_total_out = 0;
-/*
- open the local ethertap device
-*/
int setup_device(void)
{
cp();
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;
}
close(device_fd);
}
-/*
- read, encrypt and send data that is
- available through the ethertap device
-*/
int read_packet(vpn_packet_t *packet)
{
int lenin;
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;
}
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;
{
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;
}
{
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);
}
/*
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
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__
/*
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
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"
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."));
}
/*
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
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__
/*
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
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"
/*
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
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__
/*
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
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"
int device_total_in = 0;
int device_total_out = 0;
-/*
- open the local ethertap device
-*/
int setup_device(void)
{
cp();
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;
}
close(device_fd);
}
-/*
- read, encrypt and send data that is
- available through the ethertap device
-*/
int read_packet(vpn_packet_t *packet)
{
int lenin;
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;
}
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;
{
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;
}
{
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);
}
/*
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
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:
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 */
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) {
}
}
- 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);
}
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;
/*
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
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);
/*
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
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"
int device_total_in = 0;
int device_total_out = 0;
-/*
- open the local ethertap device
-*/
int setup_device(void)
{
struct ifreq ifr;
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;
}
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
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;
}
close(device_fd);
}
-/*
- read, encrypt and send data that is
- available through the ethertap device
-*/
int read_packet(vpn_packet_t *packet)
{
int lenin;
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;
}
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;
}
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;
}
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;
{
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;
}
*(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;
}
{
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);
}
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>
#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;
}
}
-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);
#endif
break;
}
+
+ va_end(ap);
}
void closelogger(void) {
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__ */
/*
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
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"
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) {
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;
}
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;
}
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;
}
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;
}
/*
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
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__
/*
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
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"
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) {
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;
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);
}
} 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);
}
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);
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();
/* 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);
}
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;
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);
}
/*
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
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__
/*
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
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"
{
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);
(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;
}
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++)
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;
}
/* 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);
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;
}
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;
}
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;
}
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) {
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) {
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;
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;
}
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;
/*
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
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"
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;
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;
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 {
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;
}
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;
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;
}
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;
}
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;
}
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);
&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))
(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
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);
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;
}
}
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;
}
}
&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;
}
}
(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
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;
}
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);
}
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;
}
/*
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
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"
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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;
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);
}
{
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;
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);
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;
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 */
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;
}
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;
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);
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;
}
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);
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);
/*
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
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"
int device_total_in = 0;
int device_total_out = 0;
-/*
- open the local ethertap device
-*/
int setup_device(void)
{
cp();
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;
}
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;
}
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);
}
{
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;
}
{
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);
}
/*
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
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"
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;
}
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);
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);
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));
}
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);
/*
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
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__
/*
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
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"
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."));
}
/*
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
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__
/*
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
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"
int device_total_in = 0;
int device_total_out = 0;
-/*
- open the local ethertap device
-*/
int setup_device(void)
{
cp();
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;
}
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;
}
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;
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);
}
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];
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;
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;
}
{
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);
}
/*
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
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"
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);
}
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);
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;
__attribute__ ((noreturn));
static void _execute_script(const char *scriptname, char **envp)
{
+ int save_errno;
+
cp();
while(*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);
}
/*
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;
}
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);
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;
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;
static RETSIGTYPE sigalrm_handler(int a)
{
- logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got ALRM signal"));
+ logger(LOG_NOTICE, _("Got ALRM signal"));
sigalrm = 1;
}
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 {
/*
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
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__
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"
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);
}
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);
}
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;
}
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;
}
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));
}
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);
}
/*
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
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"
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;
}
/* 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;
}
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;
}
/* 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;
}
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;
}
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);
}
*/
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;
}
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;
}
/* 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;
}
/* 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. */
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;
}
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 {
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;
}
/* 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;
}
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;
}
/* 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;
}
/* 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;
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;
}
} 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 */
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 */
/*
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
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"
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;
}
/* 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;
}
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();
} 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;
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;
}
/* 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;
}
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;
}
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;
}
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;
/*
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
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"
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
/*
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
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"
#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)
cp();
if(!statusstring)
- statusstring = status_text[statusno];
+ statusstring = "Status";
return send_request(c, "%d %d %s", STATUS, statusno, statusstring);
}
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;
}
cp();
if(!errstring)
- errstring = strerror(err);
+ errstring = "Error";
return send_request(c, "%d %d %s", ERROR, err, errstring);
}
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);
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;
}
/*
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
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"
/* 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);
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;
}
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;
}
/* 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;
/*
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
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"
int device_total_in = 0;
int device_total_out = 0;
-/*
- open the local ethertap device
-*/
int setup_device(void)
{
struct ifreq ifr;
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;
}
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;
}
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;
}
close(device_fd);
}
-/*
- read, encrypt and send data that is
- available through the ethertap device
-*/
int read_packet(vpn_packet_t *packet)
{
int lenin;
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;
}
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);
}
{
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;
}
{
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);
}
/*
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
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"
/* 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]);
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]);
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]);
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]),
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;
}
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;
}
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]),
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;
}
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;
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)
/*
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
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__
/*
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
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 $
*/
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;
}
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;
}
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;
}
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;
}
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;
{
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;
}
{
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);
}
/*
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
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"
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);
break;
default:
- logger(DEBUG_ALWAYS, LOG_ERR,
+ logger(LOG_ERR,
_("net2str() was called with unknown subnet type %d, exiting!"),
subnet->type);
cp_trace();
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."));
}
/*
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
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"
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);
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"
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;
}
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);
}
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);
}
}