Hm.
[tinc] / src / callbacks.c
1 #include "config.h"
2
3 #include <stdarg.h>
4
5 #include <hooks.h>
6 #include <node.h>
7
8 #include "callbacks.h"
9 #include "process.h"
10
11 #include "system.h"
12
13 void hook_node_visible(const char *hooktype, va_list ap)
14 {
15   char *name;
16   node_t *n;
17
18   n = va_arg(ap, node_t*);
19   asprintf(&name, "hosts/%s-down", n->name);
20   execute_script(name);
21   free(name);
22 }
23
24 void hook_node_invisible(const char *hooktype, va_list ap)
25 {
26   char *name;
27   node_t *n;
28
29   n = va_arg(ap, node_t*);
30   asprintf(&name, "hosts/%s-up", n->name);
31   execute_script(name);
32   free(name);
33 }
34
35 void init_callbacks(void)
36 {
37   add_hook("node-visible", hook_node_visible);
38   add_hook("node-invisible", hook_node_invisible);
39 }