hostapd: update to 20101109, reorganize patches
[openwrt.git] / package / hostapd / patches / 540-optional_rfkill.patch
1 --- a/src/drivers/driver_nl80211.c
2 +++ b/src/drivers/driver_nl80211.c
3 @@ -115,7 +115,9 @@ struct wpa_driver_nl80211_data {
4         int ifindex;
5         int if_removed;
6         int if_disabled;
7 +#ifdef CONFIG_RFKILL
8         struct rfkill_data *rfkill;
9 +#endif
10         struct wpa_driver_capa capa;
11         int has_capability;
12  
13 @@ -1630,7 +1632,7 @@ err1:
14         return -1;
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 @@ -1652,6 +1654,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  /**
30 @@ -1665,7 +1668,9 @@ static void * wpa_driver_nl80211_init(vo
31  {
32         struct wpa_driver_nl80211_data *drv;
33         struct netlink_config *cfg;
34 +#ifdef CONFIG_RFKILL
35         struct rfkill_config *rcfg;
36 +#endif
37         struct i802_bss *bss;
38  
39         drv = os_zalloc(sizeof(*drv));
40 @@ -1703,6 +1708,7 @@ static void * wpa_driver_nl80211_init(vo
41                 goto failed;
42         }
43  
44 +#ifdef CONFIG_RFKILL
45         rcfg = os_zalloc(sizeof(*rcfg));
46         if (rcfg == NULL)
47                 goto failed;
48 @@ -1715,6 +1721,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 @@ -1722,7 +1729,9 @@ static void * wpa_driver_nl80211_init(vo
57         return bss;
58  
59  failed:
60 +#ifdef CONFIG_RFKILL
61         rfkill_deinit(drv->rfkill);
62 +#endif
63         netlink_deinit(drv->netlink);
64         if (drv->ioctl_sock >= 0)
65                 close(drv->ioctl_sock);
66 @@ -1820,10 +1829,12 @@ static int nl80211_register_action_frame
67  }
68  
69  
70 +#ifdef CONFIG_RFKILL
71  static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
72  {
73         wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
74  }
75 +#endif /* CONFIG_RFKILL */
76  
77  
78  static int
79 @@ -1842,13 +1853,16 @@ wpa_driver_nl80211_finish_drv_init(struc
80                 }
81  
82                 if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
83 +#ifdef CONFIG_RFKILL
84                         if (rfkill_is_blocked(drv->rfkill)) {
85                                 wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
86                                            "interface '%s' due to rfkill",
87                                            bss->ifname);
88                                 drv->if_disabled = 1;
89                                 send_rfkill_event = 1;
90 -                       } else {
91 +                       } else
92 +#endif
93 +                       {
94                                 wpa_printf(MSG_ERROR, "nl80211: Could not set "
95                                            "interface '%s' UP", bss->ifname);
96                                 return -1;
97 @@ -1873,8 +1887,10 @@ wpa_driver_nl80211_finish_drv_init(struc
98         }
99  
100         if (send_rfkill_event) {
101 +#ifdef CONFIG_RFKILL
102                 eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
103                                        drv, drv->ctx);
104 +#endif
105         }
106  
107         return 0;
108 @@ -1955,7 +1971,9 @@ static void wpa_driver_nl80211_deinit(vo
109  
110         netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
111         netlink_deinit(drv->netlink);
112 +#ifdef CONFIG_RFKILL
113         rfkill_deinit(drv->rfkill);
114 +#endif
115  
116         eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
117  
118 --- a/src/drivers/driver_wext.c
119 +++ b/src/drivers/driver_wext.c
120 @@ -700,7 +700,7 @@ static void wpa_driver_wext_event_rtm_de
121         }
122  }
123  
124 -
125 +#ifdef CONFIG_RFKILL
126  static void wpa_driver_wext_rfkill_blocked(void *ctx)
127  {
128         wpa_printf(MSG_DEBUG, "WEXT: RFKILL blocked");
129 @@ -722,7 +722,7 @@ static void wpa_driver_wext_rfkill_unblo
130         }
131         /* rtnetlink ifup handler will report interface as enabled */
132  }
133 -
134 +#endif /* CONFIG_RFKILL */
135  
136  /**
137   * wpa_driver_wext_init - Initialize WE driver interface
138 @@ -735,7 +735,9 @@ void * wpa_driver_wext_init(void *ctx, c
139  {
140         struct wpa_driver_wext_data *drv;
141         struct netlink_config *cfg;
142 +#ifdef CONFIG_RFKILL
143         struct rfkill_config *rcfg;
144 +#endif
145         char path[128];
146         struct stat buf;
147  
148 @@ -769,6 +771,7 @@ void * wpa_driver_wext_init(void *ctx, c
149                 goto err2;
150         }
151  
152 +#ifdef CONFIG_RFKILL
153         rcfg = os_zalloc(sizeof(*rcfg));
154         if (rcfg == NULL)
155                 goto err3;
156 @@ -781,6 +784,7 @@ void * wpa_driver_wext_init(void *ctx, c
157                 wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
158                 os_free(rcfg);
159         }
160 +#endif /* CONFIG_RFKILL */
161  
162         drv->mlme_sock = -1;
163  
164 @@ -792,7 +796,9 @@ void * wpa_driver_wext_init(void *ctx, c
165         return drv;
166  
167  err3:
168 +#ifdef CONFIG_RFKILL
169         rfkill_deinit(drv->rfkill);
170 +#endif
171         netlink_deinit(drv->netlink);
172  err2:
173         close(drv->ioctl_sock);
174 @@ -802,10 +808,12 @@ err1:
175  }
176  
177  
178 +#ifdef CONFIG_RFKILL
179  static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
180  {
181         wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
182  }
183 +#endif /* CONFIG_RFKILL */
184  
185  
186  static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
187 @@ -813,13 +821,16 @@ static int wpa_driver_wext_finish_drv_in
188         int send_rfkill_event = 0;
189  
190         if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
191 +#ifdef CONFIG_RFKILL
192                 if (rfkill_is_blocked(drv->rfkill)) {
193                         wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
194                                    "interface '%s' due to rfkill",
195                                    drv->ifname);
196                         drv->if_disabled = 1;
197                         send_rfkill_event = 1;
198 -               } else {
199 +               } else
200 +#endif
201 +               {
202                         wpa_printf(MSG_ERROR, "WEXT: Could not set "
203                                    "interface '%s' UP", drv->ifname);
204                         return -1;
205 @@ -867,8 +878,10 @@ static int wpa_driver_wext_finish_drv_in
206                                1, IF_OPER_DORMANT);
207  
208         if (send_rfkill_event) {
209 +#ifdef CONFIG_RFKILL
210                 eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
211                                        drv, drv->ctx);
212 +#endif
213         }
214  
215         return 0;
216 @@ -898,7 +911,9 @@ void wpa_driver_wext_deinit(void *priv)
217  
218         netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
219         netlink_deinit(drv->netlink);
220 +#ifdef CONFIG_RFKILL
221         rfkill_deinit(drv->rfkill);
222 +#endif
223  
224         if (drv->mlme_sock >= 0)
225                 eloop_unregister_read_sock(drv->mlme_sock);
226 --- a/src/drivers/drivers.mak
227 +++ b/src/drivers/drivers.mak
228 @@ -43,7 +43,6 @@ NEED_SME=y
229  NEED_AP_MLME=y
230  NEED_NETLINK=y
231  NEED_LINUX_IOCTL=y
232 -NEED_RFKILL=y
233  ifdef CONFIG_LIBNL_TINY
234  DRV_LIBS += -lnl-tiny
235  else
236 @@ -94,7 +93,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
237  CONFIG_WIRELESS_EXTENSION=y
238  NEED_NETLINK=y
239  NEED_LINUX_IOCTL=y
240 -NEED_RFKILL=y
241  endif
242  
243  ifdef CONFIG_DRIVER_HERMES
244 @@ -183,6 +181,7 @@ endif
245  
246  ifdef NEED_RFKILL
247  DRV_OBJS += ../src/drivers/rfkill.o
248 +DRV_WPA_CFLAGS += -DCONFIG_RFKILL
249  endif
250  
251  
252 --- a/src/drivers/driver_wext.h
253 +++ b/src/drivers/driver_wext.h
254 @@ -27,7 +27,9 @@ struct wpa_driver_wext_data {
255         int ifindex2;
256         int if_removed;
257         int if_disabled;
258 +#ifdef CONFIG_RFKILL
259         struct rfkill_data *rfkill;
260 +#endif
261         u8 *assoc_req_ies;
262         size_t assoc_req_ies_len;
263         u8 *assoc_resp_ies;