mlme.c 5.2 KB

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