## Process this file with automake to produce Makefile.in
-# $Id: Makefile.am,v 1.7 2002/04/28 12:46:25 zarq Exp $
+# $Id: Makefile.am,v 1.8 2002/05/02 11:50:07 zarq Exp $
noinst_LIBRARIES = libtinc.a
INCLUDES = @INCLUDES@ -I. -I$(top_builddir) -I$(top_srcdir)/intl
libtinc_a_SOURCES = xmalloc.c pidfile.c utils.c getopt.c getopt1.c \
- list.c avl_tree.c hooks.c dropin.c edge.c conf.c netutl.c logging.c connection.c subnet.c node.c
+ list.c avl_tree.c hooks.c dropin.c edge.c conf.c netutl.c logging.c connection.c subnet.c node.c graph.c
libtinc_a_LIBADD = @LIBOBJS@ @ALLOCA@
libtinc_a_DEPENDENCIES = $(libvpn_a_LIBADD)
noinst_HEADERS = xalloc.h pidfile.h utils.h getopt.h list.h avl_tree.h \
- hooks.h dropin.h edge.h net.h conf.h netutl.h logging.h connection.h subnet.h node.h
+ hooks.h dropin.h edge.h net.h conf.h netutl.h logging.h connection.h subnet.h node.h graph.h
EXTRA_DIST = README
--- /dev/null
+/*
+ graph.c -- graph algorithms
+ Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.warande.net>,
+ 2001-2002 Ivo Timmermans <itimmermans@bigfoot.com>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ 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 2002/05/02 11:50:07 zarq Exp $
+*/
+
+/* We need to generate two trees from the graph:
+
+ 1. A minimum spanning tree for broadcasts,
+ 2. A single-source shortest path tree for unicasts.
+
+ Actually, the first one alone would suffice but would make unicast packets
+ take longer routes than necessary.
+
+ For the MST algorithm we can choose from Prim's or Kruskal's. I personally
+ favour Kruskal's, because we make an extra AVL tree of edges sorted on
+ weights (metric). That tree only has to be updated when an edge is added or
+ removed, and during the MST algorithm we just have go linearly through that
+ tree, adding safe edges until #edges = #nodes - 1. The implementation here
+ however is not so fast, because I tried to avoid having to make a forest and
+ merge trees.
+
+ For the SSSP algorithm Dijkstra's seems to be a nice choice. Currently a
+ simple breadth-first search is presented here.
+
+ The SSSP algorithm will also be used to determine whether nodes are directly,
+ indirectly or not reachable from the source. It will also set the correct
+ destination address and port of a node if possible.
+*/
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD)
+ #include <sys/param.h>
+#endif
+#include <netinet/in.h>
+
+#include <avl_tree.h>
+#include <hooks.h>
+#include <utils.h>
+
+#include "netutl.h"
+#include "node.h"
+#include "edge.h"
+#include "connection.h"
+#include "logging.h"
+
+#include "system.h"
+
+/* Implementation of Kruskal's algorithm.
+ Running time: O(EN)
+ Please note that sorting on weight is already done by add_edge().
+*/
+
+void mst_kruskal(void)
+{
+ avl_node_t *node, *next;
+ edge_t *e;
+ node_t *n;
+ connection_t *c;
+ int nodes = 0;
+ int safe_edges = 0;
+ int skipped;
+
+ /* Clear MST status on connections */
+
+ for(node = connection_tree->head; node; node = node->next)
+ {
+ c = (connection_t *)node->data;
+ c->status.mst = 0;
+ }
+
+ /* Do we have something to do at all? */
+
+ if(!edge_weight_tree->head)
+ return;
+
+ if(debug_lvl >= DEBUG_SCARY_THINGS)
+ syslog(LOG_DEBUG, "Running Kruskal's algorithm:");
+
+ /* Clear visited status on nodes */
+
+ for(node = node_tree->head; node; node = node->next)
+ {
+ n = (node_t *)node->data;
+ n->status.visited = 0;
+ nodes++;
+ }
+
+ /* Starting point */
+
+ ((edge_t *)edge_weight_tree->head->data)->from.node->status.visited = 1;
+
+ /* Add safe edges */
+
+ for(skipped = 0, node = edge_weight_tree->head; node; node = next)
+ {
+ next = node->next;
+ e = (edge_t *)node->data;
+
+ if(e->from.node->status.visited == e->to.node->status.visited)
+ {
+ skipped = 1;
+ continue;
+ }
+
+ e->from.node->status.visited = 1;
+ e->to.node->status.visited = 1;
+ if(e->connection)
+ e->connection->status.mst = 1;
+
+ safe_edges++;
+
+ if(debug_lvl >= DEBUG_SCARY_THINGS)
+ syslog(LOG_DEBUG, " Adding edge %s - %s weight %d", e->from.node->name, e->to.node->name, e->weight);
+
+ if(skipped)
+ {
+ next = edge_weight_tree->head;
+ continue;
+ }
+ }
+
+ if(debug_lvl >= DEBUG_SCARY_THINGS)
+ syslog(LOG_DEBUG, "Done, counted %d nodes and %d safe edges.", nodes, safe_edges);
+}
+
+/* Implementation of a simple breadth-first search algorithm.
+ Running time: O(E)
+*/
+
+void sssp_bfs(void)
+{
+ avl_node_t *node, *from, *next, *to;
+ edge_t *e;
+ node_t *n;
+ halfconnection_t to_hc, from_hc;
+ avl_tree_t *todo_tree;
+ int indirect;
+
+ todo_tree = avl_alloc_tree(NULL, NULL);
+
+ /* Clear visited status on nodes */
+
+ for(node = node_tree->head; node; node = node->next)
+ {
+ n = (node_t *)node->data;
+ n->status.visited = 0;
+ n->status.indirect = 1;
+ }
+
+ /* Begin with myself */
+
+ myself->status.visited = 1;
+ myself->status.indirect = 0;
+ myself->nexthop = myself;
+ myself->via = myself;
+ node = avl_alloc_node();
+ node->data = myself;
+ avl_insert_top(todo_tree, node);
+
+ /* Loop while todo_tree is filled */
+
+ while(todo_tree->head)
+ {
+ for(from = todo_tree->head; from; from = next) /* "from" is the node from which we start */
+ {
+ next = from->next;
+ n = (node_t *)from->data;
+
+ for(to = n->edge_tree->head; to; to = to->next) /* "to" is the edge connected to "from" */
+ {
+ e = (edge_t *)to->data;
+
+ if(e->from.node == n) /* "from_hc" is the halfconnection with .node == from */
+ to_hc = e->to, from_hc = e->from;
+ else
+ to_hc = e->from, from_hc = e->to;
+
+ /* Situation:
+
+ /
+ /
+ ------(n)from_hc-----to_hc
+ \
+ \
+
+ n->address is set to the to_hc.udpaddress of the edge left of n.
+ We are currently examining the edge right of n:
+
+ - If from_hc.udpaddress != n->address, then to_hc.node is probably
+ not reachable for the nodes left of n. We do as if the indirectdata
+ flag is set on edge e.
+ - If edge e provides for better reachability of to_hc.node, update
+ to_hc.node and (re)add it to the todo_tree to (re)examine the reachability
+ of nodes behind it.
+ */
+
+ indirect = n->status.indirect || e->options & OPTION_INDIRECT || ((n != myself) && sockaddrcmp(&n->address, &from_hc.udpaddress));
+
+ if(to_hc.node->status.visited && (!to_hc.node->status.indirect || indirect))
+ continue;
+
+ to_hc.node->status.visited = 1;
+ to_hc.node->status.indirect = indirect;
+ to_hc.node->nexthop = (n->nexthop == myself) ? to_hc.node : n->nexthop;
+ to_hc.node->via = indirect ? n->via : to_hc.node;
+ to_hc.node->options = e->options;
+ if(sockaddrcmp(&to_hc.node->address, &to_hc.udpaddress))
+ {
+ node = avl_unlink(node_udp_tree, to_hc.node);
+ to_hc.node->address = to_hc.udpaddress;
+ if(to_hc.node->hostname)
+ free(to_hc.node->hostname);
+ to_hc.node->hostname = sockaddr2hostname(&to_hc.udpaddress);
+ avl_insert_node(node_udp_tree, node);
+ }
+ node = avl_alloc_node();
+ node->data = to_hc.node;
+ avl_insert_before(todo_tree, from, node);
+ }
+
+ avl_delete_node(todo_tree, from);
+ }
+ }
+
+ avl_free_tree(todo_tree);
+
+ /* Check reachability status. */
+
+ for(node = node_tree->head; node; node = next)
+ {
+ next = node->next;
+ n = (node_t *)node->data;
+
+ if(n->status.visited)
+ {
+ if(!n->status.reachable)
+ {
+ if(debug_lvl >= DEBUG_TRAFFIC)
+ syslog(LOG_DEBUG, _("Node %s (%s) became reachable"), n->name, n->hostname);
+ n->status.reachable = 1;
+ run_hooks("node-visible", n);
+ }
+ }
+ else
+ {
+ if(n->status.reachable)
+ {
+ if(debug_lvl >= DEBUG_TRAFFIC)
+ syslog(LOG_DEBUG, _("Node %s (%s) became unreachable"), n->name, n->hostname);
+ n->status.reachable = 0;
+ n->status.validkey = 0;
+ n->status.waitingforkey = 0;
+ n->sent_seqno = 0;
+ run_hooks("node-invisible", n);
+ }
+ }
+ }
+}
+
+void graph(void)
+{
+ mst_kruskal();
+ sssp_bfs();
+}
--- /dev/null
+/*
+ graph.h -- header for graph.c
+ Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.warande.net>,
+ 2001-2002 Ivo Timmermans <itimmermans@bigfoot.com>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ 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 2002/05/02 11:50:07 zarq Exp $
+*/
+
+extern void graph(void);
+extern void mst_kruskal(void);
+extern void sssp_bfs(void);
--- /dev/null
+/*
+ hooks.c -- hooks management
+ Copyright (C) 2002 Guus Sliepen <guus@sliepen.warande.net>,
+ 2002 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ $Id: hooks.c,v 1.2 2002/05/02 11:50:07 zarq Exp $
+*/
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <avl_tree.h>
+#include <hooks.h>
+#include <xalloc.h>
+
+avl_tree_t *hooks_tree = NULL;
+
+struct hooks_node {
+ const char *type;
+ avl_tree_t *hooks;
+} hooks_node;
+
+static int hook_type_compare(const void *a, const void *b)
+{
+ return strcmp(((const struct hooks_node*)a)->type,
+ ((const struct hooks_node*)b)->type);
+}
+
+static int hook_dummy_compare(const void *a, const void *b)
+{
+ if(a < b)
+ return -1;
+ if(a > b)
+ return 1;
+ return 0;
+}
+
+void run_hooks(const char *type, ...)
+{
+ avl_node_t *avlnode;
+ va_list args;
+ struct hooks_node *hn;
+ struct hooks_node target;
+
+ if(!hooks_tree)
+ return;
+
+ target.type = type;
+ hn = (struct hooks_node*)avl_search(hooks_tree, &target);
+ if(!hn || !(hn->hooks->head))
+ {
+ fprintf(stderr, "Warning, no hooks found for `%s'\n", type);
+ return;
+ }
+
+ va_start(args, type);
+ for(avlnode = hn->hooks->head; avlnode; avlnode = avlnode->next)
+ {
+ assert(avlnode->data);
+ ((hook_function_t*)(avlnode->data))(type, args);
+ }
+ va_end(args);
+}
+
+void add_hook(const char *type, hook_function_t *hook)
+{
+ struct hooks_node *hn;
+ struct hooks_node target;
+
+ if(!hooks_tree)
+ hooks_tree = avl_alloc_tree(hook_type_compare, NULL);
+
+ target.type = type;
+ hn = avl_search(hooks_tree, &target);
+ if(!hn)
+ {
+ avl_tree_t *t;
+
+ hn = xmalloc(sizeof(struct hooks_node));
+ t = avl_alloc_tree(hook_dummy_compare, NULL);
+ hn->type = type;
+ hn->hooks = t;
+ avl_insert(hooks_tree, (void*)hn);
+ }
+
+ avl_insert(hn->hooks, (void*)hook);
+}
+
+void del_hook(const char *type, hook_function_t *hook)
+{
+ avl_tree_t *t;
+ struct hooks_node target;
+
+ if(!hooks_tree)
+ return;
+
+ target.type = type;
+ t = avl_search(hooks_tree, &target);
+ if(!t)
+ return;
+
+ avl_delete(t, (void*)hook);
+}
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 2002/04/28 12:46:26 zarq Exp $
+ $Id: node.h,v 1.2 2002/05/02 11:50:07 zarq Exp $
*/
#ifndef __TINC_NODE_H__
#define __TINC_NODE_H__
+#ifdef USE_GCRYPT
#include <gcrypt.h>
+#endif
#include <avl_tree.h>
## Produce this file with automake to get Makefile.in
-# $Id: Makefile.am,v 1.10 2002/04/28 12:46:26 zarq Exp $
+# $Id: Makefile.am,v 1.11 2002/05/02 11:50:07 zarq Exp $
SUBDIRS = pokey
EXTRA_DIST = linux/device.c freebsd/device.c openbsd/device.c solaris/device.c
-tincd_SOURCES = read_conf.c device.c event.c graph.c meta.c net_packet.c net_setup.c \
+tincd_SOURCES = read_conf.c device.c event.c meta.c net_packet.c net_setup.c \
net_socket.c process.c protocol.c protocol_auth.c protocol_edge.c protocol_misc.c \
- protocol_key.c protocol_subnet.c route.c tincd.c net.c
+ protocol_key.c protocol_subnet.c route.c tincd.c net.c callbacks.c
INCLUDES = @INCLUDES@ -I$(top_builddir) -I$(top_srcdir)/lib -I$(top_srcdir)/intl
-noinst_HEADERS = read_conf.h device.h event.h graph.h meta.h process.h \
- protocol.h route.h
+noinst_HEADERS = read_conf.h device.h event.h meta.h process.h \
+ protocol.h route.h callbacks.h
LIBS = @LIBS@ @INTLLIBS@
+++ /dev/null
-/*
- graph.c -- graph algorithms
- Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.warande.net>,
- 2001-2002 Ivo Timmermans <itimmermans@bigfoot.com>
-
- 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- 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.4 2002/04/28 12:46:26 zarq Exp $
-*/
-
-/* We need to generate two trees from the graph:
-
- 1. A minimum spanning tree for broadcasts,
- 2. A single-source shortest path tree for unicasts.
-
- Actually, the first one alone would suffice but would make unicast packets
- take longer routes than necessary.
-
- For the MST algorithm we can choose from Prim's or Kruskal's. I personally
- favour Kruskal's, because we make an extra AVL tree of edges sorted on
- weights (metric). That tree only has to be updated when an edge is added or
- removed, and during the MST algorithm we just have go linearly through that
- tree, adding safe edges until #edges = #nodes - 1. The implementation here
- however is not so fast, because I tried to avoid having to make a forest and
- merge trees.
-
- For the SSSP algorithm Dijkstra's seems to be a nice choice. Currently a
- simple breadth-first search is presented here.
-
- The SSSP algorithm will also be used to determine whether nodes are directly,
- indirectly or not reachable from the source. It will also set the correct
- destination address and port of a node if possible.
-*/
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD)
- #include <sys/param.h>
-#endif
-#include <netinet/in.h>
-
-#include <avl_tree.h>
-#include <utils.h>
-
-#include "netutl.h"
-#include "node.h"
-#include "edge.h"
-#include "connection.h"
-#include "process.h"
-#include "logging.h"
-
-#include "system.h"
-
-/* Implementation of Kruskal's algorithm.
- Running time: O(EN)
- Please note that sorting on weight is already done by add_edge().
-*/
-
-void mst_kruskal(void)
-{
- avl_node_t *node, *next;
- edge_t *e;
- node_t *n;
- connection_t *c;
- int nodes = 0;
- int safe_edges = 0;
- int skipped;
-
- /* Clear MST status on connections */
-
- for(node = connection_tree->head; node; node = node->next)
- {
- c = (connection_t *)node->data;
- c->status.mst = 0;
- }
-
- /* Do we have something to do at all? */
-
- if(!edge_weight_tree->head)
- return;
-
- if(debug_lvl >= DEBUG_SCARY_THINGS)
- syslog(LOG_DEBUG, "Running Kruskal's algorithm:");
-
- /* Clear visited status on nodes */
-
- for(node = node_tree->head; node; node = node->next)
- {
- n = (node_t *)node->data;
- n->status.visited = 0;
- nodes++;
- }
-
- /* Starting point */
-
- ((edge_t *)edge_weight_tree->head->data)->from.node->status.visited = 1;
-
- /* Add safe edges */
-
- for(skipped = 0, node = edge_weight_tree->head; node; node = next)
- {
- next = node->next;
- e = (edge_t *)node->data;
-
- if(e->from.node->status.visited == e->to.node->status.visited)
- {
- skipped = 1;
- continue;
- }
-
- e->from.node->status.visited = 1;
- e->to.node->status.visited = 1;
- if(e->connection)
- e->connection->status.mst = 1;
-
- safe_edges++;
-
- if(debug_lvl >= DEBUG_SCARY_THINGS)
- syslog(LOG_DEBUG, " Adding edge %s - %s weight %d", e->from.node->name, e->to.node->name, e->weight);
-
- if(skipped)
- {
- next = edge_weight_tree->head;
- continue;
- }
- }
-
- if(debug_lvl >= DEBUG_SCARY_THINGS)
- syslog(LOG_DEBUG, "Done, counted %d nodes and %d safe edges.", nodes, safe_edges);
-}
-
-/* Implementation of a simple breadth-first search algorithm.
- Running time: O(E)
-*/
-
-void sssp_bfs(void)
-{
- avl_node_t *node, *from, *next, *to;
- edge_t *e;
- node_t *n;
- halfconnection_t to_hc, from_hc;
- avl_tree_t *todo_tree;
- int indirect;
- char *name;
-
- todo_tree = avl_alloc_tree(NULL, NULL);
-
- /* Clear visited status on nodes */
-
- for(node = node_tree->head; node; node = node->next)
- {
- n = (node_t *)node->data;
- n->status.visited = 0;
- n->status.indirect = 1;
- }
-
- /* Begin with myself */
-
- myself->status.visited = 1;
- myself->status.indirect = 0;
- myself->nexthop = myself;
- myself->via = myself;
- node = avl_alloc_node();
- node->data = myself;
- avl_insert_top(todo_tree, node);
-
- /* Loop while todo_tree is filled */
-
- while(todo_tree->head)
- {
- for(from = todo_tree->head; from; from = next) /* "from" is the node from which we start */
- {
- next = from->next;
- n = (node_t *)from->data;
-
- for(to = n->edge_tree->head; to; to = to->next) /* "to" is the edge connected to "from" */
- {
- e = (edge_t *)to->data;
-
- if(e->from.node == n) /* "from_hc" is the halfconnection with .node == from */
- to_hc = e->to, from_hc = e->from;
- else
- to_hc = e->from, from_hc = e->to;
-
- /* Situation:
-
- /
- /
- ------(n)from_hc-----to_hc
- \
- \
-
- n->address is set to the to_hc.udpaddress of the edge left of n.
- We are currently examining the edge right of n:
-
- - If from_hc.udpaddress != n->address, then to_hc.node is probably
- not reachable for the nodes left of n. We do as if the indirectdata
- flag is set on edge e.
- - If edge e provides for better reachability of to_hc.node, update
- to_hc.node and (re)add it to the todo_tree to (re)examine the reachability
- of nodes behind it.
- */
-
- indirect = n->status.indirect || e->options & OPTION_INDIRECT || ((n != myself) && sockaddrcmp(&n->address, &from_hc.udpaddress));
-
- if(to_hc.node->status.visited && (!to_hc.node->status.indirect || indirect))
- continue;
-
- to_hc.node->status.visited = 1;
- to_hc.node->status.indirect = indirect;
- to_hc.node->nexthop = (n->nexthop == myself) ? to_hc.node : n->nexthop;
- to_hc.node->via = indirect ? n->via : to_hc.node;
- to_hc.node->options = e->options;
- if(sockaddrcmp(&to_hc.node->address, &to_hc.udpaddress))
- {
- node = avl_unlink(node_udp_tree, to_hc.node);
- to_hc.node->address = to_hc.udpaddress;
- if(to_hc.node->hostname)
- free(to_hc.node->hostname);
- to_hc.node->hostname = sockaddr2hostname(&to_hc.udpaddress);
- avl_insert_node(node_udp_tree, node);
- }
- node = avl_alloc_node();
- node->data = to_hc.node;
- avl_insert_before(todo_tree, from, node);
- }
-
- avl_delete_node(todo_tree, from);
- }
- }
-
- avl_free_tree(todo_tree);
-
- /* Check reachability status. */
-
- for(node = node_tree->head; node; node = next)
- {
- next = node->next;
- n = (node_t *)node->data;
-
- if(n->status.visited)
- {
- if(!n->status.reachable)
- {
- if(debug_lvl >= DEBUG_TRAFFIC)
- syslog(LOG_DEBUG, _("Node %s (%s) became reachable"), n->name, n->hostname);
- n->status.reachable = 1;
- asprintf(&name, "hosts/%s-up", n->name);
- execute_script(name);
- free(name);
- }
- }
- else
- {
- if(n->status.reachable)
- {
- if(debug_lvl >= DEBUG_TRAFFIC)
- syslog(LOG_DEBUG, _("Node %s (%s) became unreachable"), n->name, n->hostname);
- n->status.reachable = 0;
- n->status.validkey = 0;
- n->status.waitingforkey = 0;
- n->sent_seqno = 0;
- asprintf(&name, "hosts/%s-down", n->name);
- execute_script(name);
- free(name);
- }
- }
- }
-}
-
-void graph(void)
-{
- mst_kruskal();
- sssp_bfs();
-}
+++ /dev/null
-/*
- graph.h -- header for graph.c
- Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.warande.net>,
- 2001-2002 Ivo Timmermans <itimmermans@bigfoot.com>
-
- 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- 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.2 2002/04/09 15:26:00 zarq Exp $
-*/
-
-extern void graph(void);
-extern void mst_kruskal(void);
-extern void sssp_bfs(void);
## Produce this file with automake to get Makefile.in
-# $Id: Makefile.am,v 1.2 2002/04/28 12:46:26 zarq Exp $
+# $Id: Makefile.am,v 1.3 2002/05/02 11:50:07 zarq Exp $
sbin_PROGRAMS = pokey
pokey_SOURCES = event.c graph.c \
- interface.c logging.c meta.c net.c net_packet.c net_setup.c net_socket.c netutl.c \
+ interface.c meta.c net.c net_packet.c net_setup.c net_socket.c netutl.c \
process.c protocol.c protocol_auth.c protocol_edge.c \
protocol_misc.c protocol_key.c protocol_subnet.c route.c \
- pokey.c
+ pokey.c read_conf.c
INCLUDES = @INCLUDES@ -I$(top_builddir) -I$(top_srcdir)/lib -I$(top_srcdir)/intl -I$(top_srcdir)/src -I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include -I/usr/include/libglade-1.0 -I/usr/include/gnome-1.0 -I/usr/include/gnome-xml -I/usr/include/libglade-1.0 -I/usr/include/gnome-1.0 -DNEED_GNOMESUPPORT_H -I/usr/lib/gnome-libs/include -I/usr/include/glib-1.2 -I/usr/lib/glib/include -I/usr/include/orbit-1.0 -I/usr/include/gtk-1.2 -I/usr/X11R6/include
noinst_HEADERS = device.h event.h graph.h meta.h net.h netutl.h process.h \
- protocol.h route.h
+ protocol.h route.h read_conf.h
LIBS = @LIBS@ @INTLLIBS@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: interface.c,v 1.4 2002/04/28 12:46:26 zarq Exp $
+ $Id: interface.c,v 1.5 2002/05/02 11:50:07 zarq Exp $
*/
#include "config.h"
#include "system.h"
-extern GladeXML *xml;
+/* Node tree & main window stuff */
+static GladeXML *xml;
+static GtkWidget *nodetree;
+static GtkCTreeNode *hosts_ctn;
-#ifdef MAXBUFSIZE
-#undef MAXBUFSIZE
-#endif
-#define MAXBUFSIZE 1024
+/* Graph canvas stuff */
+static GladeXML *canvas_xml;
+
+static GnomeCanvasGroup *edge_group = NULL;
+
+static int canvas_width;
+static int canvas_height;
+
+static GtkWidget *canvas = NULL;
+
+static int canvas_visible = 0;
int build_graph = 0;
double k[MAX_NODES][MAX_NODES];
double d[MAX_NODES][MAX_NODES];
double l[MAX_NODES][MAX_NODES];
-const double epsilon = 0.001;
+static const double epsilon = 0.001;
static int inited = 0;
static int number_of_nodes = 0;
-static GtkWidget *nodetree;
-static GtkCTreeNode *hosts_ctn;
+static double canvas_zoom = 1.00;
-static GnomeCanvasGroup *edge_group = NULL;
-static int canvas_width;
-static int canvas_height;
+/* Log window stuff */
+#ifdef MAXBUFSIZE
+#undef MAXBUFSIZE
+#endif
-static GtkWidget *canvas = NULL;
+#define MAXBUFSIZE 1024
static int log_inited = 0;
static int follow_log = 1;
static int keep_drawing = 1;
-static GtkCList *connlist = NULL;
+static int log_visible = 0;
+static GtkWidget *log_window = NULL;
-static double canvas_zoom = 1.00;
void if_node_add(const char *hooktype, va_list ap);
void if_node_del(const char *hooktype, va_list ap);
void if_node_visible(const char *hooktype, va_list ap);
void if_node_invisible(const char *hooktype, va_list ap);
+void if_node_create(node_t *n);
+
GtkWidget *create_canvas(void)
{
+ canvas_xml = glade_xml_new(INTERFACE_FILE, "GraphWindow");
+ if(!canvas_xml)
+ {
+ log(0, TLOG_ERROR,
+ _("Could not find widget `%s'"),
+ "GraphWindow");
+ return NULL;
+ }
+
canvas = glade_xml_get_widget(xml, "canvas1");
if(!canvas)
{
return NULL;
}
- gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas), -00.0, -00.0, 700, 500);
+ gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas), 0.0, 0.0, 700, 500);
canvas_width = 300.0;
canvas_height = 500.0;
{
char buffer1[MAXBUFSIZE];
char buffer2[MAXBUFSIZE];
- GtkWidget *w;
int len;
char *p;
struct tm *tm;
time_t t;
- if(!xml)
- return;
-
- w = glade_xml_get_widget(xml, "Messages");
- if(!w)
+ if(!log_visible)
return;
/* Use vsnprintf instead of vasprintf: faster, no memory
}
}
- gtk_text_freeze(GTK_TEXT(w));
+ gtk_text_freeze(GTK_TEXT(log_window));
if(log_inited)
- gtk_text_insert(GTK_TEXT(w), NULL, NULL, NULL, "\n", 1);
+ gtk_text_insert(GTK_TEXT(log_window), NULL, NULL, NULL, "\n", 1);
- gtk_text_insert(GTK_TEXT(w), NULL, &timecolor, NULL, buffer2, strlen(buffer2));
- gtk_text_insert(GTK_TEXT(w), NULL, NULL, NULL, buffer1, len);
- gtk_text_thaw(GTK_TEXT(w));
+ gtk_text_insert(GTK_TEXT(log_window), NULL, &timecolor, NULL, buffer2, strlen(buffer2));
+ gtk_text_insert(GTK_TEXT(log_window), NULL, NULL, NULL, buffer1, len);
+ gtk_text_thaw(GTK_TEXT(log_window));
log_inited = 1;
if(follow_log)
/* gtk_text_set_point(GTK_TEXT(w), -1); */
- gtk_editable_set_position(GTK_EDITABLE(w), gtk_text_get_length(GTK_TEXT(w)));
+ gtk_editable_set_position(GTK_EDITABLE(log_window), gtk_text_get_length(GTK_TEXT(log_window)));
}
void if_hostinfoclosebutton_clicked(GtkWidget *w, gpointer data)
}
}
-void on_settings1_activate(GtkMenuItem *mi, gpointer data)
+void on_preferences1_activate(GtkMenuItem *mi, gpointer data)
{
GtkWidget *w;
GladeXML *x;
void on_logcontext_clear_activate(GtkMenuItem *mi, gpointer data)
{
- GtkWidget *l = glade_xml_get_widget(xml, "Messages");
- if(!l) { log(0, TLOG_ERROR, _("Couldn't find widget `%s'"), "Messages"); return; }
- gtk_editable_delete_text(GTK_EDITABLE(l), 0, -1); /* Delete from 0 to end of buffer */
+ gtk_editable_delete_text(GTK_EDITABLE(log_window), 0, -1); /* Delete from 0 to end of buffer */
log_inited = 0;
}
follow_log = !follow_log;
}
+void on_logcontext_close1_activate(GtkMenuItem *mi, gpointer data)
+{
+
+}
+
void on_messages_button_press_event(GtkWidget *w, GdkEventButton *event, gpointer data)
{
GladeXML *x;
}
}
-void on_canvascontext_shuffle_activate(GtkMenuItem *mi, gpointer data)
+void shuffle_nodes(void)
{
avl_node_t *avlnode;
double newx, newy;
build_graph = 1;
}
+void on_canvascontext_shuffle_activate(GtkMenuItem *mi, gpointer data)
+{
+ shuffle_nodes();
+}
+
void on_canvascontext_keep_drawing_activate(GtkMenuItem *mi, gpointer data)
{
+ GtkWidget *w;
+
keep_drawing = !keep_drawing;
+
+ /* No need to fuss with the checkbox in the menu, because that is
+ transient. Do need to update the checkbox at the bottom of the
+ window though. */
+ w = glade_xml_get_widget(canvas_xml, "KeepDrawingButton");
+ if(!w) { log(0, TLOG_ERROR, _("Couldn't find widget `%s'"), "KeepDrawingButton"); return; }
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), keep_drawing);
}
void on_canvascontext_minus50_activate(GtkMenuItem *mi, gpointer data)
gtk_exit(0);
}
-void on_info1_activate(GtkMenuItem *mi, gpointer data)
+void on_about1_activate(GtkMenuItem *mi, gpointer data)
{
GladeXML *x;
x = glade_xml_new(INTERFACE_FILE, "AboutWindow");
"AboutWindow");
return;
}
+ glade_xml_signal_autoconnect(x);
+}
+
+void on_graph_window1_activate(GtkMenuItem *mi, gpointer data)
+{
+ int i;
+ avl_node_t *avlnode;
+ double newx, newy;
+
+ canvas_xml = glade_xml_new(INTERFACE_FILE, "GraphWindow");
+ if(canvas_xml == NULL)
+ {
+ log(0, TLOG_ERROR,
+ _("Could not find widget `%s'"),
+ "GraphWindow");
+ return;
+ }
+ glade_xml_signal_autoconnect(canvas_xml);
+ canvas = glade_xml_get_widget(canvas_xml, "canvas1");
+ if(canvas == NULL) { log(0, TLOG_ERROR, _("Could not find widget `%s'"), "canvas1"); return; }
+
+ for(i = 0, avlnode = node_tree->head; avlnode; avlnode = avlnode->next)
+ {
+ node_t *n = (node_t*)(avlnode->data);
+
+ if(!((struct if_node_data*)(n->data))->item)
+ if_node_create(n);
+
+ if(!n->status.reachable)
+ continue;
+
+ newx = 250.0 + 200.0 * sin(i / 10.0 * M_PI);
+ newy = 150.0 - 100.0 * cos(i / 10.0 * M_PI);
+ gnome_canvas_item_move(GNOME_CANVAS_ITEM(((struct if_node_data*)(n->data))->item), newx - ((struct if_node_data*)(n->data))->x, newy - ((struct if_node_data*)(n->data))->y);
+ ((struct if_node_data*)(n->data))->x = newx;
+ ((struct if_node_data*)(n->data))->y = newy;
+
+ ((struct if_node_data*)(n->data))->id = i;
+
+ gnome_canvas_item_show(GNOME_CANVAS_ITEM(((struct if_node_data*)(n->data))->item));
+ gnome_canvas_update_now(GNOME_CANVAS(canvas));
+ nodes[i] = n;
+ i++;
+ }
+
+ number_of_nodes = i;
+
+ inited = 0;
+ build_graph = 1;
+ canvas_visible = 1;
+}
+
+void on_log_window1_activate(GtkMenuItem *mi, gpointer data)
+{
+ GladeXML *x;
+ GtkWidget *w;
+
+ x = glade_xml_new(INTERFACE_FILE, "LogWindow");
+ if(x == NULL)
+ {
+ log(0, TLOG_ERROR,
+ _("Could not find widget `%s'"),
+ "LogWindow");
+ return;
+ }
+ log_window = glade_xml_get_widget(x, "Messages");
+ if(!log_window)
+ {
+ log(0, TLOG_ERROR,
+ _("Could not find widget `%s'"),
+ "Messages");
+ return;
+ }
+ w = glade_xml_get_widget(x, "DebugLevelSpinbutton");
+ if(!w)
+ {
+ log(0, TLOG_ERROR,
+ _("Could not find widget `%s'"),
+ "DebugLevelSpinbutton");
+ return;
+ }
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), (float)debug_lvl);
+
+ glade_xml_signal_autoconnect(x);
+ log_visible = 1;
+ log_add_hook(log_gtk);
+ log(0, TLOG_NOTICE, "Logging started.\n");
+
+}
+
+void on_debug_level_changed(GtkSpinButton *sb, gpointer data)
+{
+ debug_lvl = gtk_spin_button_get_value_as_int(sb);
+}
+
+void on_logwindow_close_clicked(GtkButton *b, gpointer data)
+{
+ GladeXML *x;
+ GtkWidget *w;
+
+ x = glade_xml_new(INTERFACE_FILE, "LogWindow");
+ if(x == NULL)
+ {
+ log(0, TLOG_ERROR,
+ _("Could not find widget `%s'"),
+ "LogWindow");
+ return;
+ }
+ w = glade_xml_get_widget(x, "LogWindow");
+ if(!w)
+ {
+ log(0, TLOG_ERROR,
+ _("Could not find widget `%s'"),
+ "LogWindow");
+ return;
+ }
+ gtk_widget_destroy(w);
+}
+
+void on_spinbutton2_changed(GtkSpinButton *sb, gpointer data)
+{
+ canvas_zoom = gtk_spin_button_get_value_as_float(sb) / 100.0;
+ gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(canvas), canvas_zoom);
+}
+
+void on_checkbutton1_toggled(GtkCheckButton *cb, gpointer data)
+{
+ keep_drawing = !keep_drawing;
+}
+
+void on_button19_clicked(GtkWidget *bt, GdkEventButton *ev, gpointer data)
+{
+ shuffle_nodes();
+}
+
+void on_button18_clicked(GtkWidget *bt, GdkEventButton *ev, gpointer data)
+{
+ GtkWidget *w;
+
+ w = glade_xml_get_widget(canvas_xml, "GraphWindow");
+ if(!w) { log(0, TLOG_ERROR, _("Couldn't find widget `%s'"), "GraphWindow"); return; }
+ gtk_object_destroy(GTK_OBJECT(w));
+ build_graph = 0;
+ canvas_visible = 0;
}
int init_interface(void)
FALSE, TRUE);
gtk_clist_thaw(GTK_CLIST(nodetree));
- create_canvas();
-
glade_xml_signal_autoconnect(xml);
- log_add_hook(log_gtk);
log_del_hook(log_default);
add_hook("node-add", if_node_add);
avl_node_t *avlnode;
double newx, newy;
node_t *n = va_arg(ap, node_t*);
+
+ if(!n->data)
+ return;
if(!((struct if_node_data*)(n->data))->item)
+ /* No GnomeCanvasItem has been created for this node yet */
return;
if(((struct if_node_data*)(n->data))->visible)
if(!xml)
return;
- nd = xmalloc(sizeof(*nd));
+ nd = xmalloc_and_zero(sizeof(*nd));
l[0] = n->name;
gtk_clist_freeze(GTK_CLIST(nodetree));
nd->ctn = gtk_ctree_insert_node(GTK_CTREE(nodetree),
n->data = (void*)nd;
- if_node_create(n);
- if_node_visible(hooktype, ap);
+ if(canvas_visible)
+ {
+ if_node_create(n);
+ if_node_visible(hooktype, ap);
+ }
}
void if_node_del(const char *hooktype, va_list ap)
gtk_clist_thaw(GTK_CLIST(nodetree));
}
- if_node_invisible(hooktype, ap);
+ if(canvas_visible)
+ {
+ if_node_invisible(hooktype, ap);
+ }
free(nd);
n->data = NULL;
struct if_subnet_data *sd;
GtkCTreeNode *parent;
- sd = xmalloc(sizeof(*sd));
+ sd = xmalloc_and_zero(sizeof(*sd));
l[0] = net2str(subnet);
parent = subnet->owner->data ?
((struct if_subnet_data*)(subnet->owner->data))->ctn
}
}
- min_d = 0.0;
+ min_d = INFINITY;
for(i = 0; i < number_of_nodes; i++)
for(j = i + 1; j < number_of_nodes; j++)
- if(d[i][j] < min_d && d[i][j] > 0)
+ if(d[i][j] < min_d && d[i][j] > 0.0)
min_d = d[i][j];
L = 5.0 / sqrt(min_d + 1.0);
<class>GtkScrolledWindow</class>
<child_name>GnomeDock:contents</child_name>
<name>scrolledwindow1</name>
- <width>250</width>
+ <width>300</width>
+ <height>200</height>
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<auto_shrink>False</auto_shrink>
<widget>
- <class>GtkScrolledWindow</class>
- <name>scrolledwindow2</name>
- <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
- <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
- <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
- <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
+ <class>GtkVBox</class>
+ <name>vbox7</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
<widget>
- <class>GtkText</class>
- <name>Messages</name>
- <width>500</width>
- <height>300</height>
- <signal>
- <name>button_press_event</name>
- <handler>on_messages_button_press_event</handler>
- <last_modification_time>Sun, 14 Apr 2002 19:34:28 GMT</last_modification_time>
- </signal>
- <editable>False</editable>
- <text></text>
+ <class>GtkScrolledWindow</class>
+ <name>scrolledwindow2</name>
+ <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
+ <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
+ <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
+ <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkText</class>
+ <name>Messages</name>
+ <width>500</width>
+ <height>300</height>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_messages_button_press_event</handler>
+ <last_modification_time>Sun, 14 Apr 2002 19:34:28 GMT</last_modification_time>
+ </signal>
+ <editable>False</editable>
+ <text></text>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox4</name>
+ <homogeneous>False</homogeneous>
+ <spacing>10</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox5</name>
+ <homogeneous>False</homogeneous>
+ <spacing>9</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label32</name>
+ <label>Debug level</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkSpinButton</class>
+ <name>DebugLevelSpinbutton</name>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>changed</name>
+ <handler>on_debug_level_changed</handler>
+ <last_modification_time>Mon, 29 Apr 2002 21:31:08 GMT</last_modification_time>
+ </signal>
+ <climb_rate>1</climb_rate>
+ <digits>0</digits>
+ <numeric>True</numeric>
+ <update_policy>GTK_UPDATE_IF_VALID</update_policy>
+ <snap>False</snap>
+ <wrap>False</wrap>
+ <value>1</value>
+ <lower>0</lower>
+ <upper>1000</upper>
+ <step>1</step>
+ <page>10</page>
+ <page_size>10</page_size>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button17</name>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>clicked</name>
+ <handler>on_logwindow_close_clicked</handler>
+ <last_modification_time>Mon, 29 Apr 2002 21:37:37 GMT</last_modification_time>
+ </signal>
+ <stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
</widget>
</widget>
</widget>
<auto_shrink>False</auto_shrink>
<widget>
- <class>GtkScrolledWindow</class>
- <name>scrolledwindow3</name>
- <hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy>
- <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
- <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
- <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
+ <class>GtkVBox</class>
+ <name>vbox8</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
<widget>
- <class>GnomeCanvas</class>
- <name>canvas1</name>
- <width>500</width>
- <height>300</height>
- <can_focus>True</can_focus>
- <signal>
- <name>button_press_event</name>
- <handler>on_canvas_button_press_event</handler>
- <last_modification_time>Sun, 14 Apr 2002 15:21:11 GMT</last_modification_time>
- </signal>
- <anti_aliased>True</anti_aliased>
- <scroll_x1>0</scroll_x1>
- <scroll_y1>0</scroll_y1>
- <scroll_x2>100</scroll_x2>
- <scroll_y2>100</scroll_y2>
- <pixels_per_unit>1</pixels_per_unit>
+ <class>GtkScrolledWindow</class>
+ <name>scrolledwindow3</name>
+ <hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy>
+ <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
+ <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
+ <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GnomeCanvas</class>
+ <name>canvas1</name>
+ <width>500</width>
+ <height>300</height>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_canvas_button_press_event</handler>
+ <last_modification_time>Sun, 14 Apr 2002 15:21:11 GMT</last_modification_time>
+ </signal>
+ <anti_aliased>True</anti_aliased>
+ <scroll_x1>0</scroll_x1>
+ <scroll_y1>0</scroll_y1>
+ <scroll_x2>100</scroll_x2>
+ <scroll_y2>100</scroll_y2>
+ <pixels_per_unit>1</pixels_per_unit>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox6</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox7</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label33</name>
+ <label>Zoom</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkSpinButton</class>
+ <name>spinbutton2</name>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>changed</name>
+ <handler>on_spinbutton2_changed</handler>
+ <last_modification_time>Wed, 01 May 2002 17:18:44 GMT</last_modification_time>
+ </signal>
+ <climb_rate>1</climb_rate>
+ <digits>0</digits>
+ <numeric>True</numeric>
+ <update_policy>GTK_UPDATE_IF_VALID</update_policy>
+ <snap>False</snap>
+ <wrap>False</wrap>
+ <value>100</value>
+ <lower>1</lower>
+ <upper>1000</upper>
+ <step>1</step>
+ <page>10</page>
+ <page_size>10</page_size>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkCheckButton</class>
+ <name>KeepDrawingButton</name>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>toggled</name>
+ <handler>on_checkbutton1_toggled</handler>
+ <last_modification_time>Wed, 01 May 2002 17:18:37 GMT</last_modification_time>
+ </signal>
+ <label>Keep drawing</label>
+ <active>False</active>
+ <draw_indicator>True</draw_indicator>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button18</name>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>clicked</name>
+ <handler>on_button18_clicked</handler>
+ <last_modification_time>Wed, 01 May 2002 17:18:25 GMT</last_modification_time>
+ </signal>
+ <stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ <pack>GTK_PACK_END</pack>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button19</name>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>clicked</name>
+ <handler>on_button19_clicked</handler>
+ <last_modification_time>Wed, 01 May 2002 17:18:19 GMT</last_modification_time>
+ </signal>
+ <label>Shuffle</label>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ <pack>GTK_PACK_END</pack>
+ </child>
+ </widget>
</widget>
</widget>
</widget>
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.1 2002/04/28 12:46:26 zarq Exp $
+ $Id: protocol.c,v 1.2 2002/05/02 11:50:07 zarq Exp $
*/
#include "config.h"
id_h, metakey_h, challenge_h, chal_reply_h, ack_h,
status_h, error_h, termreq_h,
ping_h, pong_h,
-// add_node_h, del_node_h,
+ /* add_node_h, del_node_h,*/
add_subnet_h, del_subnet_h,
add_edge_h, del_edge_h,
key_changed_h, req_key_h, ans_key_h,
"ID", "METAKEY", "CHALLENGE", "CHAL_REPLY", "ACK",
"STATUS", "ERROR", "TERMREQ",
"PING", "PONG",
-// "ADD_NODE", "DEL_NODE",
+ /* "ADD_NODE", "DEL_NODE",*/
"ADD_SUBNET", "DEL_SUBNET",
"ADD_EDGE", "DEL_EDGE",
"KEY_CHANGED", "REQ_KEY", "ANS_KEY",
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol.h,v 1.1 2002/04/28 12:46:26 zarq Exp $
+ $Id: protocol.h,v 1.2 2002/05/02 11:50:07 zarq Exp $
*/
#ifndef __TINC_PROTOCOL_H__
ID = 0, METAKEY, CHALLENGE, CHAL_REPLY, ACK,
STATUS, ERROR, TERMREQ,
PING, PONG,
-// ADD_NODE, DEL_NODE,
+ /* ADD_NODE, DEL_NODE,*/
ADD_SUBNET, DEL_SUBNET,
ADD_EDGE, DEL_EDGE,
KEY_CHANGED, REQ_KEY, ANS_KEY,
extern int send_termreq(connection_t *);
extern int send_ping(connection_t *);
extern int send_pong(connection_t *);
-// extern int send_add_node(connection_t *, node_t *);
-// extern int send_del_node(connection_t *, node_t *);
+/* extern int send_add_node(connection_t *, node_t *); */
+/* extern int send_del_node(connection_t *, node_t *); */
extern int send_add_subnet(connection_t *, subnet_t *);
extern int send_del_subnet(connection_t *, subnet_t *);
extern int send_add_edge(connection_t *, edge_t *);
extern int termreq_h(connection_t *);
extern int ping_h(connection_t *);
extern int pong_h(connection_t *);
-// extern int add_node_h(connection_t *);
-// extern int del_node_h(connection_t *);
+/* extern int add_node_h(connection_t *); */
+/* extern int del_node_h(connection_t *); */
extern int add_subnet_h(connection_t *);
extern int del_subnet_h(connection_t *);
extern int add_edge_h(connection_t *);
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 2002/04/28 12:46:26 zarq Exp $
+ $Id: protocol_auth.c,v 1.2 2002/05/02 11:50:07 zarq Exp $
*/
#include "config.h"
c->edge = new_edge();
cp
c->edge->from.node = myself;
-// c->edge->from.tcpaddress = str2sockaddr(address, port);
+ /* c->edge->from.tcpaddress = str2sockaddr(address, port);*/
c->edge->from.udpaddress = str2sockaddr(myaddress, myport);
c->edge->to.node = n;
-// c->edge->to.tcpaddress = c->address;
+ /* c->edge->to.tcpaddress = c->address; */
sockaddr2str(&c->address, &hisaddress, &dummy);
c->edge->to.udpaddress = str2sockaddr(hisaddress, hisport);
free(hisaddress);
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 2002/04/28 12:46:26 zarq Exp $
+ $Id: protocol_edge.c,v 1.2 2002/05/02 11:50:07 zarq Exp $
*/
#include "config.h"
char *from_udpaddress, *from_udpport;
char *to_udpaddress, *to_udpport;
cp
-// sockaddr2str(&e->from.tcpaddress, &from_tcpaddress, &from_tcpport);
+ /* sockaddr2str(&e->from.tcpaddress, &from_tcpaddress, &from_tcpport); */
sockaddr2str(&e->from.udpaddress, &from_udpaddress, &from_udpport);
-// sockaddr2str(&e->to.tcpaddress, &to_tcpaddress, &to_tcpport);
+ /* sockaddr2str(&e->to.tcpaddress, &to_tcpaddress, &to_tcpport); */
sockaddr2str(&e->to.udpaddress, &to_udpaddress, &to_udpport);
x = send_request(c, "%d %lx %s %s %s %s %s %s %lx %d", ADD_EDGE, random(),
e->from.node->name, from_udpaddress, from_udpport,
e->to.node->name, to_udpaddress, to_udpport,
e->options, e->weight);
-// free(from_tcpaddress);
-// free(from_tcpport);
+ /* free(from_tcpaddress); */
+ /* free(from_tcpport); */
free(from_udpaddress);
free(from_udpport);
-// free(to_tcpaddress);
-// free(to_tcpport);
+ /* free(to_tcpaddress); */
+ /* free(to_tcpport); */
free(to_udpaddress);
free(to_udpport);
cp
char from_name[MAX_STRING_SIZE];
char to_name[MAX_STRING_SIZE];
char from_address[MAX_STRING_SIZE];
-// char from_tcpport[MAX_STRING_SIZE];
+ /* char from_tcpport[MAX_STRING_SIZE]; */
char from_udpport[MAX_STRING_SIZE];
char to_address[MAX_STRING_SIZE];
-// char to_tcpport[MAX_STRING_SIZE];
+ /* char to_tcpport[MAX_STRING_SIZE]; */
char to_udpport[MAX_STRING_SIZE];
sockaddr_t from_udpaddress;
sockaddr_t to_udpaddress;
/* Convert addresses */
-// from_tcpaddress = str2sockaddr(from_address, from_tcpport);
+ /* from_tcpaddress = str2sockaddr(from_address, from_tcpport); */
from_udpaddress = str2sockaddr(from_address, from_udpport);
-// to_tcpaddress = str2sockaddr(to_address, to_tcpport);
+ /* to_tcpaddress = str2sockaddr(to_address, to_tcpport); */
to_udpaddress = str2sockaddr(to_address, to_udpport);
/* Check if edge already exists */
e = new_edge();
e->from.node = from;
-// e->from.tcpaddress = from_tcpaddress;
+ /* e->from.tcpaddress = from_tcpaddress; */
e->from.udpaddress = from_udpaddress;
e->to.node = to;
-// e->to.tcpaddress = to_tcpaddress;
+ /* e->to.tcpaddress = to_tcpaddress; */
e->to.udpaddress = to_udpaddress;
e->options = options;
e->weight = weight;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: read_conf.h,v 1.1 2002/04/28 12:46:26 zarq Exp $
+ $Id: read_conf.h,v 1.2 2002/05/02 11:50:07 zarq Exp $
*/
#ifndef __TINC_READ_CONF_H__
#define __TINC_READ_CONF_H__
+#include <avl_tree.h>
+
extern int read_config_file(avl_tree_t *, const char *);
extern int read_server_config(void);
extern FILE *ask_and_safe_open(const char*, const char*, const char *);
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.15 2002/04/28 12:46:26 zarq Exp $
+ $Id: tincd.c,v 1.16 2002/05/02 11:50:07 zarq Exp $
*/
#include "config.h"
#include <utils.h>
#include <xalloc.h>
-#include "conf.h"
+#include "callbacks.h"
+#include "read_conf.h"
#include "net.h"
#include "netutl.h"
#include "process.h"
cp
if(detach())
exit(0);
+
+ init_callbacks();
cp
for(;;)
{