fix a double free / use after free
[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 extern unsigned int debug_mask;
17
18 enum {
19         DEBUG_SYSTEM    = 0,
20         DEBUG_DEVICE    = 1,
21         DEBUG_INTERFACE = 2,
22 };
23
24 #ifdef DEBUG
25 #define DPRINTF(format, ...) fprintf(stderr, "%s(%d): " format, __func__, __LINE__, ## __VA_ARGS__)
26 #define D(level, format, ...) if (debug_mask & (1 << (DEBUG_ ## level))) DPRINTF(format, ##__VA_ARGS__)
27 #else
28 #define DPRINTF(format, ...) no_debug(0, format, ## __VA_ARGS__)
29 #define D(level, format, ...) no_debug(DEBUG_ ## level, format, ## __VA_ARGS__)
30 #endif
31
32 static inline void no_debug(int level, const char *fmt, ...)
33 {
34 }
35
36 struct device;
37 struct interface;
38
39 extern const char *main_path;
40 void netifd_restart(void);
41 void netifd_reload(void);
42
43 #endif