directly pass the device name to the device create function
[project/netifd.git] / config.h
1 #ifndef __NETIFD_CONFIG_H
2 #define __NETIFD_CONFIG_H
3
4 #include <libubox/blobmsg.h>
5
6 extern bool config_init;
7
8 enum config_param_type {
9         CONFIG_PARAM_TYPE_SIMPLE,
10         CONFIG_PARAM_TYPE_LIST,
11         CONFIG_PARAM_TYPE_SECTION,
12 };
13
14 union config_param_info {
15         enum blobmsg_type type;
16         struct config_params *section;
17 };
18
19 struct config_param_list {
20         int n_params, n_next;
21
22         const struct blobmsg_policy *params;
23         const union config_param_info *info;
24
25         const struct config_param_list *next[];
26 };
27
28 #ifndef BITS_PER_LONG
29 #define BITS_PER_LONG (8 * sizeof(unsigned long))
30 #endif
31
32 static inline void set_bit(unsigned long *bits, int bit)
33 {
34         bits[bit / BITS_PER_LONG] |= (1UL << (bit % BITS_PER_LONG));
35 }
36
37 static inline bool test_bit(unsigned long *bits, int bit)
38 {
39         return !!(bits[bit / BITS_PER_LONG] & (1UL << (bit % BITS_PER_LONG)));
40 }
41
42 void config_init_interfaces(const char *name);
43 bool config_check_equal(struct blob_attr *c1, struct blob_attr *c2,
44                         const struct config_param_list *config);
45 bool config_diff(struct blob_attr **tb1, struct blob_attr **tb2,
46                  const struct config_param_list *config, unsigned long *diff);
47
48 struct blob_attr *config_memdup(struct blob_attr *attr);
49
50 #endif