kernel: fq_codel: dont reinit flow state
[openwrt.git] / package / hostapd / patches / 440-optional_rfkill.patch
1 --- a/src/drivers/driver_nl80211.c
2 +++ b/src/drivers/driver_nl80211.c
3 @@ -218,7 +218,9 @@ struct wpa_driver_nl80211_data {
4         int if_removed;
5         int if_disabled;
6         int ignore_if_down_event;
7 +#ifdef CONFIG_RFKILL
8         struct rfkill_data *rfkill;
9 +#endif
10         struct wpa_driver_capa capa;
11         int has_capability;
12  
13 @@ -2828,7 +2830,7 @@ static int wpa_driver_nl80211_init_nl(st
14         return 0;
15  }
16  
17 -
18 +#ifdef CONFIG_RFKILL
19  static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
20  {
21         wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
22 @@ -2851,6 +2853,7 @@ static void wpa_driver_nl80211_rfkill_un
23         }
24         /* rtnetlink ifup handler will report interface as enabled */
25  }
26 +#endif /* CONFIG_RFKILL */
27  
28  
29  static void nl80211_get_phy_name(struct wpa_driver_nl80211_data *drv)
30 @@ -2979,7 +2982,9 @@ static void * wpa_driver_nl80211_init(vo
31                                       void *global_priv)
32  {
33         struct wpa_driver_nl80211_data *drv;
34 +#ifdef CONFIG_RFKILL
35         struct rfkill_config *rcfg;
36 +#endif
37         struct i802_bss *bss;
38  
39         if (global_priv == NULL)
40 @@ -3013,6 +3018,7 @@ static void * wpa_driver_nl80211_init(vo
41  
42         nl80211_get_phy_name(drv);
43  
44 +#ifdef CONFIG_RFKILL
45         rcfg = os_zalloc(sizeof(*rcfg));
46         if (rcfg == NULL)
47                 goto failed;
48 @@ -3025,6 +3031,7 @@ static void * wpa_driver_nl80211_init(vo
49                 wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
50                 os_free(rcfg);
51         }
52 +#endif /* CONFIG_RFKILL */
53  
54         if (wpa_driver_nl80211_finish_drv_init(drv))
55                 goto failed;
56 @@ -3311,10 +3318,12 @@ static void nl80211_mgmt_unsubscribe(str
57  }
58  
59  
60 +#ifdef CONFIG_RFKILL
61  static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
62  {
63         wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
64  }
65 +#endif /* CONFIG_RFKILL */
66  
67  static int
68  wpa_driver_nl80211_finish_drv_init_sta(struct wpa_driver_nl80211_data *drv,
69 @@ -3335,13 +3344,16 @@ wpa_driver_nl80211_finish_drv_init_sta(s
70         }
71  
72         if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {
73 +#ifdef CONFIG_RFKILL
74                 if (rfkill_is_blocked(drv->rfkill)) {
75                         wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
76                                    "interface '%s' due to rfkill",
77                                    bss->ifname);
78                         drv->if_disabled = 1;
79                         *send_rfkill_event = 1;
80 -               } else {
81 +               } else
82 +#endif
83 +               {
84                         wpa_printf(MSG_ERROR, "nl80211: Could not set "
85                                    "interface '%s' UP", bss->ifname);
86                         return -1;
87 @@ -3372,8 +3384,10 @@ wpa_driver_nl80211_finish_drv_init(struc
88                 return -1;
89  
90         if (send_rfkill_event) {
91 +#ifdef CONFIG_RFKILL
92                 eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
93                                        drv, drv->ctx);
94 +#endif
95         }
96  
97         return 0;
98 @@ -3460,7 +3474,9 @@ static void wpa_driver_nl80211_deinit(vo
99  
100         netlink_send_oper_ifla(drv->global->netlink, drv->ifindex, 0,
101                                IF_OPER_UP);
102 +#ifdef CONFIG_RFKILL
103         rfkill_deinit(drv->rfkill);
104 +#endif
105  
106         eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
107  
108 --- a/src/drivers/driver_wext.c
109 +++ b/src/drivers/driver_wext.c
110 @@ -742,7 +742,7 @@ static void wpa_driver_wext_event_rtm_de
111         }
112  }
113  
114 -
115 +#ifdef CONFIG_RFKILL
116  static void wpa_driver_wext_rfkill_blocked(void *ctx)
117  {
118         wpa_printf(MSG_DEBUG, "WEXT: RFKILL blocked");
119 @@ -764,7 +764,7 @@ static void wpa_driver_wext_rfkill_unblo
120         }
121         /* rtnetlink ifup handler will report interface as enabled */
122  }
123 -
124 +#endif /* CONFIG_RFKILL */
125  
126  static void wext_get_phy_name(struct wpa_driver_wext_data *drv)
127  {
128 @@ -810,7 +810,9 @@ void * wpa_driver_wext_init(void *ctx, c
129  {
130         struct wpa_driver_wext_data *drv;
131         struct netlink_config *cfg;
132 +#ifdef CONFIG_RFKILL
133         struct rfkill_config *rcfg;
134 +#endif
135         char path[128];
136         struct stat buf;
137  
138 @@ -845,6 +847,7 @@ void * wpa_driver_wext_init(void *ctx, c
139                 goto err2;
140         }
141  
142 +#ifdef CONFIG_RFKILL
143         rcfg = os_zalloc(sizeof(*rcfg));
144         if (rcfg == NULL)
145                 goto err3;
146 @@ -857,6 +860,7 @@ void * wpa_driver_wext_init(void *ctx, c
147                 wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
148                 os_free(rcfg);
149         }
150 +#endif /* CONFIG_RFKILL */
151  
152         drv->mlme_sock = -1;
153  
154 @@ -874,7 +878,9 @@ void * wpa_driver_wext_init(void *ctx, c
155         return drv;
156  
157  err3:
158 +#ifdef CONFIG_RFKILL
159         rfkill_deinit(drv->rfkill);
160 +#endif
161         netlink_deinit(drv->netlink);
162  err2:
163         close(drv->ioctl_sock);
164 @@ -884,10 +890,12 @@ err1:
165  }
166  
167  
168 +#ifdef CONFIG_RFKILL
169  static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
170  {
171         wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
172  }
173 +#endif /* CONFIG_RFKILL */
174  
175  
176  static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
177 @@ -895,13 +903,16 @@ static int wpa_driver_wext_finish_drv_in
178         int send_rfkill_event = 0;
179  
180         if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
181 +#ifdef CONFIG_RFKILL
182                 if (rfkill_is_blocked(drv->rfkill)) {
183                         wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
184                                    "interface '%s' due to rfkill",
185                                    drv->ifname);
186                         drv->if_disabled = 1;
187                         send_rfkill_event = 1;
188 -               } else {
189 +               } else
190 +#endif
191 +               {
192                         wpa_printf(MSG_ERROR, "WEXT: Could not set "
193                                    "interface '%s' UP", drv->ifname);
194                         return -1;
195 @@ -949,8 +960,10 @@ static int wpa_driver_wext_finish_drv_in
196                                1, IF_OPER_DORMANT);
197  
198         if (send_rfkill_event) {
199 +#ifdef CONFIG_RFKILL
200                 eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
201                                        drv, drv->ctx);
202 +#endif
203         }
204  
205         return 0;
206 @@ -980,7 +993,9 @@ void wpa_driver_wext_deinit(void *priv)
207  
208         netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
209         netlink_deinit(drv->netlink);
210 +#ifdef CONFIG_RFKILL
211         rfkill_deinit(drv->rfkill);
212 +#endif
213  
214         if (drv->mlme_sock >= 0)
215                 eloop_unregister_read_sock(drv->mlme_sock);
216 --- a/src/drivers/drivers.mak
217 +++ b/src/drivers/drivers.mak
218 @@ -25,7 +25,6 @@ NEED_SME=y
219  NEED_AP_MLME=y
220  NEED_NETLINK=y
221  NEED_LINUX_IOCTL=y
222 -NEED_RFKILL=y
223  
224  ifdef CONFIG_LIBNL32
225    DRV_LIBS += -lnl-3
226 @@ -101,7 +100,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
227  CONFIG_WIRELESS_EXTENSION=y
228  NEED_NETLINK=y
229  NEED_LINUX_IOCTL=y
230 -NEED_RFKILL=y
231  endif
232  
233  ifdef CONFIG_DRIVER_NDIS
234 @@ -127,7 +125,6 @@ endif
235  ifdef CONFIG_WIRELESS_EXTENSION
236  DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
237  DRV_WPA_OBJS += ../src/drivers/driver_wext.o
238 -NEED_RFKILL=y
239  endif
240  
241  ifdef NEED_NETLINK
242 @@ -140,6 +137,7 @@ endif
243  
244  ifdef NEED_RFKILL
245  DRV_OBJS += ../src/drivers/rfkill.o
246 +DRV_WPA_CFLAGS += -DCONFIG_RFKILL
247  endif
248  
249  ifdef CONFIG_VLAN_NETLINK
250 --- a/src/drivers/driver_wext.h
251 +++ b/src/drivers/driver_wext.h
252 @@ -22,7 +22,9 @@ struct wpa_driver_wext_data {
253         int ifindex2;
254         int if_removed;
255         int if_disabled;
256 +#ifdef CONFIG_RFKILL
257         struct rfkill_data *rfkill;
258 +#endif
259         u8 *assoc_req_ies;
260         size_t assoc_req_ies_len;
261         u8 *assoc_resp_ies;