ieee80211_cfg.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * mac80211 configuration hooks for cfg80211
  3. *
  4. * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
  5. *
  6. * This file is GPLv2 as found in COPYING.
  7. */
  8. #include <linux/nl80211.h>
  9. #include <linux/rtnetlink.h>
  10. #include <net/cfg80211.h>
  11. #include "ieee80211_i.h"
  12. #include "ieee80211_cfg.h"
  13. static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
  14. unsigned int type)
  15. {
  16. struct ieee80211_local *local = wiphy_priv(wiphy);
  17. int itype;
  18. if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
  19. return -ENODEV;
  20. switch (type) {
  21. case NL80211_IFTYPE_UNSPECIFIED:
  22. itype = IEEE80211_IF_TYPE_STA;
  23. break;
  24. case NL80211_IFTYPE_ADHOC:
  25. itype = IEEE80211_IF_TYPE_IBSS;
  26. break;
  27. case NL80211_IFTYPE_STATION:
  28. itype = IEEE80211_IF_TYPE_STA;
  29. break;
  30. case NL80211_IFTYPE_MONITOR:
  31. itype = IEEE80211_IF_TYPE_MNTR;
  32. break;
  33. default:
  34. return -EINVAL;
  35. }
  36. return ieee80211_if_add(local->mdev, name, NULL, itype);
  37. }
  38. static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
  39. {
  40. struct ieee80211_local *local = wiphy_priv(wiphy);
  41. struct net_device *dev;
  42. char *name;
  43. if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
  44. return -ENODEV;
  45. dev = dev_get_by_index(ifindex);
  46. if (!dev)
  47. return 0;
  48. name = dev->name;
  49. dev_put(dev);
  50. return ieee80211_if_remove(local->mdev, name, -1);
  51. }
  52. struct cfg80211_ops mac80211_config_ops = {
  53. .add_virtual_intf = ieee80211_add_iface,
  54. .del_virtual_intf = ieee80211_del_iface,
  55. };