2 * MAC commands interface
4 * Copyright 2007-2012 Siemens AG
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.
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.
16 * Sergey Lapin <slapin@ossfans.org>
17 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
18 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
21 #include <linux/skbuff.h>
22 #include <linux/if_arp.h>
24 #include <net/ieee802154.h>
25 #include <net/ieee802154_netdev.h>
26 #include <net/wpan-phy.h>
27 #include <net/mac802154.h>
28 #include <net/nl802154.h>
30 #include "mac802154.h"
32 static int mac802154_mlme_start_req(struct net_device
*dev
,
33 struct ieee802154_addr
*addr
,
35 u8 bcn_ord
, u8 sf_ord
,
39 struct ieee802154_mlme_ops
*ops
= ieee802154_mlme_ops(dev
);
42 BUG_ON(addr
->mode
!= IEEE802154_ADDR_SHORT
);
44 mac802154_dev_set_pan_id(dev
, addr
->pan_id
);
45 mac802154_dev_set_short_addr(dev
, addr
->short_addr
);
46 mac802154_dev_set_ieee_addr(dev
);
47 mac802154_dev_set_page_channel(dev
, page
, channel
);
50 struct ieee802154_llsec_params params
;
53 params
.coord_shortaddr
= addr
->short_addr
;
54 changed
|= IEEE802154_LLSEC_PARAM_COORD_SHORTADDR
;
56 params
.pan_id
= addr
->pan_id
;
57 changed
|= IEEE802154_LLSEC_PARAM_PAN_ID
;
59 params
.hwaddr
= ieee802154_devaddr_from_raw(dev
->dev_addr
);
60 changed
|= IEEE802154_LLSEC_PARAM_HWADDR
;
62 params
.coord_hwaddr
= params
.hwaddr
;
63 changed
|= IEEE802154_LLSEC_PARAM_COORD_HWADDR
;
65 rc
= ops
->llsec
->set_params(dev
, ¶ms
, changed
);
68 /* FIXME: add validation for unused parameters to be sane
71 ieee802154_nl_start_confirm(dev
, IEEE802154_SUCCESS
);
76 static struct wpan_phy
*mac802154_get_phy(const struct net_device
*dev
)
78 struct mac802154_sub_if_data
*priv
= netdev_priv(dev
);
80 BUG_ON(dev
->type
!= ARPHRD_IEEE802154
);
82 return to_phy(get_device(&priv
->hw
->phy
->dev
));
85 static struct ieee802154_llsec_ops mac802154_llsec_ops
= {
86 .get_params
= mac802154_get_params
,
87 .set_params
= mac802154_set_params
,
88 .add_key
= mac802154_add_key
,
89 .del_key
= mac802154_del_key
,
90 .add_dev
= mac802154_add_dev
,
91 .del_dev
= mac802154_del_dev
,
92 .add_devkey
= mac802154_add_devkey
,
93 .del_devkey
= mac802154_del_devkey
,
94 .add_seclevel
= mac802154_add_seclevel
,
95 .del_seclevel
= mac802154_del_seclevel
,
96 .lock_table
= mac802154_lock_table
,
97 .get_table
= mac802154_get_table
,
98 .unlock_table
= mac802154_unlock_table
,
101 struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced
= {
102 .get_phy
= mac802154_get_phy
,
105 struct ieee802154_mlme_ops mac802154_mlme_wpan
= {
106 .get_phy
= mac802154_get_phy
,
107 .start_req
= mac802154_mlme_start_req
,
108 .get_pan_id
= mac802154_dev_get_pan_id
,
109 .get_short_addr
= mac802154_dev_get_short_addr
,
110 .get_dsn
= mac802154_dev_get_dsn
,
112 .llsec
= &mac802154_llsec_ops
,
114 .set_mac_params
= mac802154_set_mac_params
,
115 .get_mac_params
= mac802154_get_mac_params
,