2 * WiMedia Logical Link Control Protocol (WLP)
5 * Copyright (C) 2007 Intel Corporation
6 * Reinette Chatre <reinette.chatre@intel.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #ifndef __WLP_INTERNAL_H__
25 #define __WLP_INTERNAL_H__
28 * State of WSS connection
30 * A device needs to connect to a neighbor in an activated WSS before data
31 * can be transmitted. The spec also distinguishes between a new connection
32 * attempt and a connection attempt after previous connection attempts. The
33 * state WLP_WSS_CONNECT_FAILED is used for this scenario. See WLP 0.99
36 enum wlp_wss_connect {
37 WLP_WSS_UNCONNECTED = 0,
39 WLP_WSS_CONNECT_FAILED,
42 extern struct kobj_type wss_ktype;
43 extern struct attribute_group wss_attr_group;
45 extern int uwb_rc_ie_add(struct uwb_rc *, const struct uwb_ie_hdr *, size_t);
46 extern int uwb_rc_ie_rm(struct uwb_rc *, enum uwb_ie);
49 /* This should be changed to a dynamic array where entries are sorted
50 * by eth_addr and search is done in a binary form
52 * Although thinking twice about it: this technologie's maximum reach
53 * is 10 meters...unless you want to pack too much stuff in around
54 * your radio controller/WLP device, the list will probably not be
57 * In any case, there is probably some data structure in the kernel
58 * than we could reused for that already.
60 * The below structure is really just good while we support one WSS per
64 struct list_head list_node;
65 unsigned char eth_addr[ETH_ALEN];
66 struct uwb_dev_addr dev_addr;
68 unsigned char virt_addr[ETH_ALEN];
70 enum wlp_wss_connect state;
73 typedef int (*wlp_eda_for_each_f)(struct wlp *, struct wlp_eda_node *, void *);
75 extern void wlp_eda_init(struct wlp_eda *);
76 extern void wlp_eda_release(struct wlp_eda *);
77 extern int wlp_eda_create_node(struct wlp_eda *,
78 const unsigned char eth_addr[ETH_ALEN],
79 const struct uwb_dev_addr *);
80 extern void wlp_eda_rm_node(struct wlp_eda *, const struct uwb_dev_addr *);
81 extern int wlp_eda_update_node(struct wlp_eda *,
82 const struct uwb_dev_addr *,
84 const unsigned char virt_addr[ETH_ALEN],
85 const u8, const enum wlp_wss_connect);
86 extern int wlp_eda_update_node_state(struct wlp_eda *,
87 const struct uwb_dev_addr *,
88 const enum wlp_wss_connect);
90 extern int wlp_copy_eda_node(struct wlp_eda *, struct uwb_dev_addr *,
91 struct wlp_eda_node *);
92 extern int wlp_eda_for_each(struct wlp_eda *, wlp_eda_for_each_f , void *);
93 extern int wlp_eda_for_virtual(struct wlp_eda *,
94 const unsigned char eth_addr[ETH_ALEN],
95 struct uwb_dev_addr *,
96 wlp_eda_for_each_f , void *);
99 extern void wlp_remove_neighbor_tmp_info(struct wlp_neighbor_e *);
101 extern size_t wlp_wss_key_print(char *, size_t, u8 *);
103 /* Function called when no more references to WSS exists */
104 extern void wlp_wss_release(struct kobject *);
106 extern void wlp_wss_reset(struct wlp_wss *);
107 extern int wlp_wss_create_activate(struct wlp_wss *, struct wlp_uuid *,
108 char *, unsigned, unsigned);
109 extern int wlp_wss_enroll_activate(struct wlp_wss *, struct wlp_uuid *,
110 struct uwb_dev_addr *);
111 extern ssize_t wlp_discover(struct wlp *);
113 extern int wlp_enroll_neighbor(struct wlp *, struct wlp_neighbor_e *,
114 struct wlp_wss *, struct wlp_uuid *);
115 extern int wlp_wss_is_active(struct wlp *, struct wlp_wss *,
116 struct uwb_dev_addr *);
118 struct wlp_assoc_conn_ctx {
119 struct work_struct ws;
122 struct wlp_eda_node eda_entry;
126 extern int wlp_wss_connect_prep(struct wlp *, struct wlp_eda_node *, void *);
127 extern int wlp_wss_send_copy(struct wlp *, struct wlp_eda_node *, void *);
130 /* Message handling */
131 struct wlp_assoc_frame_ctx {
132 struct work_struct ws;
135 struct uwb_dev_addr src;
138 extern int wlp_wss_prep_hdr(struct wlp *, struct wlp_eda_node *, void *);
139 extern void wlp_handle_d1_frame(struct work_struct *);
140 extern int wlp_parse_d2_frame_to_cache(struct wlp *, struct sk_buff *,
141 struct wlp_neighbor_e *);
142 extern int wlp_parse_d2_frame_to_enroll(struct wlp_wss *, struct sk_buff *,
143 struct wlp_neighbor_e *,
145 extern void wlp_handle_c1_frame(struct work_struct *);
146 extern void wlp_handle_c3_frame(struct work_struct *);
147 extern int wlp_parse_c3c4_frame(struct wlp *, struct sk_buff *,
148 struct wlp_uuid *, u8 *,
149 struct uwb_mac_addr *);
150 extern int wlp_parse_f0(struct wlp *, struct sk_buff *);
151 extern int wlp_send_assoc_frame(struct wlp *, struct wlp_wss *,
152 struct uwb_dev_addr *, enum wlp_assoc_type);
153 extern ssize_t wlp_get_version(struct wlp *, struct wlp_attr_version *,
155 extern ssize_t wlp_get_wssid(struct wlp *, struct wlp_attr_wssid *,
156 struct wlp_uuid *, ssize_t);
157 extern int __wlp_alloc_device_info(struct wlp *);
158 extern int __wlp_setup_device_info(struct wlp *);
160 extern struct wlp_wss_attribute wss_attribute_properties;
161 extern struct wlp_wss_attribute wss_attribute_members;
162 extern struct wlp_wss_attribute wss_attribute_state;
165 size_t wlp_wss_uuid_print(char *buf, size_t bufsize, struct wlp_uuid *uuid)
169 result = scnprintf(buf, bufsize,
170 "%02x:%02x:%02x:%02x:%02x:%02x:"
171 "%02x:%02x:%02x:%02x:%02x:%02x:"
172 "%02x:%02x:%02x:%02x",
173 uuid->data[0], uuid->data[1],
174 uuid->data[2], uuid->data[3],
175 uuid->data[4], uuid->data[5],
176 uuid->data[6], uuid->data[7],
177 uuid->data[8], uuid->data[9],
178 uuid->data[10], uuid->data[11],
179 uuid->data[12], uuid->data[13],
180 uuid->data[14], uuid->data[15]);
185 * FIXME: How should a nonce be displayed?
188 size_t wlp_wss_nonce_print(char *buf, size_t bufsize, struct wlp_nonce *nonce)
192 result = scnprintf(buf, bufsize,
193 "%02x %02x %02x %02x %02x %02x "
194 "%02x %02x %02x %02x %02x %02x "
195 "%02x %02x %02x %02x",
196 nonce->data[0], nonce->data[1],
197 nonce->data[2], nonce->data[3],
198 nonce->data[4], nonce->data[5],
199 nonce->data[6], nonce->data[7],
200 nonce->data[8], nonce->data[9],
201 nonce->data[10], nonce->data[11],
202 nonce->data[12], nonce->data[13],
203 nonce->data[14], nonce->data[15]);
209 void wlp_session_cb(struct wlp *wlp)
211 struct completion *completion = wlp->session->cb_priv;
212 complete(completion);
216 int wlp_uuid_is_set(struct wlp_uuid *uuid)
218 struct wlp_uuid zero_uuid = { .data = { 0x00, 0x00, 0x00, 0x00,
219 0x00, 0x00, 0x00, 0x00,
220 0x00, 0x00, 0x00, 0x00,
221 0x00, 0x00, 0x00, 0x00} };
223 if (!memcmp(uuid, &zero_uuid, sizeof(*uuid)))
228 #endif /* __WLP_INTERNAL_H__ */