From: Guus Sliepen Date: Sat, 27 Oct 2001 13:13:35 +0000 (+0000) Subject: Make sure everything links. X-Git-Tag: import-tinc-1.1~785^2~443 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=ac066bb057dcb187bf91670793ba5e6ca456e052;p=meshlink Make sure everything links. --- diff --git a/src/device.h b/src/device.h index dded47ad..c2c28a13 100644 --- a/src/device.h +++ b/src/device.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.h,v 1.1.2.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__ @@ -27,7 +27,7 @@ extern int device_fd; 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); diff --git a/src/linux/device.c b/src/linux/device.c index c82a820e..1cb43077 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.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" @@ -124,6 +124,12 @@ cp return 0; } +void close_device(void) +{ +cp + close(device_fd); +} + /* read, encrypt and send data that is available through the ethertap device @@ -196,3 +202,12 @@ cp 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 +} diff --git a/src/net.c b/src/net.c index c0c8e66f..fe9eed78 100644 --- a/src/net.c +++ b/src/net.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.c,v 1.35.4.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" @@ -72,7 +72,9 @@ #include "system.h" +int maxtimeout = 900; int seconds_till_retry = 5; + int tcp_socket = -1; int udp_socket = -1; @@ -161,7 +163,7 @@ cp 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); @@ -1041,7 +1043,6 @@ try_outgoing_connections(int a) static config_t *cfg = NULL; static int retry = 0; char *name; - int maxtimeout = 900; cp if(!cfg) cfg = lookup_config(config_tree, "ConnectTo"); @@ -1122,6 +1123,7 @@ void main_loop(void) int r; time_t last_ping_check; int t; + vpn_packet_t packet; cp last_ping_check = time(NULL); @@ -1190,7 +1192,12 @@ cp /* local tap data */ if(FD_ISSET(device_fd, &fset)) - handle_tap_input(); + { + if(read_packet(&packet)) + route_outgoing(&packet); + else + return; + } } } cp diff --git a/src/net.h b/src/net.h index eb7ad7ea..e5daed9e 100644 --- a/src/net.h +++ b/src/net.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.h,v 1.9.4.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__ @@ -90,6 +90,7 @@ typedef struct packet_queue_t { queue_element_t *tail; } packet_queue_t; +extern int maxtimeout; extern int seconds_till_retry; extern char *request_name[256]; diff --git a/src/node.c b/src/node.c index 53e520e9..3776d184 100644 --- a/src/node.c +++ b/src/node.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: node.c,v 1.1.2.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" @@ -36,6 +36,8 @@ 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); diff --git a/src/process.c b/src/process.c index 9acb5fdd..d971a0f2 100644 --- a/src/process.c +++ b/src/process.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: process.c,v 1.1.2.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" @@ -372,13 +372,16 @@ sigint_handler(int a, siginfo_t *info, void *b) 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 diff --git a/src/route.c b/src/route.c index c8de7a57..170f509e 100644 --- a/src/route.c +++ b/src/route.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: route.c,v 1.1.2.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" @@ -46,6 +46,7 @@ #include "subnet.h" #include "route.h" #include "protocol.h" +#include "device.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 */ arp->arp_op = htons(ARPOP_REPLY); - accept_packet(packet); + write_packet(packet); cp } @@ -274,7 +275,7 @@ void route_incoming(node_t *source, vpn_packet_t *packet) { 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: { @@ -285,20 +286,20 @@ void route_incoming(node_t *source, vpn_packet_t *packet) 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; } } diff --git a/src/subnet.c b/src/subnet.c index 48ac45e2..fff384ff 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: subnet.c,v 1.1.2.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" @@ -338,7 +338,7 @@ cp return p; } -void dump_subnet_list(void) +void dump_subnets(void) { char *netstr; subnet_t *subnet; diff --git a/src/subnet.h b/src/subnet.h index 59693019..50cfefd7 100644 --- a/src/subnet.h +++ b/src/subnet.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: subnet.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__ @@ -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_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__ */ diff --git a/src/vertex.c b/src/vertex.c index 4f0b5d6e..9e72f9e7 100644 --- a/src/vertex.c +++ b/src/vertex.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: 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" @@ -40,12 +40,6 @@ #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) {