Another file moved; random interface stuff.
This commit is contained in:
parent
a77b35e748
commit
4c1a4e8a79
15 changed files with 679 additions and 135 deletions
|
@ -1,17 +1,17 @@
|
|||
## 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
|
||||
|
|
|
@ -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: graph.c,v 1.4 2002/04/28 12:46:26 zarq Exp $
|
||||
$Id: graph.c,v 1.1 2002/05/02 11:50:07 zarq Exp $
|
||||
*/
|
||||
|
||||
/* We need to generate two trees from the graph:
|
||||
|
@ -55,13 +55,13 @@
|
|||
#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 "process.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include "system.h"
|
||||
|
@ -156,7 +156,6 @@ void sssp_bfs(void)
|
|||
halfconnection_t to_hc, from_hc;
|
||||
avl_tree_t *todo_tree;
|
||||
int indirect;
|
||||
char *name;
|
||||
|
||||
todo_tree = avl_alloc_tree(NULL, NULL);
|
||||
|
||||
|
@ -260,9 +259,7 @@ void sssp_bfs(void)
|
|||
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);
|
||||
run_hooks("node-visible", n);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -275,9 +272,7 @@ void sssp_bfs(void)
|
|||
n->status.validkey = 0;
|
||||
n->status.waitingforkey = 0;
|
||||
n->sent_seqno = 0;
|
||||
asprintf(&name, "hosts/%s-down", n->name);
|
||||
execute_script(name);
|
||||
free(name);
|
||||
run_hooks("node-invisible", n);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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: graph.h,v 1.2 2002/04/09 15:26:00 zarq Exp $
|
||||
$Id: graph.h,v 1.1 2002/05/02 11:50:07 zarq Exp $
|
||||
*/
|
||||
|
||||
extern void graph(void);
|
120
lib/hooks.c
Normal file
120
lib/hooks.c
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
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);
|
||||
}
|
|
@ -17,13 +17,15 @@
|
|||
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>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
## 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
|
||||
|
||||
|
@ -7,14 +7,14 @@ sbin_PROGRAMS = tincd
|
|||
|
||||
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@
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
## 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@
|
||||
|
||||
|
|
|
@ -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: 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"
|
||||
|
@ -50,13 +50,23 @@
|
|||
|
||||
#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;
|
||||
|
||||
|
@ -77,30 +87,30 @@ double y[MAX_NODES];
|
|||
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);
|
||||
|
@ -111,8 +121,19 @@ void if_edge_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)
|
||||
{
|
||||
|
@ -120,7 +141,7 @@ GtkWidget *create_canvas(void)
|
|||
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;
|
||||
|
@ -132,17 +153,12 @@ void log_gtk(int level, int priority, char *fmt, va_list ap)
|
|||
{
|
||||
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
|
||||
|
@ -172,19 +188,19 @@ void log_gtk(int level, int priority, char *fmt, va_list ap)
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -272,7 +288,7 @@ void update_hostinfo_dialog(GladeXML *x, node_t *n)
|
|||
}
|
||||
}
|
||||
|
||||
void on_settings1_activate(GtkMenuItem *mi, gpointer data)
|
||||
void on_preferences1_activate(GtkMenuItem *mi, gpointer data)
|
||||
{
|
||||
GtkWidget *w;
|
||||
GladeXML *x;
|
||||
|
@ -293,9 +309,7 @@ void on_settings1_activate(GtkMenuItem *mi, gpointer data)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -304,6 +318,11 @@ void on_logcontext_follow_activate(GtkMenuItem *mi, gpointer data)
|
|||
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;
|
||||
|
@ -333,7 +352,7 @@ void on_messages_button_press_event(GtkWidget *w, GdkEventButton *event, gpointe
|
|||
}
|
||||
}
|
||||
|
||||
void on_canvascontext_shuffle_activate(GtkMenuItem *mi, gpointer data)
|
||||
void shuffle_nodes(void)
|
||||
{
|
||||
avl_node_t *avlnode;
|
||||
double newx, newy;
|
||||
|
@ -355,9 +374,23 @@ void on_canvascontext_shuffle_activate(GtkMenuItem *mi, gpointer data)
|
|||
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)
|
||||
|
@ -491,7 +524,7 @@ void on_exit1_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");
|
||||
|
@ -502,6 +535,150 @@ void on_info1_activate(GtkMenuItem *mi, gpointer data)
|
|||
"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)
|
||||
|
@ -536,11 +713,8 @@ 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);
|
||||
|
@ -660,8 +834,12 @@ void if_node_visible(const char *hooktype, va_list ap)
|
|||
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)
|
||||
|
@ -736,7 +914,7 @@ void if_node_add(const char *hooktype, va_list ap)
|
|||
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),
|
||||
|
@ -748,8 +926,11 @@ void if_node_add(const char *hooktype, va_list ap)
|
|||
|
||||
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)
|
||||
|
@ -765,7 +946,10 @@ 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;
|
||||
|
@ -778,7 +962,7 @@ void if_subnet_add(const char *hooktype, va_list ap)
|
|||
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
|
||||
|
@ -1045,10 +1229,10 @@ void if_build_graph(void)
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -1703,7 +1703,8 @@ Ivo Timmermans <ivo@o2w.nl>
|
|||
<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>
|
||||
|
@ -1766,25 +1767,124 @@ Ivo Timmermans <ivo@o2w.nl>
|
|||
<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>
|
||||
|
@ -1801,30 +1901,168 @@ Ivo Timmermans <ivo@o2w.nl>
|
|||
<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>
|
||||
|
|
|
@ -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: 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"
|
||||
|
@ -226,7 +226,7 @@ int (*request_handlers[])(connection_t*) = {
|
|||
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,
|
||||
|
@ -238,7 +238,7 @@ char (*request_name[]) = {
|
|||
"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",
|
||||
|
|
|
@ -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: 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__
|
||||
|
@ -40,7 +40,7 @@ enum {
|
|||
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,
|
||||
|
@ -81,8 +81,8 @@ extern int send_error(connection_t *, int, char *);
|
|||
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 *);
|
||||
|
@ -106,8 +106,8 @@ extern int error_h(connection_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 *);
|
||||
|
|
|
@ -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: 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"
|
||||
|
@ -564,10 +564,10 @@ cp
|
|||
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);
|
||||
|
|
|
@ -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: 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"
|
||||
|
@ -52,20 +52,20 @@ int send_add_edge(connection_t *c, edge_t *e)
|
|||
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
|
||||
|
@ -80,10 +80,10 @@ int add_edge_h(connection_t *c)
|
|||
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;
|
||||
|
@ -139,9 +139,9 @@ cp
|
|||
|
||||
/* 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 */
|
||||
|
@ -186,10 +186,10 @@ cp
|
|||
|
||||
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;
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
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 *);
|
||||
|
|
|
@ -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: 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"
|
||||
|
@ -51,7 +51,8 @@
|
|||
#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"
|
||||
|
@ -380,6 +381,8 @@ cp
|
|||
cp
|
||||
if(detach())
|
||||
exit(0);
|
||||
|
||||
init_callbacks();
|
||||
cp
|
||||
for(;;)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue