Callbacks
This commit is contained in:
parent
4c1a4e8a79
commit
474aab6325
2 changed files with 46 additions and 0 deletions
39
src/callbacks.c
Normal file
39
src/callbacks.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <hooks.h>
|
||||
#include <node.h>
|
||||
|
||||
#include "callbacks.h"
|
||||
#include "process.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
void hook_node_visible(const char *hooktype, va_list ap)
|
||||
{
|
||||
char *name;
|
||||
node_t *n;
|
||||
|
||||
n = va_arg(ap, node_t*);
|
||||
asprintf(&name, "hosts/%s-down", n->name);
|
||||
execute_script(name);
|
||||
free(name);
|
||||
}
|
||||
|
||||
void hook_node_invisible(const char *hooktype, va_list ap)
|
||||
{
|
||||
char *name;
|
||||
node_t *n;
|
||||
|
||||
n = va_arg(ap, node_t*);
|
||||
asprintf(&name, "hosts/%s-up", n->name);
|
||||
execute_script(name);
|
||||
free(name);
|
||||
}
|
||||
|
||||
void init_callbacks(void)
|
||||
{
|
||||
add_hook("node-visible", hook_node_visible);
|
||||
add_hook("node-invisible", hook_node_invisible);
|
||||
}
|
7
src/callbacks.h
Normal file
7
src/callbacks.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
#ifndef __TINC_CALLBACKS_H__
|
||||
#define __TINC_CALLBACKS_H__
|
||||
|
||||
extern void init_callbacks(void);
|
||||
|
||||
#endif /* __TINC_CALLBACKS_H__ */
|
Loading…
Reference in a new issue