mlme.c 5.3 KB

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