X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fsubnet.c;h=7ff8f7aab518d27372fd74436eb5198546e72aa2;hb=57991e264202ad83e2c1b663777b358bf5573652;hp=4b6c068688ff787a125cfb15c9cfce86d5bd0add;hpb=0b8b23e0dd7219344543f135ca0aeba8a4a42d48;p=tinc diff --git a/src/subnet.c b/src/subnet.c index 4b6c0686..7ff8f7aa 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -1,6 +1,6 @@ /* subnet.c -- handle subnet lookups and lists - Copyright (C) 2000-2012 Guus Sliepen , + Copyright (C) 2000-2013 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -25,10 +25,11 @@ #include "device.h" #include "hash.h" #include "logger.h" +#include "names.h" #include "net.h" #include "netutl.h" #include "node.h" -#include "process.h" +#include "script.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" @@ -78,7 +79,7 @@ void free_subnet_tree(splay_tree_t *subnet_tree) { /* Allocating and freeing space for subnets */ subnet_t *new_subnet(void) { - return xmalloc_and_zero(sizeof(subnet_t)); + return xzalloc(sizeof(subnet_t)); } void free_subnet(subnet_t *subnet) { @@ -203,7 +204,7 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { // Prepare environment variables to be passed to the script - char *envp[9] = {NULL}; + char *envp[10] = {NULL}; xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); xasprintf(&envp[1], "DEVICE=%s", device ? : ""); xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); @@ -218,6 +219,8 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { free(address); } + xasprintf(&envp[8], "NAME=%s", myself->name); + name = up ? "subnet-up" : "subnet-down"; if(!subnet) { @@ -259,7 +262,7 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { } } - for(int i = 0; envp[i] && i < 8; i++) + for(int i = 0; envp[i] && i < 9; i++) free(envp[i]); }