403cc86da9cb7ebba06ad8ebcfa781412702895c
[project/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 "interface.h"
19
20 extern struct vlist_tree wireless_devices;
21 extern struct avl_tree wireless_drivers;
22
23 struct wireless_driver {
24         struct avl_node node;
25
26         const char *name;
27         const char *script;
28
29         struct {
30                 char *buf;
31                 struct uci_blob_param_list *config;
32         } device, interface;
33 };
34
35 struct wireless_device {
36         struct vlist_node node;
37
38         struct wireless_driver *drv;
39         struct vlist_tree interfaces;
40         char *name;
41
42         struct netifd_process script_task;
43         struct uloop_timeout timeout;
44         struct uloop_timeout poll;
45
46         struct list_head script_proc;
47         struct uloop_fd script_proc_fd;
48         struct uloop_timeout script_check;
49
50         struct ubus_request_data *kill_request;
51
52         struct blob_attr *prev_config;
53         struct blob_attr *config;
54         struct blob_attr *data;
55
56         bool config_autostart;
57         bool autostart;
58         bool disabled;
59         bool retry_setup_failed;
60
61         enum interface_state state;
62         enum interface_config_state config_state;
63         bool cancel;
64         int retry;
65
66         int vif_idx;
67 };
68
69 struct wireless_interface {
70         struct vlist_node node;
71         const char *section;
72         char *name;
73
74         struct wireless_device *wdev;
75
76         struct blob_attr *config;
77         struct blob_attr *data;
78
79         const char *ifname;
80         struct blob_attr *network;
81         bool isolate;
82         bool ap_mode;
83 };
84
85 struct wireless_process {
86         struct list_head list;
87
88         const char *exe;
89         int pid;
90
91         bool required;
92 };
93
94 void wireless_device_create(struct wireless_driver *drv, const char *name, struct blob_attr *data);
95 void wireless_device_set_up(struct wireless_device *wdev);
96 void wireless_device_set_down(struct wireless_device *wdev);
97 void wireless_device_status(struct wireless_device *wdev, struct blob_buf *b);
98 void wireless_device_get_validate(struct wireless_device *wdev, struct blob_buf *b);
99 void wireless_interface_create(struct wireless_device *wdev, struct blob_attr *data, const char *section);
100 int wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data,
101                            struct ubus_request_data *req);
102
103 void wireless_start_pending(void);
104 void wireless_init(void);
105
106 #endif