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. #include "hostapd.h"
  18. #ifndef CONFIG_NO_HOSTAPD_LOGGER
  19. static const char * mlme_auth_alg_str(int alg)
  20. {
  21. switch (alg) {
  22. case WLAN_AUTH_OPEN:
  23. return "OPEN_SYSTEM";
  24. case WLAN_AUTH_SHARED_KEY:
  25. return "SHARED_KEY";
  26. case WLAN_AUTH_FT:
  27. return "FT";
  28. }
  29. return "unknown";
  30. }
  31. #endif /* CONFIG_NO_HOSTAPD_LOGGER */
  32. /**
  33. * mlme_authenticate_indication - Report the establishment of an authentication
  34. * relationship with a specific peer MAC entity
  35. * @hapd: BSS data
  36. * @sta: peer STA data
  37. *
  38. * MLME calls this function as a result of the establishment of an
  39. * authentication relationship with a specific peer MAC entity that
  40. * resulted from an authentication procedure that was initiated by
  41. * that specific peer MAC entity.
  42. *
  43. * PeerSTAAddress = sta->addr
  44. * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY)
  45. */
  46. void mlme_authenticate_indication(struct hostapd_data *hapd,
  47. struct sta_info *sta)
  48. {
  49. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
  50. HOSTAPD_LEVEL_DEBUG,
  51. "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
  52. MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
  53. if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP))
  54. mlme_deletekeys_request(hapd, sta);
  55. }
  56. /**
  57. * mlme_deauthenticate_indication - Report the invalidation of an
  58. * authentication relationship with a specific peer MAC entity
  59. * @hapd: BSS data
  60. * @sta: Peer STA data
  61. * @reason_code: ReasonCode from Deauthentication frame
  62. *
  63. * MLME calls this function as a result of the invalidation of an
  64. * authentication relationship with a specific peer MAC entity.
  65. *
  66. * PeerSTAAddress = sta->addr
  67. */
  68. void mlme_deauthenticate_indication(struct hostapd_data *hapd,
  69. struct sta_info *sta, u16 reason_code)
  70. {
  71. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
  72. HOSTAPD_LEVEL_DEBUG,
  73. "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
  74. MAC2STR(sta->addr), reason_code);
  75. if (!hapd->iface->driver_ap_teardown)
  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. 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. }