mac_cmd.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * MAC commands interface
  3. *
  4. * Copyright 2007-2012 Siemens AG
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * Written by:
  20. * Sergey Lapin <slapin@ossfans.org>
  21. * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
  22. * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
  23. */
  24. #include <linux/skbuff.h>
  25. #include <linux/if_arp.h>
  26. #include <net/ieee802154.h>
  27. #include <net/ieee802154_netdev.h>
  28. #include <net/wpan-phy.h>
  29. #include <net/mac802154.h>
  30. #include <net/nl802154.h>
  31. #include "mac802154.h"
  32. static int mac802154_mlme_start_req(struct net_device *dev,
  33. struct ieee802154_addr *addr,
  34. u8 channel, u8 page,
  35. u8 bcn_ord, u8 sf_ord,
  36. u8 pan_coord, u8 blx,
  37. u8 coord_realign)
  38. {
  39. BUG_ON(addr->addr_type != IEEE802154_ADDR_SHORT);
  40. mac802154_dev_set_pan_id(dev, addr->pan_id);
  41. mac802154_dev_set_short_addr(dev, addr->short_addr);
  42. mac802154_dev_set_ieee_addr(dev);
  43. mac802154_dev_set_page_channel(dev, page, channel);
  44. /* FIXME: add validation for unused parameters to be sane
  45. * for SoftMAC
  46. */
  47. ieee802154_nl_start_confirm(dev, IEEE802154_SUCCESS);
  48. return 0;
  49. }
  50. static struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
  51. {
  52. struct mac802154_sub_if_data *priv = netdev_priv(dev);
  53. BUG_ON(dev->type != ARPHRD_IEEE802154);
  54. return to_phy(get_device(&priv->hw->phy->dev));
  55. }
  56. struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced = {
  57. .get_phy = mac802154_get_phy,
  58. };
  59. struct ieee802154_mlme_ops mac802154_mlme_wpan = {
  60. .get_phy = mac802154_get_phy,
  61. .start_req = mac802154_mlme_start_req,
  62. .get_pan_id = mac802154_dev_get_pan_id,
  63. .get_short_addr = mac802154_dev_get_short_addr,
  64. };