ap_mlme.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * hostapd / IEEE 802.11 MLME
  3. * Copyright 2003-2006, Jouni Malinen <j@w1.fi>
  4. * Copyright 2003-2004, Instant802 Networks, Inc.
  5. * Copyright 2005-2006, Devicescape Software, Inc.
  6. *
  7. * This software may be distributed under the terms of the BSD license.
  8. * See README for more details.
  9. */
  10. #include "utils/includes.h"
  11. #include "utils/common.h"
  12. #include "common/ieee802_11_defs.h"
  13. #include "ieee802_11.h"
  14. #include "wpa_auth.h"
  15. #include "sta_info.h"
  16. #include "ap_mlme.h"
  17. #include "hostapd.h"
  18. #ifndef CONFIG_NO_HOSTAPD_LOGGER
  19. static const char * mlme_auth_alg_str(int alg)
  20. {
  21. switch (alg) {
  22. case WLAN_AUTH_OPEN:
  23. return "OPEN_SYSTEM";
  24. case WLAN_AUTH_SHARED_KEY:
  25. return "SHARED_KEY";
  26. case WLAN_AUTH_FT:
  27. return "FT";
  28. }
  29. return "unknown";
  30. }
  31. #endif /* CONFIG_NO_HOSTAPD_LOGGER */
  32. /**
  33. * mlme_authenticate_indication - Report the establishment of an authentication
  34. * relationship with a specific peer MAC entity
  35. * @hapd: BSS data
  36. * @sta: peer STA data
  37. *
  38. * MLME calls this function as a result of the establishment of an
  39. * authentication relationship with a specific peer MAC entity that
  40. * resulted from an authentication procedure that was initiated by
  41. * that specific peer MAC entity.
  42. *
  43. * PeerSTAAddress = sta->addr
  44. * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY)
  45. */
  46. void mlme_authenticate_indication(struct hostapd_data *hapd,
  47. struct sta_info *sta)
  48. {
  49. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
  50. HOSTAPD_LEVEL_DEBUG,
  51. "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
  52. MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
  53. if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP))
  54. mlme_deletekeys_request(hapd, sta);
  55. ap_sta_clear_disconnect_timeouts(hapd, sta);
  56. }
  57. /**
  58. * mlme_deauthenticate_indication - Report the invalidation of an
  59. * authentication relationship with a specific peer MAC entity
  60. * @hapd: BSS data
  61. * @sta: Peer STA data
  62. * @reason_code: ReasonCode from Deauthentication frame
  63. *
  64. * MLME calls this function as a result of the invalidation of an
  65. * authentication relationship with a specific peer MAC entity.
  66. *
  67. * PeerSTAAddress = sta->addr
  68. */
  69. void mlme_deauthenticate_indication(struct hostapd_data *hapd,
  70. struct sta_info *sta, u16 reason_code)
  71. {
  72. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
  73. HOSTAPD_LEVEL_DEBUG,
  74. "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
  75. MAC2STR(sta->addr), reason_code);
  76. if (!hapd->iface->driver_ap_teardown)
  77. mlme_deletekeys_request(hapd, sta);
  78. }
  79. /**
  80. * mlme_associate_indication - Report the establishment of an association with
  81. * a specific peer MAC entity
  82. * @hapd: BSS data
  83. * @sta: peer STA data
  84. *
  85. * MLME calls this function as a result of the establishment of an
  86. * association with a specific peer MAC entity that resulted from an
  87. * association procedure that was initiated by that specific peer MAC entity.
  88. *
  89. * PeerSTAAddress = sta->addr
  90. */
  91. void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
  92. {
  93. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
  94. HOSTAPD_LEVEL_DEBUG,
  95. "MLME-ASSOCIATE.indication(" MACSTR ")",
  96. MAC2STR(sta->addr));
  97. if (sta->auth_alg != WLAN_AUTH_FT)
  98. mlme_deletekeys_request(hapd, sta);
  99. ap_sta_clear_disconnect_timeouts(hapd, sta);
  100. }
  101. /**
  102. * mlme_reassociate_indication - Report the establishment of an reassociation
  103. * with a specific peer MAC entity
  104. * @hapd: BSS data
  105. * @sta: peer STA data
  106. *
  107. * MLME calls this function as a result of the establishment of an
  108. * reassociation with a specific peer MAC entity that resulted from a
  109. * reassociation procedure that was initiated by that specific peer MAC entity.
  110. *
  111. * PeerSTAAddress = sta->addr
  112. */
  113. void mlme_reassociate_indication(struct hostapd_data *hapd,
  114. struct sta_info *sta)
  115. {
  116. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
  117. HOSTAPD_LEVEL_DEBUG,
  118. "MLME-REASSOCIATE.indication(" MACSTR ")",
  119. MAC2STR(sta->addr));
  120. if (sta->auth_alg != WLAN_AUTH_FT)
  121. mlme_deletekeys_request(hapd, sta);
  122. ap_sta_clear_disconnect_timeouts(hapd, sta);
  123. }
  124. /**
  125. * mlme_disassociate_indication - Report disassociation with a specific peer
  126. * MAC entity
  127. * @hapd: BSS data
  128. * @sta: Peer STA data
  129. * @reason_code: ReasonCode from Disassociation frame
  130. *
  131. * MLME calls this function as a result of the invalidation of an association
  132. * relationship with a specific peer MAC entity.
  133. *
  134. * PeerSTAAddress = sta->addr
  135. */
  136. void mlme_disassociate_indication(struct hostapd_data *hapd,
  137. struct sta_info *sta, u16 reason_code)
  138. {
  139. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
  140. HOSTAPD_LEVEL_DEBUG,
  141. "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
  142. MAC2STR(sta->addr), reason_code);
  143. mlme_deletekeys_request(hapd, sta);
  144. }
  145. void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
  146. const u8 *addr)
  147. {
  148. hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
  149. HOSTAPD_LEVEL_DEBUG,
  150. "MLME-MichaelMICFailure.indication(" MACSTR ")",
  151. MAC2STR(addr));
  152. }
  153. void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
  154. {
  155. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
  156. HOSTAPD_LEVEL_DEBUG,
  157. "MLME-DELETEKEYS.request(" MACSTR ")",
  158. MAC2STR(sta->addr));
  159. if (sta->wpa_sm)
  160. wpa_remove_ptk(sta->wpa_sm);
  161. }