mlme.c 5.3 KB

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