mlme.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * cfg80211 MLME SAP interface
  3. *
  4. * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/netdevice.h>
  9. #include <linux/nl80211.h>
  10. #include <net/cfg80211.h>
  11. #include "core.h"
  12. #include "nl80211.h"
  13. void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len)
  14. {
  15. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  16. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  17. nl80211_send_rx_auth(rdev, dev, buf, len);
  18. }
  19. EXPORT_SYMBOL(cfg80211_send_rx_auth);
  20. void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len)
  21. {
  22. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  23. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  24. nl80211_send_rx_assoc(rdev, dev, buf, len);
  25. }
  26. EXPORT_SYMBOL(cfg80211_send_rx_assoc);
  27. void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len)
  28. {
  29. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  30. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  31. nl80211_send_deauth(rdev, dev, buf, len);
  32. }
  33. EXPORT_SYMBOL(cfg80211_send_deauth);
  34. void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len)
  35. {
  36. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  37. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  38. nl80211_send_disassoc(rdev, dev, buf, len);
  39. }
  40. EXPORT_SYMBOL(cfg80211_send_disassoc);
  41. static void cfg80211_wext_disconnected(struct net_device *dev)
  42. {
  43. #ifdef CONFIG_WIRELESS_EXT
  44. union iwreq_data wrqu;
  45. memset(&wrqu, 0, sizeof(wrqu));
  46. wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
  47. #endif
  48. }
  49. void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
  50. {
  51. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  52. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  53. nl80211_send_auth_timeout(rdev, dev, addr);
  54. cfg80211_wext_disconnected(dev);
  55. }
  56. EXPORT_SYMBOL(cfg80211_send_auth_timeout);
  57. void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr)
  58. {
  59. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  60. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  61. nl80211_send_assoc_timeout(rdev, dev, addr);
  62. cfg80211_wext_disconnected(dev);
  63. }
  64. EXPORT_SYMBOL(cfg80211_send_assoc_timeout);
  65. void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
  66. enum nl80211_key_type key_type, int key_id,
  67. const u8 *tsc)
  68. {
  69. struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
  70. struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  71. #ifdef CONFIG_WIRELESS_EXT
  72. union iwreq_data wrqu;
  73. char *buf = kmalloc(128, GFP_ATOMIC);
  74. if (buf) {
  75. sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
  76. "keyid=%d %scast addr=%pM)", key_id,
  77. key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
  78. addr);
  79. memset(&wrqu, 0, sizeof(wrqu));
  80. wrqu.data.length = strlen(buf);
  81. wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
  82. kfree(buf);
  83. }
  84. #endif
  85. nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc);
  86. }
  87. EXPORT_SYMBOL(cfg80211_michael_mic_failure);