]> git.meshlink.io Git - meshlink/blobdiff - src/node.c
Merge branch 'master' into 1.1
[meshlink] / src / node.c
index 280a70cbb28252c77e8887f4e4e6085a5dcf540f..80d28d64112c8cc49e1ad3616b4fb06cb432c463 100644 (file)
@@ -1,6 +1,6 @@
 /*
     node.c -- node tree management
-    Copyright (C) 2001-2006 Guus Sliepen <guus@tinc-vpn.org>,
+    Copyright (C) 2001-2009 Guus Sliepen <guus@tinc-vpn.org>,
                   2001-2005 Ivo Timmermans
 
     This program is free software; you can redistribute it and/or modify
@@ -67,13 +67,12 @@ void exit_nodes(void) {
 }
 
 node_t *new_node(void) {
-       node_t *n = xmalloc_and_zero(sizeof(*n));
+       node_t *n = xmalloc_and_zero(sizeof *n);
 
        cp();
 
        n->subnet_tree = new_subnet_tree();
        n->edge_tree = new_edge_tree();
-       n->queue = list_alloc((list_action_t) free);
        n->mtu = MTU;
        n->maxmtu = MTU;
 
@@ -83,9 +82,6 @@ node_t *new_node(void) {
 void free_node(node_t *n) {
        cp();
 
-       if(n->queue)
-               list_delete_list(n->queue);
-
        if(n->subnet_tree)
                free_subnet_tree(n->subnet_tree);
 
@@ -157,22 +153,21 @@ node_t *lookup_node_udp(const sockaddr_t *sa) {
        return splay_search(node_udp_tree, &n);
 }
 
-void dump_nodes(void) {
+int dump_nodes(struct evbuffer *out) {
        splay_node_t *node;
        node_t *n;
 
        cp();
 
-       logger(LOG_DEBUG, _("Nodes:"));
-
        for(node = node_tree->head; node; node = node->next) {
                n = node->data;
-               logger(LOG_DEBUG, _(" %s at %s cipher %d digest %d maclength %d compression %d options %lx status %04x nexthop %s via %s pmtu %d (min %d max %d)"),
+               if(evbuffer_add_printf(out, _(" %s at %s cipher %d digest %d maclength %d compression %d options %lx status %04x nexthop %s via %s distance %d pmtu %d (min %d max %d)\n"),
                           n->name, n->hostname, cipher_get_nid(&n->cipher),
                           digest_get_nid(&n->digest), n->maclength, n->compression,
                           n->options, *(uint32_t *)&n->status, n->nexthop ? n->nexthop->name : "-",
-                          n->via ? n->via->name : "-", n->mtu, n->minmtu, n->maxmtu);
+                          n->via ? n->via->name : "-", n->distance, n->mtu, n->minmtu, n->maxmtu) == -1)
+                       return errno;
        }
 
-       logger(LOG_DEBUG, _("End of nodes."));
+       return 0;
 }