summaryrefslogtreecommitdiffhomepage
path: root/config.h
blob: 879b1deff2bfaf84da40ef0c535795ee9f06565a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef __NETIFD_CONFIG_H
#define __NETIFD_CONFIG_H

#include <libubox/blobmsg.h>

extern bool config_init;

enum config_param_type {
	CONFIG_PARAM_TYPE_SIMPLE,
	CONFIG_PARAM_TYPE_LIST,
	CONFIG_PARAM_TYPE_SECTION,
};

union config_param_info {
	enum blobmsg_type type;
	struct config_params *section;
};

struct config_param_list {
	int n_params, n_next;

	const struct blobmsg_policy *params;
	const union config_param_info *info;

	const struct config_param_list *next[];
};

#ifndef BITS_PER_LONG
#define BITS_PER_LONG (8 * sizeof(unsigned long))
#endif

static inline void set_bit(unsigned long *bits, int bit)
{
	bits[bit / BITS_PER_LONG] |= (1UL << (bit % BITS_PER_LONG));
}

static inline bool test_bit(unsigned long *bits, int bit)
{
	return !!(bits[bit / BITS_PER_LONG] & (1UL << (bit % BITS_PER_LONG)));
}

void config_init_all(void);
bool config_check_equal(struct blob_attr *c1, struct blob_attr *c2,
			const struct config_param_list *config);
bool config_diff(struct blob_attr **tb1, struct blob_attr **tb2,
		 const struct config_param_list *config, unsigned long *diff);

struct blob_attr *config_memdup(struct blob_attr *attr);

#endif