ap_mlme.c 5.1 KB

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