-
Notifications
You must be signed in to change notification settings - Fork 6
/
ustatusd.h
112 lines (90 loc) · 2.88 KB
/
ustatusd.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright (C) 2017 John Crispin <john@phrozen.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#define _GNU_SOURCE
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/reboot.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <unistd.h>
#include <getopt.h>
#include <libgen.h>
#include <glob.h>
#include <linux/rtnetlink.h>
#include <linux/nl80211.h>
#include <net/if.h>
#include <netlink/msg.h>
#include <netlink/attr.h>
#include <netlink/socket.h>
#include <netlink/genl/ctrl.h>
#include <netlink/genl/genl.h>
#include <libubox/uloop.h>
#include <libubox/utils.h>
#include <libubus.h>
#include <libubox/blobmsg_json.h>
#include <libubox/avl.h>
#include <libubox/vlist.h>
#include <libubox/ulog.h>
#include <uci.h>
#include <uci_blob.h>
struct ip_node {
struct avl_node avl;
uint8_t *ip;
uint8_t *mac;
int ip_len;
int iface;
};
struct status_socket {
struct uloop_fd uloop;
struct nl_sock *sock;
int bufsize;
};
struct family_data {
const char *group;
int id;
};
struct config {
uint16_t rssi_low;
uint16_t rssi_high;
uint32_t tx_rate_low;
uint32_t tx_rate_high;
uint32_t tx_retries;
uint32_t station_status;
uint32_t station_poll;
};
extern struct config config;
extern bool nl_status_socket(struct status_socket *ev, int protocol,
int (*cb)(struct nl_msg *msg, void *arg), void *priv);
extern void nl_handler_nl_status(struct uloop_fd *u, unsigned int statuss);
extern int genl_send_and_recv(struct status_socket *ev, struct nl_msg * msg);
extern int nl80211_init(void);
extern void nl80211_enum(void);
extern int rtnl_init(void);
extern void rtnl_enum(void);
extern struct nl_sock *create_socket(int protocol, int groups);
extern void handler_nl_status(struct uloop_fd *u, unsigned int statuss);
extern struct ubus_object ubus_object;
extern struct ubus_auto_conn conn;
extern void ubus_init(void);
extern void ubus_uninit(void);
extern struct blob_buf b;
extern void blobmsg_add_iface(struct blob_buf *bbuf, char *name, int index);
extern void blobmsg_add_iftype(struct blob_buf *bbuf, const char *name, const uint32_t iftype);
extern void blobmsg_add_ipv4(struct blob_buf *bbuf, const char *name, const uint8_t* addr);
extern void blobmsg_add_ipv6(struct blob_buf *bbuf, const char *name, const uint16_t* addr);
extern void blobmsg_add_mac(struct blob_buf *bbuf, const char *name, const uint8_t* addr);
extern void bridge_init(void);
extern void config_load(void);
extern void resmon_init(void);
extern void resmon_to_blob(struct blob_buf *b);