You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ap_mlme.c 5.3KB

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