From d09e94fff82440cedf04f2e0cfe1ede8a0ab0600 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 5 May 2013 15:56:42 +0200 Subject: Set a global default DHCPv6 exchange timeout This delays SLAAC-updates before any DHCPv6-binding is established. --- src/script.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/script.c') diff --git a/src/script.c b/src/script.c index ffb39f3..a56d9b4 100644 --- a/src/script.c +++ b/src/script.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,7 @@ static const int8_t hexvals[] = { static char *argv[4] = {NULL, NULL, NULL, NULL}; +static volatile char *delayed_call = NULL; int script_init(const char *path, const char *ifname) @@ -176,11 +178,32 @@ static void entry_to_env(const char *name, const void *data, size_t len, enum en } +static void script_call_delayed(int signal __attribute__((unused))) +{ + if (delayed_call) + script_call((char*)delayed_call); +} + + +void script_delay_call(const char *status, int timeout) +{ + if (!delayed_call) { + delayed_call = strdup(status); + signal(SIGALRM, script_call_delayed); + alarm(timeout); + } +} + + void script_call(const char *status) { size_t dns_len, search_len, custom_len, sntp_ip_len, sntp_dns_len; size_t sip_ip_len, sip_fqdn_len; + odhcp6c_expire(); + if (delayed_call) + alarm(0); + struct in6_addr *dns = odhcp6c_get_state(STATE_DNS, &dns_len); uint8_t *search = odhcp6c_get_state(STATE_SEARCH, &search_len); uint8_t *custom = odhcp6c_get_state(STATE_CUSTOM_OPTS, &custom_len); -- cgit v1.2.1