system-linux: fix PATH_MAX undeclared compilation error
[oweals/netifd.git] / wireless.h
1 /*
2  * netifd - network interface daemon
3  * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14 #ifndef __NETIFD_WIRELESS_H
15 #define __NETIFD_WIRELESS_H
16
17 #include <libubox/utils.h>
18 #include <libubox/list.h>
19 #include "interface.h"
20
21 extern struct vlist_tree wireless_devices;
22 extern struct avl_tree wireless_drivers;
23
24 struct wireless_driver {
25         struct avl_node node;
26
27         const char *name;
28         const char *script;
29
30         struct {
31                 char *buf;
32                 struct uci_blob_param_list *config;
33         } device, interface;
34 };
35
36 struct wireless_device {
37         struct vlist_node node;
38
39         struct list_head handler;
40         bool handler_action;
41         bool handler_pending;
42         bool serialize;
43
44         struct wireless_driver *drv;
45         struct vlist_tree interfaces;
46         char *name;
47
48         struct netifd_process script_task;
49         struct uloop_timeout timeout;
50         struct uloop_timeout poll;
51
52         struct list_head script_proc;
53         struct uloop_fd script_proc_fd;
54         struct uloop_timeout script_check;
55
56         struct ubus_request_data *kill_request;
57
58         struct blob_attr *prev_config;
59         struct blob_attr *config;
60         struct blob_attr *data;
61
62         bool autostart;
63         bool disabled;
64         bool retry_setup_failed;
65
66         enum interface_state state;
67         enum interface_config_state config_state;
68         bool reconf;
69         bool cancel;
70         int retry;
71
72         int vif_idx;
73 };
74
75 struct wireless_interface {
76         struct vlist_node node;
77         const char *section;
78         char *name;
79
80         struct wireless_device *wdev;
81
82         struct blob_attr *config;
83         struct blob_attr *data;
84
85         const char *ifname;
86         struct blob_attr *network;
87         bool isolate;
88         bool ap_mode;
89 };
90
91 struct wireless_process {
92         struct list_head list;
93
94         const char *exe;
95         int pid;
96
97         bool required;
98 };
99
100 void wireless_device_create(struct wireless_driver *drv, const char *name, struct blob_attr *data);
101 void wireless_device_set_up(struct wireless_device *wdev);
102 void wireless_device_set_down(struct wireless_device *wdev);
103 void wireless_device_reconf(struct wireless_device *wdev);
104 void wireless_device_status(struct wireless_device *wdev, struct blob_buf *b);
105 void wireless_device_get_validate(struct wireless_device *wdev, struct blob_buf *b);
106 void wireless_interface_create(struct wireless_device *wdev, struct blob_attr *data, const char *section);
107 int wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data,
108                            struct ubus_request_data *req);
109
110 void wireless_start_pending(void);
111 void wireless_init(void);
112
113 #endif