add support for calls to a hotplug script on interface state changes
[project/netifd.git] / netifd.h
1 #ifndef __NETIFD_H
2 #define __NETIFD_H
3
4 #include <sys/socket.h>
5 #include <net/if.h>
6
7 #include <stdbool.h>
8 #include <stdio.h>
9
10 #include <libubox/uloop.h>
11
12 #include <libubus.h>
13
14 #include "utils.h"
15
16 #ifdef DUMMY_MODE
17 #define DEFAULT_HOTPLUG_PATH    "./scripts/hotplug-cmd"
18 #else
19 #define DEFAULT_HOTPLUG_PATH    "/sbin/hotplug-cmd"
20 #endif
21
22 extern char *hotplug_cmd_path;
23 extern unsigned int debug_mask;
24
25 enum {
26         DEBUG_SYSTEM    = 0,
27         DEBUG_DEVICE    = 1,
28         DEBUG_INTERFACE = 2,
29 };
30
31 #ifdef DEBUG
32 #define DPRINTF(format, ...) fprintf(stderr, "%s(%d): " format, __func__, __LINE__, ## __VA_ARGS__)
33 #define D(level, format, ...) do { \
34                 if (debug_mask & (1 << (DEBUG_ ## level))) \
35                                 DPRINTF(format, ##__VA_ARGS__); \
36         } while (0)
37 #else
38 #define DPRINTF(format, ...) no_debug(0, format, ## __VA_ARGS__)
39 #define D(level, format, ...) no_debug(DEBUG_ ## level, format, ## __VA_ARGS__)
40 #endif
41
42 static inline void no_debug(int level, const char *fmt, ...)
43 {
44 }
45
46 struct device;
47 struct interface;
48
49 extern const char *main_path;
50 void netifd_restart(void);
51 void netifd_reload(void);
52
53 #endif