diff options
author | Steven Barth <steven@midlink.org> | 2013-05-05 15:56:42 +0200 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2013-05-05 15:56:42 +0200 |
commit | d09e94fff82440cedf04f2e0cfe1ede8a0ab0600 (patch) | |
tree | 123348f359cb9af02bf6c1d76c3bfbca2b2d4562 /src/script.c | |
parent | 2515dbce13746bb1633cfa4b8e22424946a7f007 (diff) | |
download | odhcp6c-d09e94fff82440cedf04f2e0cfe1ede8a0ab0600.tar.gz |
Set a global default DHCPv6 exchange timeout
This delays SLAAC-updates before any DHCPv6-binding is established.
Diffstat (limited to 'src/script.c')
-rw-r--r-- | src/script.c | 23 |
1 files changed, 23 insertions, 0 deletions
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 <stdlib.h> #include <string.h> #include <syslog.h> +#include <signal.h> #include <unistd.h> #include <arpa/inet.h> #include <netinet/in.h> @@ -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); |