f2fs: enable fast symlink by utilizing inline data
[linux/fpc-iii.git] / net / mac802154 / llsec.h
blob950578e1d7bebab7636aae278af3964140ec94e1
1 /*
2 * Copyright (C) 2014 Fraunhofer ITWM
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * Written by:
14 * Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
17 #ifndef MAC802154_LLSEC_H
18 #define MAC802154_LLSEC_H
20 #include <linux/slab.h>
21 #include <linux/hashtable.h>
22 #include <linux/crypto.h>
23 #include <linux/kref.h>
24 #include <linux/spinlock.h>
25 #include <net/af_ieee802154.h>
26 #include <net/ieee802154_netdev.h>
28 struct mac802154_llsec_key {
29 struct ieee802154_llsec_key key;
31 /* one tfm for each authsize (4/8/16) */
32 struct crypto_aead *tfm[3];
33 struct crypto_blkcipher *tfm0;
35 struct kref ref;
38 struct mac802154_llsec_device_key {
39 struct ieee802154_llsec_device_key devkey;
41 struct rcu_head rcu;
44 struct mac802154_llsec_device {
45 struct ieee802154_llsec_device dev;
47 struct hlist_node bucket_s;
48 struct hlist_node bucket_hw;
50 /* protects dev.frame_counter and the elements of dev.keys */
51 spinlock_t lock;
53 struct rcu_head rcu;
56 struct mac802154_llsec_seclevel {
57 struct ieee802154_llsec_seclevel level;
59 struct rcu_head rcu;
62 struct mac802154_llsec {
63 struct ieee802154_llsec_params params;
64 struct ieee802154_llsec_table table;
66 DECLARE_HASHTABLE(devices_short, 6);
67 DECLARE_HASHTABLE(devices_hw, 6);
69 /* protects params, all other fields are fine with RCU */
70 rwlock_t lock;
73 void mac802154_llsec_init(struct mac802154_llsec *sec);
74 void mac802154_llsec_destroy(struct mac802154_llsec *sec);
76 int mac802154_llsec_get_params(struct mac802154_llsec *sec,
77 struct ieee802154_llsec_params *params);
78 int mac802154_llsec_set_params(struct mac802154_llsec *sec,
79 const struct ieee802154_llsec_params *params,
80 int changed);
82 int mac802154_llsec_key_add(struct mac802154_llsec *sec,
83 const struct ieee802154_llsec_key_id *id,
84 const struct ieee802154_llsec_key *key);
85 int mac802154_llsec_key_del(struct mac802154_llsec *sec,
86 const struct ieee802154_llsec_key_id *key);
88 int mac802154_llsec_dev_add(struct mac802154_llsec *sec,
89 const struct ieee802154_llsec_device *dev);
90 int mac802154_llsec_dev_del(struct mac802154_llsec *sec,
91 __le64 device_addr);
93 int mac802154_llsec_devkey_add(struct mac802154_llsec *sec,
94 __le64 dev_addr,
95 const struct ieee802154_llsec_device_key *key);
96 int mac802154_llsec_devkey_del(struct mac802154_llsec *sec,
97 __le64 dev_addr,
98 const struct ieee802154_llsec_device_key *key);
100 int mac802154_llsec_seclevel_add(struct mac802154_llsec *sec,
101 const struct ieee802154_llsec_seclevel *sl);
102 int mac802154_llsec_seclevel_del(struct mac802154_llsec *sec,
103 const struct ieee802154_llsec_seclevel *sl);
105 int mac802154_llsec_encrypt(struct mac802154_llsec *sec, struct sk_buff *skb);
106 int mac802154_llsec_decrypt(struct mac802154_llsec *sec, struct sk_buff *skb);
108 #endif /* MAC802154_LLSEC_H */