ocb.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 (WARN_ON(!setup->chandef.chan))
  28. return -EINVAL;
  29. err = rdev_join_ocb(rdev, dev, setup);
  30. if (!err)
  31. wdev->chandef = setup->chandef;
  32. return err;
  33. }
  34. int cfg80211_join_ocb(struct cfg80211_registered_device *rdev,
  35. struct net_device *dev,
  36. struct ocb_setup *setup)
  37. {
  38. struct wireless_dev *wdev = dev->ieee80211_ptr;
  39. int err;
  40. wdev_lock(wdev);
  41. err = __cfg80211_join_ocb(rdev, dev, setup);
  42. wdev_unlock(wdev);
  43. return err;
  44. }
  45. int __cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,
  46. struct net_device *dev)
  47. {
  48. struct wireless_dev *wdev = dev->ieee80211_ptr;
  49. int err;
  50. ASSERT_WDEV_LOCK(wdev);
  51. if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_OCB)
  52. return -EOPNOTSUPP;
  53. if (!rdev->ops->leave_ocb)
  54. return -EOPNOTSUPP;
  55. err = rdev_leave_ocb(rdev, dev);
  56. if (!err)
  57. memset(&wdev->chandef, 0, sizeof(wdev->chandef));
  58. return err;
  59. }
  60. int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,
  61. struct net_device *dev)
  62. {
  63. struct wireless_dev *wdev = dev->ieee80211_ptr;
  64. int err;
  65. wdev_lock(wdev);
  66. err = __cfg80211_leave_ocb(rdev, dev);
  67. wdev_unlock(wdev);
  68. return err;
  69. }