X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fgraph.c;h=75996eacdd26a8539fecc9166137822d495fdc2f;hb=b3b89e46b1b84fa6cf1726fabe9e9c7bb0d3d831;hp=7079f93efc5e98513541b47de14d823211874b30;hpb=cc3c69c892b0dad9a6ece0a0f4ccd429a22fcbff;p=meshlink diff --git a/src/graph.c b/src/graph.c index 7079f93e..75996eac 100644 --- a/src/graph.c +++ b/src/graph.c @@ -44,9 +44,7 @@ #include "system.h" -#include "config.h" #include "connection.h" -#include "device.h" #include "edge.h" #include "graph.h" #include "list.h" @@ -54,8 +52,8 @@ #include "names.h" #include "netutl.h" #include "node.h" -#include "process.h" #include "protocol.h" +#include "script.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" @@ -204,7 +202,7 @@ static void check_reachability(void) { for splay_each(node_t, n, node_tree) { if(n->status.visited != n->status.reachable) { n->status.reachable = !n->status.reachable; - n->last_state_change = time(NULL); + n->last_state_change = now.tv_sec; if(n->status.reachable) { logger(DEBUG_TRAFFIC, LOG_DEBUG, "Node %s (%s) became reachable", @@ -236,16 +234,14 @@ static void check_reachability(void) { char *name; char *address; char *port; - char *envp[7]; + char *envp[8] = {NULL}; xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); - xasprintf(&envp[1], "DEVICE=%s", device ? : ""); - xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); xasprintf(&envp[3], "NODE=%s", n->name); sockaddr2str(&n->address, &address, &port); xasprintf(&envp[4], "REMOTEADDRESS=%s", address); xasprintf(&envp[5], "REMOTEPORT=%s", port); - envp[6] = NULL; + xasprintf(&envp[6], "NAME=%s", myself->name); execute_script(n->status.reachable ? "host-up" : "host-down", envp); @@ -256,7 +252,7 @@ static void check_reachability(void) { free(address); free(port); - for(int i = 0; i < 6; i++) + for(int i = 0; i < 7; i++) free(envp[i]); subnet_update(n, NULL, n->status.reachable);