- Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.eu.org>,
- 2001-2002 Ivo Timmermans <ivo@o2w.nl>
+ Copyright (C) 2001-2004 Guus Sliepen <guus@tinc-vpn.org>,
+ 2001-2004 Ivo Timmermans <ivo@tinc-vpn.org>
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
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
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- logger(DEBUG_SCARY_THINGS, LOG_DEBUG, " Adding edge %s - %s weight %d", e->from->name,
+ ifdebug(SCARY_THINGS) logger(LOG_DEBUG, " Adding edge %s - %s weight %d", e->from->name,
- logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Done, counted %d nodes and %d safe edges.", nodes,
+ ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Done, counted %d nodes and %d safe edges.", nodes,
- 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(from = todo_list->head; from; from = todonext) { /* "from" is the node from which we start */
+ n = from->data;
- n->address is set to the e->address of the edge left of n to n.
- We are currently examining the edge e right of n from n:
+ Where e is an edge, (n) and (e->to) are nodes.
+ n->address is set to the e->address of the edge left of n to n.
+ We are currently examining the edge e right of n from n:
- - If e->reverse->address != n->address, then e->to 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 e->to, update
- e->to and (re)add it to the todo_tree to (re)examine the reachability
- of nodes behind it.
- */
+ - If e->reverse->address != n->address, then e->to 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 e->to, update
+ e->to and (re)add it to the todo_list to (re)examine the reachability
+ of nodes behind it.
+ */
- indirect = n->status.indirect || e->options & OPTION_INDIRECT
- || ((n != myself) && sockaddrcmp(&n->address, &e->reverse->address));
+ indirect = n->status.indirect || e->options & OPTION_INDIRECT
+ || ((n != myself) && sockaddrcmp(&n->address, &e->reverse->address));
- e->to->status.visited = 1;
- e->to->status.indirect = indirect;
- e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop;
- e->to->via = indirect ? n->via : e->to;
- e->to->options = e->options;
+ e->to->status.visited = true;
+ e->to->status.indirect = indirect;
+ e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop;
+ e->to->via = indirect ? n->via : e->to;
+ e->to->options = e->options;
- if(sockaddrcmp(&e->to->address, &e->address)) {
- node = avl_unlink(node_udp_tree, e->to);
- e->to->address = e->address;
+ if(sockaddrcmp(&e->to->address, &e->address)) {
+ node = avl_unlink(node_udp_tree, e->to);
+ sockaddrfree(&e->to->address);
+ sockaddrcpy(&e->to->address, &e->address);
- node = avl_alloc_node();
- node->data = e->to;
- avl_insert_before(todo_tree, from, node);
+ if(e->to->options & OPTION_PMTU_DISCOVERY) {
+ e->to->mtuprobes = 0;
+ e->to->minmtu = 0;
+ e->to->maxmtu = MTU;
+ if(e->to->status.validkey)
+ send_mtu_probe(e->to);
+ }
- if(n->status.reachable)
- logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Node %s (%s) became reachable"),
+ if(n->status.reachable) {
+ ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became reachable"),
- else
- logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Node %s (%s) became unreachable"),
+ avl_insert(node_udp_tree, n);
+ } else {
+ ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became unreachable"),
asprintf(&envp[0], "NETNAME=%s", netname ? : "");
asprintf(&envp[1], "DEVICE=%s", device ? : "");
asprintf(&envp[0], "NETNAME=%s", netname ? : "");
asprintf(&envp[1], "DEVICE=%s", device ? : "");
asprintf(&envp[3], "NODE=%s", n->name);
sockaddr2str(&n->address, &address, &port);
asprintf(&envp[4], "REMOTEADDRESS=%s", address);
asprintf(&envp[3], "NODE=%s", n->name);
sockaddr2str(&n->address, &address, &port);
asprintf(&envp[4], "REMOTEADDRESS=%s", address);