ocb.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * OCB mode implementation
  3. *
  4. * Copyright: (c) 2014 Czech Technical University in Prague
  5. * (c) 2014 Volkswagen Group Research
  6. * Author: Rostislav Lisovy <rostislav.lisovy@fel.cvut.cz>
  7. * Funded by: Volkswagen Group Research
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/ieee80211.h>
  14. #include <net/cfg80211.h>
  15. #include "nl80211.h"
  16. #include "core.h"
  17. #include "rdev-ops.h"
  18. int __cfg80211_join_ocb(struct cfg80211_registered_device *rdev,
  19. struct net_device *dev,
  20. struct ocb_setup *setup)
  21. {
  22. struct wireless_dev *wdev = dev->ieee80211_ptr;
  23. int err;
  24. ASSERT_WDEV_LOCK(wdev);
  25. if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_OCB)
  26. return -EOPNOTSUPP;
  27. if (!rdev->ops->join_ocb)
  28. return -EOPNOTSUPP;
  29. if (WARN_ON(!setup->chandef.chan))
  30. return -EINVAL;
  31. err = rdev_join_ocb(rdev, dev, setup);
  32. if (!err)
  33. wdev->chandef = setup->chandef;
  34. return err;
  35. }
  36. int cfg80211_join_ocb(struct cfg80211_registered_device *rdev,
  37. struct net_device *dev,
  38. struct ocb_setup *setup)
  39. {
  40. struct wireless_dev *wdev = dev->ieee80211_ptr;
  41. int err;
  42. wdev_lock(wdev);
  43. err = __cfg80211_join_ocb(rdev, dev, setup);
  44. wdev_unlock(wdev);
  45. return err;
  46. }
  47. int __cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,
  48. struct net_device *dev)
  49. {
  50. struct wireless_dev *wdev = dev->ieee80211_ptr;
  51. int err;
  52. ASSERT_WDEV_LOCK(wdev);
  53. if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_OCB)
  54. return -EOPNOTSUPP;
  55. if (!rdev->ops->leave_ocb)
  56. return -EOPNOTSUPP;
  57. err = rdev_leave_ocb(rdev, dev);
  58. if (!err)
  59. memset(&wdev->chandef, 0, sizeof(wdev->chandef));
  60. return err;
  61. }
  62. int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,
  63. struct net_device *dev)
  64. {
  65. struct wireless_dev *wdev = dev->ieee80211_ptr;
  66. int err;
  67. wdev_lock(wdev);
  68. err = __cfg80211_leave_ocb(rdev, dev);
  69. wdev_unlock(wdev);
  70. return err;
  71. }