-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.h
62 lines (51 loc) · 1.49 KB
/
interface.h
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
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright (C) 2024 TDT AG <[email protected]>
*
* This is free software, licensed under the GNU General Public License v2.
* See https://www.gnu.org/licenses/gpl-2.0.txt for more information.
*
*/
#ifndef _INTERFACE_H
#define _INTERFACE_H
#include <libubox/list.h>
#include <libubox/blobmsg.h>
#include <uci_blob.h>
enum interface_state {
IFACE_STATE_UNKNOWN,
IFACE_STATE_DOWN,
IFACE_STATE_NO_DEFAULT_ROUTE,
IFACE_STATE_UP,
IFACE_STATE_OFFLINE,
IFACE_STATE_ONLINE
};
struct interface {
struct list_head list;
char *name;
char *device;
enum interface_state state;
/* tracking targets */
int interval;
struct list_head targets;
};
enum {
IFACE_ATTR_INTERFACE,
IFACE_ATTR_ENABLED,
IFACE_ATTR_INTERVAL,
IFACE_ATTR_TRACKING_IPS,
__IFACE_ATTR_MAX,
};
static const struct blobmsg_policy interface_attrs[__IFACE_ATTR_MAX] = {
[IFACE_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_ENABLED] = { .name = "enabled", .type = BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_INTERVAL] = { .name = "interval", .type = BLOBMSG_TYPE_INT32 },
[IFACE_ATTR_TRACKING_IPS] = { .name = "track_ip", .type = BLOBMSG_TYPE_ARRAY },
};
static const struct uci_blob_param_list interface_attr_list = {
.n_params = ARRAY_SIZE(interface_attrs),
.params = interface_attrs,
};
void interface_notify(const char *interface, const char *action);
void interface_get_status(const char *interface, struct blob_buf *b);
int interfaces_init(void);
void interfaces_done(void);
#endif /* _INTERFACE_H */