remote: close file on usteer_init_local_id fread fail
[project/usteer.git] / node.h
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
14 *
15 * Copyright (C) 2020 embedd.ch
16 * Copyright (C) 2020 Felix Fietkau <nbd@nbd.name>
17 * Copyright (C) 2020 John Crispin <john@phrozen.org>
18 */
19
20 #ifndef __APMGR_NODE_H
21 #define __APMGR_NODE_H
22
23 #include "usteer.h"
24
25 enum local_req_state {
26 REQ_IDLE,
27 REQ_CLIENTS,
28 REQ_STATUS,
29 REQ_RRM_SET_LIST,
30 REQ_RRM_GET_OWN,
31 __REQ_MAX
32 };
33
34 struct usteer_local_node {
35 struct usteer_node node;
36
37 struct ubus_subscriber ev;
38 struct uloop_timeout update;
39
40 const char *iface;
41 int ifindex;
42 int wiphy;
43
44 struct ubus_request req;
45 struct uloop_timeout req_timer;
46 int req_state;
47
48 uint32_t obj_id;
49
50 float load_ewma;
51 int load_thr_count;
52
53 uint64_t time, time_busy;
54
55 struct kvlist node_info;
56
57 struct uloop_timeout bss_tm_queries_timeout;
58 struct list_head bss_tm_queries;
59
60 int beacon_interval;
61
62 uint16_t band_steering_interval;
63
64 struct {
65 bool present;
66 struct uloop_timeout update;
67 } nl80211;
68 struct {
69 struct ubus_request req;
70 bool req_pending;
71 bool status_complete;
72 } netifd;
73
74 unsigned int link_measurement_tries;
75 };
76
77 struct interface;
78
79 struct usteer_remote_host {
80 struct avl_node avl;
81
82 struct list_head nodes;
83 struct blob_attr *host_info;
84 char *addr;
85 };
86
87 struct usteer_remote_node {
88 struct list_head list;
89 struct list_head host_list;
90 const char *name;
91
92 struct usteer_remote_host *host;
93 struct usteer_node node;
94
95 int check;
96 };
97
98 extern struct avl_tree local_nodes;
99 extern struct list_head remote_nodes;
100 extern struct avl_tree remote_hosts;
101
102 #define for_each_local_node(node) \
103 avl_for_each_element(&local_nodes, node, avl) \
104 if (!node->disabled)
105
106 #define for_each_remote_node(rn) \
107 list_for_each_entry(rn, &remote_nodes, list)
108
109 #endif