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.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__
extern int setup_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 void dump_device_stats(void);
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.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"
return 0;
}
+void close_device(void)
+{
+cp
+ close(device_fd);
+}
+
/*
read, encrypt and send data that is
available through the ethertap device
cp
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
+}
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.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 "system.h"
+int maxtimeout = 900;
int seconds_till_retry = 5;
+
int tcp_socket = -1;
int udp_socket = -1;
to.sin_addr.s_addr = htonl(n->address);
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"),
n->name, n->hostname);
static config_t *cfg = NULL;
static int retry = 0;
char *name;
- int maxtimeout = 900;
cp
if(!cfg)
cfg = lookup_config(config_tree, "ConnectTo");
int r;
time_t last_ping_check;
int t;
+ vpn_packet_t packet;
cp
last_ping_check = time(NULL);
/* local tap data */
if(FD_ISSET(device_fd, &fset))
- handle_tap_input();
+ {
+ if(read_packet(&packet))
+ route_outgoing(&packet);
+ else
+ return;
+ }
}
}
cp
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.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__
queue_element_t *tail;
} packet_queue_t;
+extern int maxtimeout;
extern int seconds_till_retry;
extern char *request_name[256];
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.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"
avl_tree_t *node_tree; /* Known nodes, sorted by name */
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)
{
return strcmp(a->name, b->name);
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.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"
RETSIGTYPE
sigusr1_handler(int a, siginfo_t *info, void *b)
{
- dump_connection_list();
+ dump_connections();
}
RETSIGTYPE
sigusr2_handler(int a, siginfo_t *info, void *b)
{
- dump_subnet_list();
+ dump_device_stats();
+ dump_nodes();
+ dump_vertices();
+ dump_subnets();
}
RETSIGTYPE
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.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 "subnet.h"
#include "route.h"
#include "protocol.h"
+#include "device.h"
#include "system.h"
memcpy(arp->arp_sha, packet->data + ETHER_ADDR_LEN, ETHER_ADDR_LEN); /* add fake source hard addr */
arp->arp_op = htons(ARPOP_REPLY);
- accept_packet(packet);
+ write_packet(packet);
cp
}
{
case RMODE_ROUTER:
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;
case RMODE_SWITCH:
{
if(subnet)
{
if(subnet->owner == myself)
- accept_packet(packet);
+ write_packet(packet);
else
send_packet(subnet->owner, packet);
}
else
{
broadcast_packet(source, packet);
- accept_packet(packet);
+ write_packet(packet);
}
}
break;
case RMODE_HUB:
broadcast_packet(source, packet); /* Spread it on */
- accept_packet(packet);
+ write_packet(packet);
break;
}
}
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.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"
return p;
}
-void dump_subnet_list(void)
+void dump_subnets(void)
{
char *netstr;
subnet_t *subnet;
along with this program; if not, write to the Free Software
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__
extern subnet_t *lookup_subnet_mac(mac_t *);
extern subnet_t *lookup_subnet_ipv4(ipv4_t *);
extern subnet_t *lookup_subnet_ipv6(ipv6_t *);
-extern void dump_subnet_list(void);
+extern void dump_subnets(void);
#endif /* __TINC_SUBNET_H__ */
along with this program; if not, write to the Free Software
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 "system.h"
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)
{