440-optional_rfkill.patch 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. --- a/src/drivers/driver_nl80211.c
  2. +++ b/src/drivers/driver_nl80211.c
  3. @@ -212,7 +212,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. @@ -2768,7 +2770,7 @@ static int wpa_driver_nl80211_init_nl(st
  13. return 0;
  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. @@ -2791,6 +2793,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. @@ -2922,7 +2925,9 @@ static void * wpa_driver_nl80211_init(vo
  27. void *global_priv)
  28. {
  29. struct wpa_driver_nl80211_data *drv;
  30. +#ifdef CONFIG_RFKILL
  31. struct rfkill_config *rcfg;
  32. +#endif
  33. struct i802_bss *bss;
  34. if (global_priv == NULL)
  35. @@ -2956,6 +2961,7 @@ static void * wpa_driver_nl80211_init(vo
  36. nl80211_get_phy_name(drv);
  37. +#ifdef CONFIG_RFKILL
  38. rcfg = os_zalloc(sizeof(*rcfg));
  39. if (rcfg == NULL)
  40. goto failed;
  41. @@ -2968,6 +2974,7 @@ static void * wpa_driver_nl80211_init(vo
  42. wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
  43. os_free(rcfg);
  44. }
  45. +#endif /* CONFIG_RFKILL */
  46. if (wpa_driver_nl80211_finish_drv_init(drv))
  47. goto failed;
  48. @@ -3254,10 +3261,12 @@ static void nl80211_mgmt_unsubscribe(str
  49. }
  50. +#ifdef CONFIG_RFKILL
  51. static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
  52. {
  53. wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
  54. }
  55. +#endif /* CONFIG_RFKILL */
  56. static int
  57. wpa_driver_nl80211_finish_drv_init_sta(struct wpa_driver_nl80211_data *drv,
  58. @@ -3278,13 +3287,16 @@ wpa_driver_nl80211_finish_drv_init_sta(s
  59. }
  60. if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {
  61. +#ifdef CONFIG_RFKILL
  62. if (rfkill_is_blocked(drv->rfkill)) {
  63. wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
  64. "interface '%s' due to rfkill",
  65. bss->ifname);
  66. drv->if_disabled = 1;
  67. *send_rfkill_event = 1;
  68. - } else {
  69. + } else
  70. +#endif
  71. + {
  72. wpa_printf(MSG_ERROR, "nl80211: Could not set "
  73. "interface '%s' UP", bss->ifname);
  74. return -1;
  75. @@ -3315,8 +3327,10 @@ wpa_driver_nl80211_finish_drv_init(struc
  76. return -1;
  77. if (send_rfkill_event) {
  78. +#ifdef CONFIG_RFKILL
  79. eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
  80. drv, drv->ctx);
  81. +#endif
  82. }
  83. return 0;
  84. @@ -3403,7 +3417,9 @@ static void wpa_driver_nl80211_deinit(vo
  85. netlink_send_oper_ifla(drv->global->netlink, drv->ifindex, 0,
  86. IF_OPER_UP);
  87. +#ifdef CONFIG_RFKILL
  88. rfkill_deinit(drv->rfkill);
  89. +#endif
  90. eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
  91. --- a/src/drivers/driver_wext.c
  92. +++ b/src/drivers/driver_wext.c
  93. @@ -742,7 +742,7 @@ static void wpa_driver_wext_event_rtm_de
  94. }
  95. }
  96. -
  97. +#ifdef CONFIG_RFKILL
  98. static void wpa_driver_wext_rfkill_blocked(void *ctx)
  99. {
  100. wpa_printf(MSG_DEBUG, "WEXT: RFKILL blocked");
  101. @@ -764,7 +764,7 @@ static void wpa_driver_wext_rfkill_unblo
  102. }
  103. /* rtnetlink ifup handler will report interface as enabled */
  104. }
  105. -
  106. +#endif /* CONFIG_RFKILL */
  107. static void wext_get_phy_name(struct wpa_driver_wext_data *drv)
  108. {
  109. @@ -810,7 +810,9 @@ void * wpa_driver_wext_init(void *ctx, c
  110. {
  111. struct wpa_driver_wext_data *drv;
  112. struct netlink_config *cfg;
  113. +#ifdef CONFIG_RFKILL
  114. struct rfkill_config *rcfg;
  115. +#endif
  116. char path[128];
  117. struct stat buf;
  118. @@ -845,6 +847,7 @@ void * wpa_driver_wext_init(void *ctx, c
  119. goto err2;
  120. }
  121. +#ifdef CONFIG_RFKILL
  122. rcfg = os_zalloc(sizeof(*rcfg));
  123. if (rcfg == NULL)
  124. goto err3;
  125. @@ -857,6 +860,7 @@ void * wpa_driver_wext_init(void *ctx, c
  126. wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
  127. os_free(rcfg);
  128. }
  129. +#endif /* CONFIG_RFKILL */
  130. drv->mlme_sock = -1;
  131. @@ -874,7 +878,9 @@ void * wpa_driver_wext_init(void *ctx, c
  132. return drv;
  133. err3:
  134. +#ifdef CONFIG_RFKILL
  135. rfkill_deinit(drv->rfkill);
  136. +#endif
  137. netlink_deinit(drv->netlink);
  138. err2:
  139. close(drv->ioctl_sock);
  140. @@ -884,10 +890,12 @@ err1:
  141. }
  142. +#ifdef CONFIG_RFKILL
  143. static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
  144. {
  145. wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
  146. }
  147. +#endif /* CONFIG_RFKILL */
  148. static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
  149. @@ -895,13 +903,16 @@ static int wpa_driver_wext_finish_drv_in
  150. int send_rfkill_event = 0;
  151. if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
  152. +#ifdef CONFIG_RFKILL
  153. if (rfkill_is_blocked(drv->rfkill)) {
  154. wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
  155. "interface '%s' due to rfkill",
  156. drv->ifname);
  157. drv->if_disabled = 1;
  158. send_rfkill_event = 1;
  159. - } else {
  160. + } else
  161. +#endif
  162. + {
  163. wpa_printf(MSG_ERROR, "WEXT: Could not set "
  164. "interface '%s' UP", drv->ifname);
  165. return -1;
  166. @@ -949,8 +960,10 @@ static int wpa_driver_wext_finish_drv_in
  167. 1, IF_OPER_DORMANT);
  168. if (send_rfkill_event) {
  169. +#ifdef CONFIG_RFKILL
  170. eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
  171. drv, drv->ctx);
  172. +#endif
  173. }
  174. return 0;
  175. @@ -980,7 +993,9 @@ void wpa_driver_wext_deinit(void *priv)
  176. netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
  177. netlink_deinit(drv->netlink);
  178. +#ifdef CONFIG_RFKILL
  179. rfkill_deinit(drv->rfkill);
  180. +#endif
  181. if (drv->mlme_sock >= 0)
  182. eloop_unregister_read_sock(drv->mlme_sock);
  183. --- a/src/drivers/drivers.mak
  184. +++ b/src/drivers/drivers.mak
  185. @@ -25,7 +25,6 @@ NEED_SME=y
  186. NEED_AP_MLME=y
  187. NEED_NETLINK=y
  188. NEED_LINUX_IOCTL=y
  189. -NEED_RFKILL=y
  190. ifdef CONFIG_LIBNL32
  191. DRV_LIBS += -lnl-3
  192. @@ -101,7 +100,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
  193. CONFIG_WIRELESS_EXTENSION=y
  194. NEED_NETLINK=y
  195. NEED_LINUX_IOCTL=y
  196. -NEED_RFKILL=y
  197. endif
  198. ifdef CONFIG_DRIVER_NDIS
  199. @@ -127,7 +125,6 @@ endif
  200. ifdef CONFIG_WIRELESS_EXTENSION
  201. DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
  202. DRV_WPA_OBJS += ../src/drivers/driver_wext.o
  203. -NEED_RFKILL=y
  204. endif
  205. ifdef NEED_NETLINK
  206. @@ -140,6 +137,7 @@ endif
  207. ifdef NEED_RFKILL
  208. DRV_OBJS += ../src/drivers/rfkill.o
  209. +DRV_WPA_CFLAGS += -DCONFIG_RFKILL
  210. endif
  211. --- a/src/drivers/driver_wext.h
  212. +++ b/src/drivers/driver_wext.h
  213. @@ -22,7 +22,9 @@ struct wpa_driver_wext_data {
  214. int ifindex2;
  215. int if_removed;
  216. int if_disabled;
  217. +#ifdef CONFIG_RFKILL
  218. struct rfkill_data *rfkill;
  219. +#endif
  220. u8 *assoc_req_ies;
  221. size_t assoc_req_ies_len;
  222. u8 *assoc_resp_ies;