ieee80211_cfg.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/net_namespace.h>
  11. #include <net/cfg80211.h>
  12. #include "ieee80211_i.h"
  13. #include "ieee80211_cfg.h"
  14. static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
  15. unsigned int type)
  16. {
  17. struct ieee80211_local *local = wiphy_priv(wiphy);
  18. int itype;
  19. if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
  20. return -ENODEV;
  21. switch (type) {
  22. case NL80211_IFTYPE_UNSPECIFIED:
  23. itype = IEEE80211_IF_TYPE_STA;
  24. break;
  25. case NL80211_IFTYPE_ADHOC:
  26. itype = IEEE80211_IF_TYPE_IBSS;
  27. break;
  28. case NL80211_IFTYPE_STATION:
  29. itype = IEEE80211_IF_TYPE_STA;
  30. break;
  31. case NL80211_IFTYPE_MONITOR:
  32. itype = IEEE80211_IF_TYPE_MNTR;
  33. break;
  34. default:
  35. return -EINVAL;
  36. }
  37. return ieee80211_if_add(local->mdev, name, NULL, itype);
  38. }
  39. static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
  40. {
  41. struct ieee80211_local *local = wiphy_priv(wiphy);
  42. struct net_device *dev;
  43. char *name;
  44. if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
  45. return -ENODEV;
  46. dev = dev_get_by_index(&init_net, ifindex);
  47. if (!dev)
  48. return 0;
  49. name = dev->name;
  50. dev_put(dev);
  51. return ieee80211_if_remove(local->mdev, name, -1);
  52. }
  53. struct cfg80211_ops mac80211_config_ops = {
  54. .add_virtual_intf = ieee80211_add_iface,
  55. .del_virtual_intf = ieee80211_del_iface,
  56. };