Make sure everything links.

This commit is contained in:
Guus Sliepen 2001-10-27 13:13:35 +00:00
parent 82e3837109
commit ac066bb057
10 changed files with 52 additions and 29 deletions

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.h,v 1.1.2.2 2001/10/27 12:13:17 guus Exp $ $Id: device.h,v 1.1.2.3 2001/10/27 13:13:35 guus Exp $
*/ */
#ifndef __TINC_DEVICE_H__ #ifndef __TINC_DEVICE_H__
@ -27,7 +27,7 @@ extern int device_fd;
extern int setup_device(void); extern int setup_device(void);
extern void close_device(void); extern void close_device(void);
extern vpn_packet_t *read_packet(void); extern int read_packet(vpn_packet_t *);
extern int write_packet(vpn_packet_t *); extern int write_packet(vpn_packet_t *);
extern void dump_device_stats(void); extern void dump_device_stats(void);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: device.c,v 1.1.2.2 2001/10/27 12:13:17 guus Exp $ $Id: device.c,v 1.1.2.3 2001/10/27 13:13:35 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -124,6 +124,12 @@ cp
return 0; return 0;
} }
void close_device(void)
{
cp
close(device_fd);
}
/* /*
read, encrypt and send data that is read, encrypt and send data that is
available through the ethertap device available through the ethertap device
@ -196,3 +202,12 @@ cp
cp cp
return 0; return 0;
} }
void dump_device_stats(void)
{
cp
syslog(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device_fname);
syslog(LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
syslog(LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
cp
}

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net.c,v 1.35.4.137 2001/10/27 12:13:17 guus Exp $ $Id: net.c,v 1.35.4.138 2001/10/27 13:13:35 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -72,7 +72,9 @@
#include "system.h" #include "system.h"
int maxtimeout = 900;
int seconds_till_retry = 5; int seconds_till_retry = 5;
int tcp_socket = -1; int tcp_socket = -1;
int udp_socket = -1; int udp_socket = -1;
@ -161,7 +163,7 @@ cp
to.sin_addr.s_addr = htonl(n->address); to.sin_addr.s_addr = htonl(n->address);
to.sin_port = htons(n->port); to.sin_port = htons(n->port);
if((sendto(socket, (char *) outpkt.salt, outlen, 0, (const struct sockaddr *)&to, tolen)) < 0) if((sendto(udp_socket, (char *) outpkt.salt, outlen, 0, (const struct sockaddr *)&to, tolen)) < 0)
{ {
syslog(LOG_ERR, _("Error sending packet to %s (%s): %m"), syslog(LOG_ERR, _("Error sending packet to %s (%s): %m"),
n->name, n->hostname); n->name, n->hostname);
@ -1041,7 +1043,6 @@ try_outgoing_connections(int a)
static config_t *cfg = NULL; static config_t *cfg = NULL;
static int retry = 0; static int retry = 0;
char *name; char *name;
int maxtimeout = 900;
cp cp
if(!cfg) if(!cfg)
cfg = lookup_config(config_tree, "ConnectTo"); cfg = lookup_config(config_tree, "ConnectTo");
@ -1122,6 +1123,7 @@ void main_loop(void)
int r; int r;
time_t last_ping_check; time_t last_ping_check;
int t; int t;
vpn_packet_t packet;
cp cp
last_ping_check = time(NULL); last_ping_check = time(NULL);
@ -1190,7 +1192,12 @@ cp
/* local tap data */ /* local tap data */
if(FD_ISSET(device_fd, &fset)) if(FD_ISSET(device_fd, &fset))
handle_tap_input(); {
if(read_packet(&packet))
route_outgoing(&packet);
else
return;
}
} }
} }
cp cp

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net.h,v 1.9.4.35 2001/10/27 12:13:17 guus Exp $ $Id: net.h,v 1.9.4.36 2001/10/27 13:13:35 guus Exp $
*/ */
#ifndef __TINC_NET_H__ #ifndef __TINC_NET_H__
@ -90,6 +90,7 @@ typedef struct packet_queue_t {
queue_element_t *tail; queue_element_t *tail;
} packet_queue_t; } packet_queue_t;
extern int maxtimeout;
extern int seconds_till_retry; extern int seconds_till_retry;
extern char *request_name[256]; extern char *request_name[256];

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: node.c,v 1.1.2.2 2001/10/27 12:13:17 guus Exp $ $Id: node.c,v 1.1.2.3 2001/10/27 13:13:35 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -36,6 +36,8 @@
avl_tree_t *node_tree; /* Known nodes, sorted by name */ avl_tree_t *node_tree; /* Known nodes, sorted by name */
avl_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */ avl_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */
node_t *myself;
int node_compare(node_t *a, node_t *b) int node_compare(node_t *a, node_t *b)
{ {
return strcmp(a->name, b->name); return strcmp(a->name, b->name);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: process.c,v 1.1.2.26 2001/10/27 12:13:17 guus Exp $ $Id: process.c,v 1.1.2.27 2001/10/27 13:13:35 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -372,13 +372,16 @@ sigint_handler(int a, siginfo_t *info, void *b)
RETSIGTYPE RETSIGTYPE
sigusr1_handler(int a, siginfo_t *info, void *b) sigusr1_handler(int a, siginfo_t *info, void *b)
{ {
dump_connection_list(); dump_connections();
} }
RETSIGTYPE RETSIGTYPE
sigusr2_handler(int a, siginfo_t *info, void *b) sigusr2_handler(int a, siginfo_t *info, void *b)
{ {
dump_subnet_list(); dump_device_stats();
dump_nodes();
dump_vertices();
dump_subnets();
} }
RETSIGTYPE RETSIGTYPE

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: route.c,v 1.1.2.19 2001/10/27 12:13:17 guus Exp $ $Id: route.c,v 1.1.2.20 2001/10/27 13:13:35 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -46,6 +46,7 @@
#include "subnet.h" #include "subnet.h"
#include "route.h" #include "route.h"
#include "protocol.h" #include "protocol.h"
#include "device.h"
#include "system.h" #include "system.h"
@ -217,7 +218,7 @@ cp
memcpy(arp->arp_sha, packet->data + ETHER_ADDR_LEN, ETHER_ADDR_LEN); /* add fake source hard addr */ memcpy(arp->arp_sha, packet->data + ETHER_ADDR_LEN, ETHER_ADDR_LEN); /* add fake source hard addr */
arp->arp_op = htons(ARPOP_REPLY); arp->arp_op = htons(ARPOP_REPLY);
accept_packet(packet); write_packet(packet);
cp cp
} }
@ -274,7 +275,7 @@ void route_incoming(node_t *source, vpn_packet_t *packet)
{ {
case RMODE_ROUTER: case RMODE_ROUTER:
memcpy(packet->data, mymac.net.mac.address.x, 6); /* Override destination address to make the kernel accept it */ memcpy(packet->data, mymac.net.mac.address.x, 6); /* Override destination address to make the kernel accept it */
accept_packet(packet); write_packet(packet);
break; break;
case RMODE_SWITCH: case RMODE_SWITCH:
{ {
@ -285,20 +286,20 @@ void route_incoming(node_t *source, vpn_packet_t *packet)
if(subnet) if(subnet)
{ {
if(subnet->owner == myself) if(subnet->owner == myself)
accept_packet(packet); write_packet(packet);
else else
send_packet(subnet->owner, packet); send_packet(subnet->owner, packet);
} }
else else
{ {
broadcast_packet(source, packet); broadcast_packet(source, packet);
accept_packet(packet); write_packet(packet);
} }
} }
break; break;
case RMODE_HUB: case RMODE_HUB:
broadcast_packet(source, packet); /* Spread it on */ broadcast_packet(source, packet); /* Spread it on */
accept_packet(packet); write_packet(packet);
break; break;
} }
} }

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: subnet.c,v 1.1.2.25 2001/10/27 12:13:17 guus Exp $ $Id: subnet.c,v 1.1.2.26 2001/10/27 13:13:35 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -338,7 +338,7 @@ cp
return p; return p;
} }
void dump_subnet_list(void) void dump_subnets(void)
{ {
char *netstr; char *netstr;
subnet_t *subnet; subnet_t *subnet;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: subnet.h,v 1.1.2.11 2001/10/27 12:13:17 guus Exp $ $Id: subnet.h,v 1.1.2.12 2001/10/27 13:13:35 guus Exp $
*/ */
#ifndef __TINC_SUBNET_H__ #ifndef __TINC_SUBNET_H__
@ -81,6 +81,6 @@ extern subnet_t *lookup_subnet(struct node_t *, subnet_t *);
extern subnet_t *lookup_subnet_mac(mac_t *); extern subnet_t *lookup_subnet_mac(mac_t *);
extern subnet_t *lookup_subnet_ipv4(ipv4_t *); extern subnet_t *lookup_subnet_ipv4(ipv4_t *);
extern subnet_t *lookup_subnet_ipv6(ipv6_t *); extern subnet_t *lookup_subnet_ipv6(ipv6_t *);
extern void dump_subnet_list(void); extern void dump_subnets(void);
#endif /* __TINC_SUBNET_H__ */ #endif /* __TINC_SUBNET_H__ */

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: vertex.c,v 1.1.2.2 2001/10/27 12:13:17 guus Exp $ $Id: vertex.c,v 1.1.2.3 2001/10/27 13:13:35 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -40,12 +40,6 @@
#include "system.h" #include "system.h"
avl_tree_t *vertex_tree; /* Tree with all known vertices (replaces active_tree) */ avl_tree_t *vertex_tree; /* Tree with all known vertices (replaces active_tree) */
avl_tree_t *connection_tree; /* Tree with all meta connections with ourself */
int connection_compare(connection_t *a, connection_t *b)
{
return a->socket - b->socket;
}
int vertex_compare(vertex_t *a, vertex_t *b) int vertex_compare(vertex_t *a, vertex_t *b)
{ {