2 * WiMedia Logical Link Control Protocol (WLP)
4 * Copyright (C) 2005-2006 Intel Corporation
5 * Reinette Chatre <reinette.chatre@intel.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * - Does not (yet) include support for WLP control frames
25 * WLP Draft 0.99 [6.5].
27 * A visual representation of the data structures.
35 * ... ... wssid wssid ...
37 * }; neighbors --> neighbA --> neighbB
41 * eda cache --> neighborA --> neighborB --> neighborC ...
44 #ifndef __LINUX__WLP_H_
45 #define __LINUX__WLP_H_
47 #include <linux/netdevice.h>
48 #include <linux/skbuff.h>
49 #include <linux/list.h>
50 #include <linux/uwb.h>
54 * WLP Draft 0.99 [6.2]
56 * The MUX header for all WLP frames
58 #define WLP_PROTOCOL_ID 0x0100
62 * WLP version placed in the association frames (WLP 0.99 [6.6])
64 #define WLP_VERSION 0x10
67 * Bytes needed to print UUID as string
69 #define WLP_WSS_UUID_STRSIZE 48
72 * Bytes needed to print nonce as string
74 #define WLP_WSS_NONCE_STRSIZE 48
78 * Size used for WLP name size
80 * The WSS name is set to 65 bytes, 1 byte larger than the maximum
81 * allowed by the WLP spec. This is to have a null terminated string
82 * for display to the user. A maximum of 64 bytes will still be used
83 * when placing the WSS name field in association frames.
85 #define WLP_WSS_NAME_SIZE 65
88 * Number of bytes added by WLP to data frame
90 * A data frame transmitted from a host will be placed in a Standard or
91 * Abbreviated WLP frame. These have an extra 4 bytes of header (struct
92 * wlp_frame_std_abbrv_hdr).
93 * When the stack sends this data frame for transmission it needs to ensure
94 * there is enough headroom for this header.
96 #define WLP_DATA_HLEN 4
99 * State of device regarding WLP Service Set
101 * WLP_WSS_STATE_NONE: the host does not participate in any WSS
102 * WLP_WSS_STATE_PART_ENROLLED: used as part of the enrollment sequence
103 * ("Partial Enroll"). This state is used to
104 * indicate the first part of enrollment that is
105 * unsecure. If the WSS is unsecure then the
106 * state will promptly go to WLP_WSS_STATE_ENROLLED,
107 * if the WSS is not secure then the enrollment
108 * procedure is a few more steps before we are
110 * WLP_WSS_STATE_ENROLLED: the host is enrolled in a WSS
111 * WLP_WSS_STATE_ACTIVE: WSS is activated
112 * WLP_WSS_STATE_CONNECTED: host is connected to neighbor in WSS
116 WLP_WSS_STATE_NONE = 0,
117 WLP_WSS_STATE_PART_ENROLLED,
118 WLP_WSS_STATE_ENROLLED,
119 WLP_WSS_STATE_ACTIVE,
120 WLP_WSS_STATE_CONNECTED,
127 * Set to one if the WSS is secure, zero if it is not secure
129 enum wlp_wss_sec_status {
130 WLP_WSS_UNSECURE = 0,
136 * WLP Draft 0.99 [6.2 Table 1]
138 enum wlp_frame_type {
139 WLP_FRAME_STANDARD = 0,
140 WLP_FRAME_ABBREVIATED,
142 WLP_FRAME_ASSOCIATION,
146 * WLP Association Message Type
147 * WLP Draft 0.99 [6.6.1.2 Table 8]
149 enum wlp_assoc_type {
171 * WLP Draft 0.99 [6.6.1 Table 6]
174 WLP_ATTR_AUTH = 0x1005, /* Authenticator */
175 WLP_ATTR_DEV_NAME = 0x1011, /* Device Name */
176 WLP_ATTR_DEV_PWD_ID = 0x1012, /* Device Password ID */
177 WLP_ATTR_E_HASH1 = 0x1014, /* E-Hash1 */
178 WLP_ATTR_E_HASH2 = 0x1015, /* E-Hash2 */
179 WLP_ATTR_E_SNONCE1 = 0x1016, /* E-SNonce1 */
180 WLP_ATTR_E_SNONCE2 = 0x1017, /* E-SNonce2 */
181 WLP_ATTR_ENCR_SET = 0x1018, /* Encrypted Settings */
182 WLP_ATTR_ENRL_NONCE = 0x101A, /* Enrollee Nonce */
183 WLP_ATTR_KEYWRAP_AUTH = 0x101E, /* Key Wrap Authenticator */
184 WLP_ATTR_MANUF = 0x1021, /* Manufacturer */
185 WLP_ATTR_MSG_TYPE = 0x1022, /* Message Type */
186 WLP_ATTR_MODEL_NAME = 0x1023, /* Model Name */
187 WLP_ATTR_MODEL_NR = 0x1024, /* Model Number */
188 WLP_ATTR_PUB_KEY = 0x1032, /* Public Key */
189 WLP_ATTR_REG_NONCE = 0x1039, /* Registrar Nonce */
190 WLP_ATTR_R_HASH1 = 0x103D, /* R-Hash1 */
191 WLP_ATTR_R_HASH2 = 0x103E, /* R-Hash2 */
192 WLP_ATTR_R_SNONCE1 = 0x103F, /* R-SNonce1 */
193 WLP_ATTR_R_SNONCE2 = 0x1040, /* R-SNonce2 */
194 WLP_ATTR_SERIAL = 0x1042, /* Serial number */
195 WLP_ATTR_UUID_E = 0x1047, /* UUID-E */
196 WLP_ATTR_UUID_R = 0x1048, /* UUID-R */
197 WLP_ATTR_PRI_DEV_TYPE = 0x1054, /* Primary Device Type */
198 WLP_ATTR_SEC_DEV_TYPE = 0x1055, /* Secondary Device Type */
199 WLP_ATTR_PORT_DEV = 0x1056, /* Portable Device */
200 WLP_ATTR_APP_EXT = 0x1058, /* Application Extension */
201 WLP_ATTR_WLP_VER = 0x2000, /* WLP Version */
202 WLP_ATTR_WSSID = 0x2001, /* WSSID */
203 WLP_ATTR_WSS_NAME = 0x2002, /* WSS Name */
204 WLP_ATTR_WSS_SEC_STAT = 0x2003, /* WSS Secure Status */
205 WLP_ATTR_WSS_BCAST = 0x2004, /* WSS Broadcast Address */
206 WLP_ATTR_WSS_M_KEY = 0x2005, /* WSS Master Key */
207 WLP_ATTR_ACC_ENRL = 0x2006, /* Accepting Enrollment */
208 WLP_ATTR_WSS_INFO = 0x2007, /* WSS Information */
209 WLP_ATTR_WSS_SEL_MTHD = 0x2008, /* WSS Selection Method */
210 WLP_ATTR_ASSC_MTHD_LIST = 0x2009, /* Association Methods List */
211 WLP_ATTR_SEL_ASSC_MTHD = 0x200A, /* Selected Association Method */
212 WLP_ATTR_ENRL_HASH_COMM = 0x200B, /* Enrollee Hash Commitment */
213 WLP_ATTR_WSS_TAG = 0x200C, /* WSS Tag */
214 WLP_ATTR_WSS_VIRT = 0x200D, /* WSS Virtual EUI-48 */
215 WLP_ATTR_WLP_ASSC_ERR = 0x200E, /* WLP Association Error */
216 WLP_ATTR_VNDR_EXT = 0x200F, /* Vendor Extension */
220 * WLP Category ID of primary/secondary device
221 * WLP Draft 0.99 [6.6.1.8 Table 12]
223 enum wlp_dev_category_id {
224 WLP_DEV_CAT_COMPUTER = 1,
226 WLP_DEV_CAT_PRINT_SCAN_FAX_COPIER,
229 WLP_DEV_CAT_INFRASTRUCTURE,
233 WLP_DEV_CAT_TELEPHONE,
234 WLP_DEV_CAT_OTHER = 65535,
238 * WLP WSS selection method
239 * WLP Draft 0.99 [6.6.1.6 Table 10]
241 enum wlp_wss_sel_mthd {
242 WLP_WSS_ENRL_SELECT = 1, /* Enrollee selects */
243 WLP_WSS_REG_SELECT, /* Registrar selects */
247 * WLP association error values
248 * WLP Draft 0.99 [6.6.1.5 Table 9]
250 enum wlp_assc_error {
251 WLP_ASSOC_ERROR_NONE,
252 WLP_ASSOC_ERROR_AUTH, /* Authenticator Failure */
253 WLP_ASSOC_ERROR_ROGUE, /* Rogue activity suspected */
254 WLP_ASSOC_ERROR_BUSY, /* Device busy */
255 WLP_ASSOC_ERROR_LOCK, /* Setup Locked */
256 WLP_ASSOC_ERROR_NOT_READY, /* Registrar not ready */
257 WLP_ASSOC_ERROR_INV, /* Invalid WSS selection */
258 WLP_ASSOC_ERROR_MSG_TIME, /* Message timeout */
259 WLP_ASSOC_ERROR_ENR_TIME, /* Enrollment session timeout */
260 WLP_ASSOC_ERROR_PW, /* Device password invalid */
261 WLP_ASSOC_ERROR_VER, /* Unsupported version */
262 WLP_ASSOC_ERROR_INT, /* Internal error */
263 WLP_ASSOC_ERROR_UNDEF, /* Undefined error */
264 WLP_ASSOC_ERROR_NUM, /* Numeric comparison failure */
265 WLP_ASSOC_ERROR_WAIT, /* Waiting for user input */
272 enum wlp_parameters {
273 WLP_PER_MSG_TIMEOUT = 15, /* Seconds to wait for response to
274 association message. */
280 * The WLP IE should be included in beacons by all devices.
282 * The driver can set only a few of the fields in this information element,
283 * most fields are managed by the device self. When the driver needs to set
284 * a field it will only provide values for the fields of interest, the rest
285 * will be filled with zeroes. The fields of interest are:
289 * Capabilities (only to include WSSID Hash list length)
290 * WSSID Hash List fields
294 * Only the fields that will be used are detailed in this structure, rest
295 * are not detailed or marked as "notused".
298 struct uwb_ie_hdr hdr;
301 __le16 acw_anchor_addr;
302 u8 wssid_hash_list[];
303 } __attribute__((packed));
305 static inline int wlp_ie_hash_length(struct wlp_ie *ie)
307 return (le16_to_cpu(ie->capabilities) >> 12) & 0xf;
310 static inline void wlp_ie_set_hash_length(struct wlp_ie *ie, int hash_length)
312 u16 caps = le16_to_cpu(ie->capabilities);
313 caps = (caps & ~(0xf << 12)) | (hash_length << 12);
314 ie->capabilities = cpu_to_le16(caps);
319 * WLP Draft 0.99 [6.6.1 Table 6]
321 * A 128-bit random number often used (E-SNonce1, E-SNonce2, Enrollee
322 * Nonce, Registrar Nonce, R-SNonce1, R-SNonce2). It is passed to HW so
327 } __attribute__((packed));
331 * WLP Draft 0.99 [6.6.1 Table 6]
333 * Universally Unique Identifier (UUID) encoded as an octet string in the
334 * order the octets are shown in string representation in RFC4122. A UUID
335 * is often used (UUID-E, UUID-R, WSSID). It is passed to HW so it is packed.
339 } __attribute__((packed));
343 * Primary and secondary device type attributes
344 * WLP Draft 0.99 [6.6.1.8]
346 struct wlp_dev_type {
347 enum wlp_dev_category_id category:16;
351 } __attribute__((packed));
355 * WLP Draft 0.99 [6.2]
357 struct wlp_frame_hdr {
358 __le16 mux_hdr; /* WLP_PROTOCOL_ID */
359 enum wlp_frame_type type:8;
360 } __attribute__((packed));
363 * WLP attribute field header
364 * WLP Draft 0.99 [6.6.1]
366 * Header of each attribute found in an association frame
368 struct wlp_attr_hdr {
371 } __attribute__((packed));
374 * Device information commonly used together
376 * Each of these device information elements has a specified range in which it
377 * should fit (WLP 0.99 [Table 6]). This range provided in the spec does not
378 * include the termination null '\0' character (when used in the
379 * association protocol the attribute fields are accompanied
380 * with a "length" field so the full range from the spec can be used for
381 * the value). We thus allocate an extra byte to be able to store a string
382 * of max length with a terminating '\0'.
384 struct wlp_device_info {
387 char manufacturer[65];
390 struct wlp_dev_type prim_dev_type;
394 * Macros for the WLP attributes
396 * There are quite a few attributes (total is 43). The attribute layout can be
397 * in one of three categories: one value, an array, an enum forced to 8 bits.
398 * These macros help with their definitions.
400 #define wlp_attr(type, name) \
401 struct wlp_attr_##name { \
402 struct wlp_attr_hdr hdr; \
404 } __attribute__((packed));
406 #define wlp_attr_array(type, name) \
407 struct wlp_attr_##name { \
408 struct wlp_attr_hdr hdr; \
410 } __attribute__((packed));
413 * WLP association attribute fields
414 * WLP Draft 0.99 [6.6.1 Table 6]
416 * Attributes appear in same order as the Table in the spec
417 * FIXME Does not define all attributes yet
420 /* Device name: Friendly name of sending device */
421 wlp_attr_array(u8, dev_name)
423 /* Enrollee Nonce: Random number generated by enrollee for an enrollment
425 wlp_attr(struct wlp_nonce, enonce)
427 /* Manufacturer name: Name of manufacturer of the sending device */
428 wlp_attr_array(u8, manufacturer)
430 /* WLP Message Type */
431 wlp_attr(u8, msg_type)
433 /* WLP Model name: Model name of sending device */
434 wlp_attr_array(u8, model_name)
436 /* WLP Model number: Model number of sending device */
437 wlp_attr_array(u8, model_nr)
439 /* Registrar Nonce: Random number generated by registrar for an enrollment
441 wlp_attr(struct wlp_nonce, rnonce)
443 /* Serial number of device */
444 wlp_attr_array(u8, serial)
446 /* UUID of enrollee */
447 wlp_attr(struct wlp_uuid, uuid_e)
449 /* UUID of registrar */
450 wlp_attr(struct wlp_uuid, uuid_r)
452 /* WLP Primary device type */
453 wlp_attr(struct wlp_dev_type, prim_dev_type)
455 /* WLP Secondary device type */
456 wlp_attr(struct wlp_dev_type, sec_dev_type)
458 /* WLP protocol version */
459 wlp_attr(u8, version)
461 /* WLP service set identifier */
462 wlp_attr(struct wlp_uuid, wssid)
465 wlp_attr_array(u8, wss_name)
467 /* WLP WSS Secure Status */
468 wlp_attr(u8, wss_sec_status)
470 /* WSS Broadcast Address */
471 wlp_attr(struct uwb_mac_addr, wss_bcast)
473 /* WLP Accepting Enrollment */
474 wlp_attr(u8, accept_enrl)
477 * WSS information attributes
478 * WLP Draft 0.99 [6.6.3 Table 15]
480 struct wlp_wss_info {
481 struct wlp_attr_wssid wssid;
482 struct wlp_attr_wss_name name;
483 struct wlp_attr_accept_enrl accept;
484 struct wlp_attr_wss_sec_status sec_stat;
485 struct wlp_attr_wss_bcast bcast;
486 } __attribute__((packed));
488 /* WLP WSS Information */
489 wlp_attr_array(struct wlp_wss_info, wss_info)
491 /* WLP WSS Selection method */
492 wlp_attr(u8, wss_sel_mthd)
495 wlp_attr(u8, wss_tag)
497 /* WSS Virtual Address */
498 wlp_attr(struct uwb_mac_addr, wss_virt)
500 /* WLP association error */
501 wlp_attr(u8, wlp_assc_err)
504 * WLP standard and abbreviated frames
506 * WLP Draft 0.99 [6.3] and [6.4]
508 * The difference between the WLP standard frame and the WLP
509 * abbreviated frame is that the standard frame includes the src
510 * and dest addresses from the Ethernet header, the abbreviated frame does
512 * The src/dest (as well as the type/length and client data) are already
513 * defined as part of the Ethernet header, we do not do this here.
514 * From this perspective the standard and abbreviated frames appear the
515 * same - they will be treated differently though.
517 * The size of this header is also captured in WLP_DATA_HLEN to enable
518 * interfaces to prepare their headroom.
520 struct wlp_frame_std_abbrv_hdr {
521 struct wlp_frame_hdr hdr;
523 } __attribute__((packed));
526 * WLP association frames
528 * WLP Draft 0.99 [6.6]
530 struct wlp_frame_assoc {
531 struct wlp_frame_hdr hdr;
532 enum wlp_assoc_type type:8;
533 struct wlp_attr_version version;
534 struct wlp_attr_msg_type msg_type;
536 } __attribute__((packed));
538 /* Ethernet to dev address mapping */
541 struct list_head cache; /* Eth<->Dev Addr cache */
545 * WSS information temporary storage
547 * This information is only stored temporarily during discovery. It should
548 * not be stored unless the device is enrolled in the advertised WSS. This
549 * is done mainly because we follow the letter of the spec in this regard.
550 * See WLP 0.99 [7.2.3].
551 * When the device does become enrolled in a WSS the WSS information will
552 * be stored as part of the more comprehensive struct wlp_wss.
554 struct wlp_wss_tmp_info {
555 char name[WLP_WSS_NAME_SIZE];
558 struct uwb_mac_addr bcast;
562 struct list_head node;
563 struct wlp_uuid wssid;
564 struct wlp_wss_tmp_info *info;
568 * A cache entry of WLP neighborhood
570 * @node: head of list is wlp->neighbors
571 * @wssid: list of wssids of this neighbor, element is wlp_wssid_e
572 * @info: temporary storage for information learned during discovery. This
573 * storage is used together with the wssid_e temporary storage
576 struct wlp_neighbor_e {
577 struct list_head node;
578 struct wlp_uuid uuid;
579 struct uwb_dev *uwb_dev;
580 struct list_head wssid; /* Elements are wlp_wssid_e */
581 struct wlp_device_info *info;
586 * Information for an association session in progress.
588 * @exp_message: The type of the expected message. Both this message and a
589 * F0 message (which can be sent in response to any
590 * association frame) will be accepted as a valid message for
592 * @cb: The function that will be called upon receipt of this
594 * @cb_priv: Private data of callback
595 * @data: Data used in association process (always a sk_buff?)
596 * @neighbor: Address of neighbor with which association session is in
600 enum wlp_assoc_type exp_message;
601 void (*cb)(struct wlp *);
604 struct uwb_dev_addr neighbor_addr;
610 * @mutex: used to protect entire WSS structure.
612 * @name: The WSS name is set to 65 bytes, 1 byte larger than the maximum
613 * allowed by the WLP spec. This is to have a null terminated string
614 * for display to the user. A maximum of 64 bytes will still be used
615 * when placing the WSS name field in association frames.
617 * @accept_enroll: Accepting enrollment: Set to one if registrar is
618 * accepting enrollment in WSS, or zero otherwise.
620 * Global and local information for each WSS in which we are enrolled.
621 * WLP 0.99 Section 7.2.1 and Section 7.2.2
626 /* Global properties. */
627 struct wlp_uuid wssid;
629 char name[WLP_WSS_NAME_SIZE];
630 struct uwb_mac_addr bcast;
633 /* Local properties. */
635 struct uwb_mac_addr virtual_addr;
638 enum wlp_wss_state state;
643 * @mutex: protect changes to WLP structure. We only allow changes to the
644 * uuid, so currently this mutex only protects this field.
648 struct uwb_rc *rc; /* UWB radio controller */
651 struct wlp_uuid uuid;
652 struct wlp_session *session;
654 struct mutex nbmutex; /* Neighbor mutex protects neighbors list */
655 struct list_head neighbors; /* Elements are wlp_neighbor_e */
656 struct uwb_notifs_handler uwb_notifs_handler;
657 struct wlp_device_info *dev_info;
658 void (*fill_device_info)(struct wlp *wlp, struct wlp_device_info *info);
659 int (*xmit_frame)(struct wlp *, struct sk_buff *,
660 struct uwb_dev_addr *);
661 void (*stop_queue)(struct wlp *);
662 void (*start_queue)(struct wlp *);
668 struct wlp_wss_attribute {
669 struct attribute attr;
670 ssize_t (*show)(struct wlp_wss *wss, char *buf);
671 ssize_t (*store)(struct wlp_wss *wss, const char *buf, size_t count);
674 #define WSS_ATTR(_name, _mode, _show, _store) \
675 static struct wlp_wss_attribute wss_attr_##_name = __ATTR(_name, _mode, \
678 extern int wlp_setup(struct wlp *, struct uwb_rc *);
679 extern void wlp_remove(struct wlp *);
680 extern ssize_t wlp_neighborhood_show(struct wlp *, char *);
681 extern int wlp_wss_setup(struct net_device *, struct wlp_wss *);
682 extern void wlp_wss_remove(struct wlp_wss *);
683 extern ssize_t wlp_wss_activate_show(struct wlp_wss *, char *);
684 extern ssize_t wlp_wss_activate_store(struct wlp_wss *, const char *, size_t);
685 extern ssize_t wlp_eda_show(struct wlp *, char *);
686 extern ssize_t wlp_eda_store(struct wlp *, const char *, size_t);
687 extern ssize_t wlp_uuid_show(struct wlp *, char *);
688 extern ssize_t wlp_uuid_store(struct wlp *, const char *, size_t);
689 extern ssize_t wlp_dev_name_show(struct wlp *, char *);
690 extern ssize_t wlp_dev_name_store(struct wlp *, const char *, size_t);
691 extern ssize_t wlp_dev_manufacturer_show(struct wlp *, char *);
692 extern ssize_t wlp_dev_manufacturer_store(struct wlp *, const char *, size_t);
693 extern ssize_t wlp_dev_model_name_show(struct wlp *, char *);
694 extern ssize_t wlp_dev_model_name_store(struct wlp *, const char *, size_t);
695 extern ssize_t wlp_dev_model_nr_show(struct wlp *, char *);
696 extern ssize_t wlp_dev_model_nr_store(struct wlp *, const char *, size_t);
697 extern ssize_t wlp_dev_serial_show(struct wlp *, char *);
698 extern ssize_t wlp_dev_serial_store(struct wlp *, const char *, size_t);
699 extern ssize_t wlp_dev_prim_category_show(struct wlp *, char *);
700 extern ssize_t wlp_dev_prim_category_store(struct wlp *, const char *,
702 extern ssize_t wlp_dev_prim_OUI_show(struct wlp *, char *);
703 extern ssize_t wlp_dev_prim_OUI_store(struct wlp *, const char *, size_t);
704 extern ssize_t wlp_dev_prim_OUI_sub_show(struct wlp *, char *);
705 extern ssize_t wlp_dev_prim_OUI_sub_store(struct wlp *, const char *,
707 extern ssize_t wlp_dev_prim_subcat_show(struct wlp *, char *);
708 extern ssize_t wlp_dev_prim_subcat_store(struct wlp *, const char *,
710 extern int wlp_receive_frame(struct device *, struct wlp *, struct sk_buff *,
711 struct uwb_dev_addr *);
712 extern int wlp_prepare_tx_frame(struct device *, struct wlp *,
713 struct sk_buff *, struct uwb_dev_addr *);
714 void wlp_reset_all(struct wlp *wlp);
720 void wlp_wss_init(struct wlp_wss *wss)
722 mutex_init(&wss->mutex);
726 void wlp_init(struct wlp *wlp)
728 INIT_LIST_HEAD(&wlp->neighbors);
729 mutex_init(&wlp->mutex);
730 mutex_init(&wlp->nbmutex);
731 wlp_wss_init(&wlp->wss);
735 #endif /* #ifndef __LINUX__WLP_H_ */