aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>2014-05-16 11:46:42 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-16 17:23:41 -0400
commit29e023746a672e4ff702ca9dc63a06145fd8f4b0 (patch)
tree1716d0a86dcf6acb665178a44c9c5ef211e3813b
parentaf9eed5bbf0fb4e398081e79a707545dcca5ebda (diff)
mac802154: add llsec configuration functions
Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/ieee802154_netdev.h36
-rw-r--r--net/mac802154/mac802154.h33
-rw-r--r--net/mac802154/mac_cmd.c18
-rw-r--r--net/mac802154/mib.c187
4 files changed, 274 insertions, 0 deletions
diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h
index 000c8552d5de..eb9f850a51b6 100644
--- a/include/net/ieee802154_netdev.h
+++ b/include/net/ieee802154_netdev.h
@@ -358,6 +358,40 @@ enum {
358 IEEE802154_LLSEC_PARAM_COORD_SHORTADDR = 1 << 8, 358 IEEE802154_LLSEC_PARAM_COORD_SHORTADDR = 1 << 8,
359}; 359};
360 360
361struct ieee802154_llsec_ops {
362 int (*get_params)(struct net_device *dev,
363 struct ieee802154_llsec_params *params);
364 int (*set_params)(struct net_device *dev,
365 const struct ieee802154_llsec_params *params,
366 int changed);
367
368 int (*add_key)(struct net_device *dev,
369 const struct ieee802154_llsec_key_id *id,
370 const struct ieee802154_llsec_key *key);
371 int (*del_key)(struct net_device *dev,
372 const struct ieee802154_llsec_key_id *id);
373
374 int (*add_dev)(struct net_device *dev,
375 const struct ieee802154_llsec_device *llsec_dev);
376 int (*del_dev)(struct net_device *dev, __le64 dev_addr);
377
378 int (*add_devkey)(struct net_device *dev,
379 __le64 device_addr,
380 const struct ieee802154_llsec_device_key *key);
381 int (*del_devkey)(struct net_device *dev,
382 __le64 device_addr,
383 const struct ieee802154_llsec_device_key *key);
384
385 int (*add_seclevel)(struct net_device *dev,
386 const struct ieee802154_llsec_seclevel *sl);
387 int (*del_seclevel)(struct net_device *dev,
388 const struct ieee802154_llsec_seclevel *sl);
389
390 void (*lock_table)(struct net_device *dev);
391 void (*get_table)(struct net_device *dev,
392 struct ieee802154_llsec_table **t);
393 void (*unlock_table)(struct net_device *dev);
394};
361/* 395/*
362 * This should be located at net_device->ml_priv 396 * This should be located at net_device->ml_priv
363 * 397 *
@@ -388,6 +422,8 @@ struct ieee802154_mlme_ops {
388 void (*get_mac_params)(struct net_device *dev, 422 void (*get_mac_params)(struct net_device *dev,
389 struct ieee802154_mac_params *params); 423 struct ieee802154_mac_params *params);
390 424
425 struct ieee802154_llsec_ops *llsec;
426
391 /* The fields below are required. */ 427 /* The fields below are required. */
392 428
393 struct wpan_phy *(*get_phy)(const struct net_device *dev); 429 struct wpan_phy *(*get_phy)(const struct net_device *dev);
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index a8d7cbc701a0..762a6f849c6b 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -136,4 +136,37 @@ int mac802154_set_mac_params(struct net_device *dev,
136void mac802154_get_mac_params(struct net_device *dev, 136void mac802154_get_mac_params(struct net_device *dev,
137 struct ieee802154_mac_params *params); 137 struct ieee802154_mac_params *params);
138 138
139int mac802154_get_params(struct net_device *dev,
140 struct ieee802154_llsec_params *params);
141int mac802154_set_params(struct net_device *dev,
142 const struct ieee802154_llsec_params *params,
143 int changed);
144
145int mac802154_add_key(struct net_device *dev,
146 const struct ieee802154_llsec_key_id *id,
147 const struct ieee802154_llsec_key *key);
148int mac802154_del_key(struct net_device *dev,
149 const struct ieee802154_llsec_key_id *id);
150
151int mac802154_add_dev(struct net_device *dev,
152 const struct ieee802154_llsec_device *llsec_dev);
153int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
154
155int mac802154_add_devkey(struct net_device *dev,
156 __le64 device_addr,
157 const struct ieee802154_llsec_device_key *key);
158int mac802154_del_devkey(struct net_device *dev,
159 __le64 device_addr,
160 const struct ieee802154_llsec_device_key *key);
161
162int mac802154_add_seclevel(struct net_device *dev,
163 const struct ieee802154_llsec_seclevel *sl);
164int mac802154_del_seclevel(struct net_device *dev,
165 const struct ieee802154_llsec_seclevel *sl);
166
167void mac802154_lock_table(struct net_device *dev);
168void mac802154_get_table(struct net_device *dev,
169 struct ieee802154_llsec_table **t);
170void mac802154_unlock_table(struct net_device *dev);
171
139#endif /* MAC802154_H */ 172#endif /* MAC802154_H */
diff --git a/net/mac802154/mac_cmd.c b/net/mac802154/mac_cmd.c
index d40c0928bc62..afb4e2cbc00a 100644
--- a/net/mac802154/mac_cmd.c
+++ b/net/mac802154/mac_cmd.c
@@ -64,6 +64,22 @@ static struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
64 return to_phy(get_device(&priv->hw->phy->dev)); 64 return to_phy(get_device(&priv->hw->phy->dev));
65} 65}
66 66
67static struct ieee802154_llsec_ops mac802154_llsec_ops = {
68 .get_params = mac802154_get_params,
69 .set_params = mac802154_set_params,
70 .add_key = mac802154_add_key,
71 .del_key = mac802154_del_key,
72 .add_dev = mac802154_add_dev,
73 .del_dev = mac802154_del_dev,
74 .add_devkey = mac802154_add_devkey,
75 .del_devkey = mac802154_del_devkey,
76 .add_seclevel = mac802154_add_seclevel,
77 .del_seclevel = mac802154_del_seclevel,
78 .lock_table = mac802154_lock_table,
79 .get_table = mac802154_get_table,
80 .unlock_table = mac802154_unlock_table,
81};
82
67struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced = { 83struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced = {
68 .get_phy = mac802154_get_phy, 84 .get_phy = mac802154_get_phy,
69}; 85};
@@ -75,6 +91,8 @@ struct ieee802154_mlme_ops mac802154_mlme_wpan = {
75 .get_short_addr = mac802154_dev_get_short_addr, 91 .get_short_addr = mac802154_dev_get_short_addr,
76 .get_dsn = mac802154_dev_get_dsn, 92 .get_dsn = mac802154_dev_get_dsn,
77 93
94 .llsec = &mac802154_llsec_ops,
95
78 .set_mac_params = mac802154_set_mac_params, 96 .set_mac_params = mac802154_set_mac_params,
79 .get_mac_params = mac802154_get_mac_params, 97 .get_mac_params = mac802154_get_mac_params,
80}; 98};
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
index f0991f2344d4..15aa2f2b03a7 100644
--- a/net/mac802154/mib.c
+++ b/net/mac802154/mib.c
@@ -213,3 +213,190 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
213 } else 213 } else
214 mutex_unlock(&priv->hw->phy->pib_lock); 214 mutex_unlock(&priv->hw->phy->pib_lock);
215} 215}
216
217
218int mac802154_get_params(struct net_device *dev,
219 struct ieee802154_llsec_params *params)
220{
221 struct mac802154_sub_if_data *priv = netdev_priv(dev);
222 int res;
223
224 BUG_ON(dev->type != ARPHRD_IEEE802154);
225
226 mutex_lock(&priv->sec_mtx);
227 res = mac802154_llsec_get_params(&priv->sec, params);
228 mutex_unlock(&priv->sec_mtx);
229
230 return res;
231}
232
233int mac802154_set_params(struct net_device *dev,
234 const struct ieee802154_llsec_params *params,
235 int changed)
236{
237 struct mac802154_sub_if_data *priv = netdev_priv(dev);
238 int res;
239
240 BUG_ON(dev->type != ARPHRD_IEEE802154);
241
242 mutex_lock(&priv->sec_mtx);
243 res = mac802154_llsec_set_params(&priv->sec, params, changed);
244 mutex_unlock(&priv->sec_mtx);
245
246 return res;
247}
248
249
250int mac802154_add_key(struct net_device *dev,
251 const struct ieee802154_llsec_key_id *id,
252 const struct ieee802154_llsec_key *key)
253{
254 struct mac802154_sub_if_data *priv = netdev_priv(dev);
255 int res;
256
257 BUG_ON(dev->type != ARPHRD_IEEE802154);
258
259 mutex_lock(&priv->sec_mtx);
260 res = mac802154_llsec_key_add(&priv->sec, id, key);
261 mutex_unlock(&priv->sec_mtx);
262
263 return res;
264}
265
266int mac802154_del_key(struct net_device *dev,
267 const struct ieee802154_llsec_key_id *id)
268{
269 struct mac802154_sub_if_data *priv = netdev_priv(dev);
270 int res;
271
272 BUG_ON(dev->type != ARPHRD_IEEE802154);
273
274 mutex_lock(&priv->sec_mtx);
275 res = mac802154_llsec_key_del(&priv->sec, id);
276 mutex_unlock(&priv->sec_mtx);
277
278 return res;
279}
280
281
282int mac802154_add_dev(struct net_device *dev,
283 const struct ieee802154_llsec_device *llsec_dev)
284{
285 struct mac802154_sub_if_data *priv = netdev_priv(dev);
286 int res;
287
288 BUG_ON(dev->type != ARPHRD_IEEE802154);
289
290 mutex_lock(&priv->sec_mtx);
291 res = mac802154_llsec_dev_add(&priv->sec, llsec_dev);
292 mutex_unlock(&priv->sec_mtx);
293
294 return res;
295}
296
297int mac802154_del_dev(struct net_device *dev, __le64 dev_addr)
298{
299 struct mac802154_sub_if_data *priv = netdev_priv(dev);
300 int res;
301
302 BUG_ON(dev->type != ARPHRD_IEEE802154);
303
304 mutex_lock(&priv->sec_mtx);
305 res = mac802154_llsec_dev_del(&priv->sec, dev_addr);
306 mutex_unlock(&priv->sec_mtx);
307
308 return res;
309}
310
311
312int mac802154_add_devkey(struct net_device *dev,
313 __le64 device_addr,
314 const struct ieee802154_llsec_device_key *key)
315{
316 struct mac802154_sub_if_data *priv = netdev_priv(dev);
317 int res;
318
319 BUG_ON(dev->type != ARPHRD_IEEE802154);
320
321 mutex_lock(&priv->sec_mtx);
322 res = mac802154_llsec_devkey_add(&priv->sec, device_addr, key);
323 mutex_unlock(&priv->sec_mtx);
324
325 return res;
326}
327
328int mac802154_del_devkey(struct net_device *dev,
329 __le64 device_addr,
330 const struct ieee802154_llsec_device_key *key)
331{
332 struct mac802154_sub_if_data *priv = netdev_priv(dev);
333 int res;
334
335 BUG_ON(dev->type != ARPHRD_IEEE802154);
336
337 mutex_lock(&priv->sec_mtx);
338 res = mac802154_llsec_devkey_del(&priv->sec, device_addr, key);
339 mutex_unlock(&priv->sec_mtx);
340
341 return res;
342}
343
344
345int mac802154_add_seclevel(struct net_device *dev,
346 const struct ieee802154_llsec_seclevel *sl)
347{
348 struct mac802154_sub_if_data *priv = netdev_priv(dev);
349 int res;
350
351 BUG_ON(dev->type != ARPHRD_IEEE802154);
352
353 mutex_lock(&priv->sec_mtx);
354 res = mac802154_llsec_seclevel_add(&priv->sec, sl);
355 mutex_unlock(&priv->sec_mtx);
356
357 return res;
358}
359
360int mac802154_del_seclevel(struct net_device *dev,
361 const struct ieee802154_llsec_seclevel *sl)
362{
363 struct mac802154_sub_if_data *priv = netdev_priv(dev);
364 int res;
365
366 BUG_ON(dev->type != ARPHRD_IEEE802154);
367
368 mutex_lock(&priv->sec_mtx);
369 res = mac802154_llsec_seclevel_del(&priv->sec, sl);
370 mutex_unlock(&priv->sec_mtx);
371
372 return res;
373}
374
375
376void mac802154_lock_table(struct net_device *dev)
377{
378 struct mac802154_sub_if_data *priv = netdev_priv(dev);
379
380 BUG_ON(dev->type != ARPHRD_IEEE802154);
381
382 mutex_lock(&priv->sec_mtx);
383}
384
385void mac802154_get_table(struct net_device *dev,
386 struct ieee802154_llsec_table **t)
387{
388 struct mac802154_sub_if_data *priv = netdev_priv(dev);
389
390 BUG_ON(dev->type != ARPHRD_IEEE802154);
391
392 *t = &priv->sec.table;
393}
394
395void mac802154_unlock_table(struct net_device *dev)
396{
397 struct mac802154_sub_if_data *priv = netdev_priv(dev);
398
399 BUG_ON(dev->type != ARPHRD_IEEE802154);
400
401 mutex_unlock(&priv->sec_mtx);
402}