Root/package/hostapd/patches/540-optional_rfkill.patch

1--- a/src/drivers/driver_nl80211.c
2+++ b/src/drivers/driver_nl80211.c
3@@ -198,7 +198,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@@ -2203,7 +2205,7 @@ err3:
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@@ -2226,6 +2228,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@@ -2283,7 +2286,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     drv = os_zalloc(sizeof(*drv));
40@@ -2311,6 +2316,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@@ -2323,6 +2329,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@@ -2445,10 +2452,12 @@ static int nl80211_register_action_frame
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 
68 static int
69@@ -2475,13 +2484,16 @@ wpa_driver_nl80211_finish_drv_init(struc
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@@ -2510,8 +2522,10 @@ wpa_driver_nl80211_finish_drv_init(struc
88     }
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@@ -2596,7 +2610,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@@ -702,7 +702,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@@ -724,7 +724,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@@ -770,7 +770,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@@ -805,6 +807,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@@ -817,6 +820,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@@ -828,7 +832,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@@ -838,10 +844,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@@ -849,13 +857,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@@ -903,8 +914,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@@ -934,7 +947,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@@ -43,7 +43,6 @@ NEED_SME=y
219 NEED_AP_MLME=y
220 NEED_NETLINK=y
221 NEED_LINUX_IOCTL=y
222-NEED_RFKILL=y
223 ifdef CONFIG_LIBNL_TINY
224 DRV_LIBS += -lnl-tiny
225 else
226@@ -94,7 +93,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_RALINK
234@@ -146,7 +144,6 @@ endif
235 ifdef CONFIG_WIRELESS_EXTENSION
236 DRV_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
237 DRV_OBJS += ../src/drivers/driver_wext.o
238-NEED_RFKILL=y
239 endif
240 
241 ifdef NEED_NETLINK
242@@ -159,6 +156,7 @@ endif
243 
244 ifdef NEED_RFKILL
245 DRV_OBJS += ../src/drivers/rfkill.o
246+DRV_WPA_CFLAGS += -DCONFIG_RFKILL
247 endif
248 
249 
250--- a/src/drivers/driver_wext.h
251+++ b/src/drivers/driver_wext.h
252@@ -28,7 +28,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;
262

Archive Download this file



interactive