540-optional_rfkill.patch 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. --- a/src/drivers/driver_nl80211.c
  2. +++ b/src/drivers/driver_nl80211.c
  3. @@ -127,7 +127,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. @@ -1729,7 +1731,7 @@ err1:
  13. return -1;
  14. }
  15. -
  16. +#ifdef CONFIG_RFKILL
  17. static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
  18. {
  19. wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
  20. @@ -1751,6 +1753,7 @@ static void wpa_driver_nl80211_rfkill_un
  21. }
  22. /* rtnetlink ifup handler will report interface as enabled */
  23. }
  24. +#endif /* CONFIG_RFKILL */
  25. static void nl80211_get_phy_name(struct wpa_driver_nl80211_data *drv)
  26. @@ -1799,7 +1802,9 @@ static void * wpa_driver_nl80211_init(vo
  27. {
  28. struct wpa_driver_nl80211_data *drv;
  29. struct netlink_config *cfg;
  30. +#ifdef CONFIG_RFKILL
  31. struct rfkill_config *rcfg;
  32. +#endif
  33. struct i802_bss *bss;
  34. drv = os_zalloc(sizeof(*drv));
  35. @@ -1842,6 +1847,7 @@ static void * wpa_driver_nl80211_init(vo
  36. goto failed;
  37. }
  38. +#ifdef CONFIG_RFKILL
  39. rcfg = os_zalloc(sizeof(*rcfg));
  40. if (rcfg == NULL)
  41. goto failed;
  42. @@ -1854,6 +1860,7 @@ static void * wpa_driver_nl80211_init(vo
  43. wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
  44. os_free(rcfg);
  45. }
  46. +#endif /* CONFIG_RFKILL */
  47. if (wpa_driver_nl80211_finish_drv_init(drv))
  48. goto failed;
  49. @@ -1861,7 +1868,9 @@ static void * wpa_driver_nl80211_init(vo
  50. return bss;
  51. failed:
  52. +#ifdef CONFIG_RFKILL
  53. rfkill_deinit(drv->rfkill);
  54. +#endif
  55. netlink_deinit(drv->netlink);
  56. if (drv->ioctl_sock >= 0)
  57. close(drv->ioctl_sock);
  58. @@ -1964,10 +1973,12 @@ static int nl80211_register_action_frame
  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. static int
  67. @@ -1986,13 +1997,16 @@ wpa_driver_nl80211_finish_drv_init(struc
  68. }
  69. if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
  70. +#ifdef CONFIG_RFKILL
  71. if (rfkill_is_blocked(drv->rfkill)) {
  72. wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
  73. "interface '%s' due to rfkill",
  74. bss->ifname);
  75. drv->if_disabled = 1;
  76. send_rfkill_event = 1;
  77. - } else {
  78. + } else
  79. +#endif
  80. + {
  81. wpa_printf(MSG_ERROR, "nl80211: Could not set "
  82. "interface '%s' UP", bss->ifname);
  83. return -1;
  84. @@ -2020,8 +2034,10 @@ wpa_driver_nl80211_finish_drv_init(struc
  85. }
  86. if (send_rfkill_event) {
  87. +#ifdef CONFIG_RFKILL
  88. eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
  89. drv, drv->ctx);
  90. +#endif
  91. }
  92. return 0;
  93. @@ -2102,7 +2118,9 @@ static void wpa_driver_nl80211_deinit(vo
  94. netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
  95. netlink_deinit(drv->netlink);
  96. +#ifdef CONFIG_RFKILL
  97. rfkill_deinit(drv->rfkill);
  98. +#endif
  99. eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
  100. @@ -5631,7 +5649,9 @@ static void *i802_init(struct hostapd_da
  101. failed:
  102. nl80211_remove_monitor_interface(drv);
  103. +#ifdef CONFIG_RFKILL
  104. rfkill_deinit(drv->rfkill);
  105. +#endif
  106. netlink_deinit(drv->netlink);
  107. if (drv->ioctl_sock >= 0)
  108. close(drv->ioctl_sock);
  109. --- a/src/drivers/driver_wext.c
  110. +++ b/src/drivers/driver_wext.c
  111. @@ -702,7 +702,7 @@ static void wpa_driver_wext_event_rtm_de
  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. static void wext_get_phy_name(struct wpa_driver_wext_data *drv)
  126. {
  127. @@ -770,7 +770,9 @@ void * wpa_driver_wext_init(void *ctx, c
  128. {
  129. struct wpa_driver_wext_data *drv;
  130. struct netlink_config *cfg;
  131. +#ifdef CONFIG_RFKILL
  132. struct rfkill_config *rcfg;
  133. +#endif
  134. char path[128];
  135. struct stat buf;
  136. @@ -805,6 +807,7 @@ void * wpa_driver_wext_init(void *ctx, c
  137. goto err2;
  138. }
  139. +#ifdef CONFIG_RFKILL
  140. rcfg = os_zalloc(sizeof(*rcfg));
  141. if (rcfg == NULL)
  142. goto err3;
  143. @@ -817,6 +820,7 @@ void * wpa_driver_wext_init(void *ctx, c
  144. wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
  145. os_free(rcfg);
  146. }
  147. +#endif /* CONFIG_RFKILL */
  148. drv->mlme_sock = -1;
  149. @@ -828,7 +832,9 @@ void * wpa_driver_wext_init(void *ctx, c
  150. return drv;
  151. err3:
  152. +#ifdef CONFIG_RFKILL
  153. rfkill_deinit(drv->rfkill);
  154. +#endif
  155. netlink_deinit(drv->netlink);
  156. err2:
  157. close(drv->ioctl_sock);
  158. @@ -838,10 +844,12 @@ err1:
  159. }
  160. +#ifdef CONFIG_RFKILL
  161. static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
  162. {
  163. wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
  164. }
  165. +#endif /* CONFIG_RFKILL */
  166. static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
  167. @@ -849,13 +857,16 @@ static int wpa_driver_wext_finish_drv_in
  168. int send_rfkill_event = 0;
  169. if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
  170. +#ifdef CONFIG_RFKILL
  171. if (rfkill_is_blocked(drv->rfkill)) {
  172. wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
  173. "interface '%s' due to rfkill",
  174. drv->ifname);
  175. drv->if_disabled = 1;
  176. send_rfkill_event = 1;
  177. - } else {
  178. + } else
  179. +#endif
  180. + {
  181. wpa_printf(MSG_ERROR, "WEXT: Could not set "
  182. "interface '%s' UP", drv->ifname);
  183. return -1;
  184. @@ -903,8 +914,10 @@ static int wpa_driver_wext_finish_drv_in
  185. 1, IF_OPER_DORMANT);
  186. if (send_rfkill_event) {
  187. +#ifdef CONFIG_RFKILL
  188. eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
  189. drv, drv->ctx);
  190. +#endif
  191. }
  192. return 0;
  193. @@ -934,7 +947,9 @@ void wpa_driver_wext_deinit(void *priv)
  194. netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
  195. netlink_deinit(drv->netlink);
  196. +#ifdef CONFIG_RFKILL
  197. rfkill_deinit(drv->rfkill);
  198. +#endif
  199. if (drv->mlme_sock >= 0)
  200. eloop_unregister_read_sock(drv->mlme_sock);
  201. --- a/src/drivers/drivers.mak
  202. +++ b/src/drivers/drivers.mak
  203. @@ -43,7 +43,6 @@ NEED_SME=y
  204. NEED_AP_MLME=y
  205. NEED_NETLINK=y
  206. NEED_LINUX_IOCTL=y
  207. -NEED_RFKILL=y
  208. ifdef CONFIG_LIBNL_TINY
  209. DRV_LIBS += -lnl-tiny
  210. else
  211. @@ -94,7 +93,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
  212. CONFIG_WIRELESS_EXTENSION=y
  213. NEED_NETLINK=y
  214. NEED_LINUX_IOCTL=y
  215. -NEED_RFKILL=y
  216. endif
  217. ifdef CONFIG_DRIVER_HERMES
  218. @@ -170,7 +168,6 @@ endif
  219. ifdef CONFIG_WIRELESS_EXTENSION
  220. DRV_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
  221. DRV_OBJS += ../src/drivers/driver_wext.o
  222. -NEED_RFKILL=y
  223. endif
  224. ifdef NEED_NETLINK
  225. @@ -183,6 +180,7 @@ endif
  226. ifdef NEED_RFKILL
  227. DRV_OBJS += ../src/drivers/rfkill.o
  228. +DRV_WPA_CFLAGS += -DCONFIG_RFKILL
  229. endif
  230. --- a/src/drivers/driver_wext.h
  231. +++ b/src/drivers/driver_wext.h
  232. @@ -28,7 +28,9 @@ struct wpa_driver_wext_data {
  233. int ifindex2;
  234. int if_removed;
  235. int if_disabled;
  236. +#ifdef CONFIG_RFKILL
  237. struct rfkill_data *rfkill;
  238. +#endif
  239. u8 *assoc_req_ies;
  240. size_t assoc_req_ies_len;
  241. u8 *assoc_resp_ies;