1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#ifndef __LINUX__WLP_H_
45#define __LINUX__WLP_H_
46
47#include <linux/netdevice.h>
48#include <linux/skbuff.h>
49#include <linux/list.h>
50#include <linux/uwb.h>
51
52
53
54
55
56
57
58#define WLP_PROTOCOL_ID 0x0100
59
60
61
62
63
64#define WLP_VERSION 0x10
65
66
67
68
69#define WLP_WSS_UUID_STRSIZE 48
70
71
72
73
74#define WLP_WSS_NONCE_STRSIZE 48
75
76
77
78
79
80
81
82
83
84
85#define WLP_WSS_NAME_SIZE 65
86
87
88
89
90
91
92
93
94
95
96#define WLP_DATA_HLEN 4
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115enum wlp_wss_state {
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,
121};
122
123
124
125
126
127
128
129enum wlp_wss_sec_status {
130 WLP_WSS_UNSECURE = 0,
131 WLP_WSS_SECURE,
132};
133
134
135
136
137
138enum wlp_frame_type {
139 WLP_FRAME_STANDARD = 0,
140 WLP_FRAME_ABBREVIATED,
141 WLP_FRAME_CONTROL,
142 WLP_FRAME_ASSOCIATION,
143};
144
145
146
147
148
149enum wlp_assoc_type {
150 WLP_ASSOC_D1 = 2,
151 WLP_ASSOC_D2 = 3,
152 WLP_ASSOC_M1 = 4,
153 WLP_ASSOC_M2 = 5,
154 WLP_ASSOC_M3 = 7,
155 WLP_ASSOC_M4 = 8,
156 WLP_ASSOC_M5 = 9,
157 WLP_ASSOC_M6 = 10,
158 WLP_ASSOC_M7 = 11,
159 WLP_ASSOC_M8 = 12,
160 WLP_ASSOC_F0 = 14,
161 WLP_ASSOC_E1 = 32,
162 WLP_ASSOC_E2 = 33,
163 WLP_ASSOC_C1 = 34,
164 WLP_ASSOC_C2 = 35,
165 WLP_ASSOC_C3 = 36,
166 WLP_ASSOC_C4 = 37,
167};
168
169
170
171
172
173enum wlp_attr_type {
174 WLP_ATTR_AUTH = 0x1005,
175 WLP_ATTR_DEV_NAME = 0x1011,
176 WLP_ATTR_DEV_PWD_ID = 0x1012,
177 WLP_ATTR_E_HASH1 = 0x1014,
178 WLP_ATTR_E_HASH2 = 0x1015,
179 WLP_ATTR_E_SNONCE1 = 0x1016,
180 WLP_ATTR_E_SNONCE2 = 0x1017,
181 WLP_ATTR_ENCR_SET = 0x1018,
182 WLP_ATTR_ENRL_NONCE = 0x101A,
183 WLP_ATTR_KEYWRAP_AUTH = 0x101E,
184 WLP_ATTR_MANUF = 0x1021,
185 WLP_ATTR_MSG_TYPE = 0x1022,
186 WLP_ATTR_MODEL_NAME = 0x1023,
187 WLP_ATTR_MODEL_NR = 0x1024,
188 WLP_ATTR_PUB_KEY = 0x1032,
189 WLP_ATTR_REG_NONCE = 0x1039,
190 WLP_ATTR_R_HASH1 = 0x103D,
191 WLP_ATTR_R_HASH2 = 0x103E,
192 WLP_ATTR_R_SNONCE1 = 0x103F,
193 WLP_ATTR_R_SNONCE2 = 0x1040,
194 WLP_ATTR_SERIAL = 0x1042,
195 WLP_ATTR_UUID_E = 0x1047,
196 WLP_ATTR_UUID_R = 0x1048,
197 WLP_ATTR_PRI_DEV_TYPE = 0x1054,
198 WLP_ATTR_SEC_DEV_TYPE = 0x1055,
199 WLP_ATTR_PORT_DEV = 0x1056,
200 WLP_ATTR_APP_EXT = 0x1058,
201 WLP_ATTR_WLP_VER = 0x2000,
202 WLP_ATTR_WSSID = 0x2001,
203 WLP_ATTR_WSS_NAME = 0x2002,
204 WLP_ATTR_WSS_SEC_STAT = 0x2003,
205 WLP_ATTR_WSS_BCAST = 0x2004,
206 WLP_ATTR_WSS_M_KEY = 0x2005,
207 WLP_ATTR_ACC_ENRL = 0x2006,
208 WLP_ATTR_WSS_INFO = 0x2007,
209 WLP_ATTR_WSS_SEL_MTHD = 0x2008,
210 WLP_ATTR_ASSC_MTHD_LIST = 0x2009,
211 WLP_ATTR_SEL_ASSC_MTHD = 0x200A,
212 WLP_ATTR_ENRL_HASH_COMM = 0x200B,
213 WLP_ATTR_WSS_TAG = 0x200C,
214 WLP_ATTR_WSS_VIRT = 0x200D,
215 WLP_ATTR_WLP_ASSC_ERR = 0x200E,
216 WLP_ATTR_VNDR_EXT = 0x200F,
217};
218
219
220
221
222
223enum wlp_dev_category_id {
224 WLP_DEV_CAT_COMPUTER = 1,
225 WLP_DEV_CAT_INPUT,
226 WLP_DEV_CAT_PRINT_SCAN_FAX_COPIER,
227 WLP_DEV_CAT_CAMERA,
228 WLP_DEV_CAT_STORAGE,
229 WLP_DEV_CAT_INFRASTRUCTURE,
230 WLP_DEV_CAT_DISPLAY,
231 WLP_DEV_CAT_MULTIM,
232 WLP_DEV_CAT_GAMING,
233 WLP_DEV_CAT_TELEPHONE,
234 WLP_DEV_CAT_OTHER = 65535,
235};
236
237
238
239
240
241enum wlp_wss_sel_mthd {
242 WLP_WSS_ENRL_SELECT = 1,
243 WLP_WSS_REG_SELECT,
244};
245
246
247
248
249
250enum wlp_assc_error {
251 WLP_ASSOC_ERROR_NONE,
252 WLP_ASSOC_ERROR_AUTH,
253 WLP_ASSOC_ERROR_ROGUE,
254 WLP_ASSOC_ERROR_BUSY,
255 WLP_ASSOC_ERROR_LOCK,
256 WLP_ASSOC_ERROR_NOT_READY,
257 WLP_ASSOC_ERROR_INV,
258 WLP_ASSOC_ERROR_MSG_TIME,
259 WLP_ASSOC_ERROR_ENR_TIME,
260 WLP_ASSOC_ERROR_PW,
261 WLP_ASSOC_ERROR_VER,
262 WLP_ASSOC_ERROR_INT,
263 WLP_ASSOC_ERROR_UNDEF,
264 WLP_ASSOC_ERROR_NUM,
265 WLP_ASSOC_ERROR_WAIT,
266};
267
268
269
270
271
272enum wlp_parameters {
273 WLP_PER_MSG_TIMEOUT = 15,
274
275};
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297struct wlp_ie {
298 struct uwb_ie_hdr hdr;
299 __le16 capabilities;
300 __le16 cycle_param;
301 __le16 acw_anchor_addr;
302 u8 wssid_hash_list[];
303} __attribute__((packed));
304
305static inline int wlp_ie_hash_length(struct wlp_ie *ie)
306{
307 return (le16_to_cpu(ie->capabilities) >> 12) & 0xf;
308}
309
310static inline void wlp_ie_set_hash_length(struct wlp_ie *ie, int hash_length)
311{
312 u16 caps = le16_to_cpu(ie->capabilities);
313 caps = (caps & ~(0xf << 12)) | (hash_length << 12);
314 ie->capabilities = cpu_to_le16(caps);
315}
316
317
318
319
320
321
322
323
324
325struct wlp_nonce {
326 u8 data[16];
327} __attribute__((packed));
328
329
330
331
332
333
334
335
336
337struct wlp_uuid {
338 u8 data[16];
339} __attribute__((packed));
340
341
342
343
344
345
346struct wlp_dev_type {
347 enum wlp_dev_category_id category:16;
348 u8 OUI[3];
349 u8 OUIsubdiv;
350 __le16 subID;
351} __attribute__((packed));
352
353
354
355
356
357struct wlp_frame_hdr {
358 __le16 mux_hdr;
359 enum wlp_frame_type type:8;
360} __attribute__((packed));
361
362
363
364
365
366
367
368struct wlp_attr_hdr {
369 __le16 type;
370 __le16 length;
371} __attribute__((packed));
372
373
374
375
376
377
378
379
380
381
382
383
384struct wlp_device_info {
385 char name[33];
386 char model_name[33];
387 char manufacturer[65];
388 char model_nr[33];
389 char serial[33];
390 struct wlp_dev_type prim_dev_type;
391};
392
393
394
395
396
397
398
399
400#define wlp_attr(type, name) \
401struct wlp_attr_##name { \
402 struct wlp_attr_hdr hdr; \
403 type name; \
404} __attribute__((packed));
405
406#define wlp_attr_array(type, name) \
407struct wlp_attr_##name { \
408 struct wlp_attr_hdr hdr; \
409 type name[]; \
410} __attribute__((packed));
411
412
413
414
415
416
417
418
419
420
421wlp_attr_array(u8, dev_name)
422
423
424
425wlp_attr(struct wlp_nonce, enonce)
426
427
428wlp_attr_array(u8, manufacturer)
429
430
431wlp_attr(u8, msg_type)
432
433
434wlp_attr_array(u8, model_name)
435
436
437wlp_attr_array(u8, model_nr)
438
439
440
441wlp_attr(struct wlp_nonce, rnonce)
442
443
444wlp_attr_array(u8, serial)
445
446
447wlp_attr(struct wlp_uuid, uuid_e)
448
449
450wlp_attr(struct wlp_uuid, uuid_r)
451
452
453wlp_attr(struct wlp_dev_type, prim_dev_type)
454
455
456wlp_attr(struct wlp_dev_type, sec_dev_type)
457
458
459wlp_attr(u8, version)
460
461
462wlp_attr(struct wlp_uuid, wssid)
463
464
465wlp_attr_array(u8, wss_name)
466
467
468wlp_attr(u8, wss_sec_status)
469
470
471wlp_attr(struct uwb_mac_addr, wss_bcast)
472
473
474wlp_attr(u8, accept_enrl)
475
476
477
478
479
480struct 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));
487
488
489wlp_attr_array(struct wlp_wss_info, wss_info)
490
491
492wlp_attr(u8, wss_sel_mthd)
493
494
495wlp_attr(u8, wss_tag)
496
497
498wlp_attr(struct uwb_mac_addr, wss_virt)
499
500
501wlp_attr(u8, wlp_assc_err)
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520struct wlp_frame_std_abbrv_hdr {
521 struct wlp_frame_hdr hdr;
522 u8 tag;
523} __attribute__((packed));
524
525
526
527
528
529
530struct 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;
535 u8 attr[];
536} __attribute__((packed));
537
538
539struct wlp_eda {
540 spinlock_t lock;
541 struct list_head cache;
542};
543
544
545
546
547
548
549
550
551
552
553
554struct wlp_wss_tmp_info {
555 char name[WLP_WSS_NAME_SIZE];
556 u8 accept_enroll;
557 u8 sec_status;
558 struct uwb_mac_addr bcast;
559};
560
561struct wlp_wssid_e {
562 struct list_head node;
563 struct wlp_uuid wssid;
564 struct wlp_wss_tmp_info *info;
565};
566
567
568
569
570
571
572
573
574
575
576struct wlp_neighbor_e {
577 struct list_head node;
578 struct wlp_uuid uuid;
579 struct uwb_dev *uwb_dev;
580 struct list_head wssid;
581 struct wlp_device_info *info;
582};
583
584struct wlp;
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599struct wlp_session {
600 enum wlp_assoc_type exp_message;
601 void (*cb)(struct wlp *);
602 void *cb_priv;
603 void *data;
604 struct uwb_dev_addr neighbor_addr;
605};
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623struct wlp_wss {
624 struct mutex mutex;
625 struct kobject kobj;
626
627 struct wlp_uuid wssid;
628 u8 hash;
629 char name[WLP_WSS_NAME_SIZE];
630 struct uwb_mac_addr bcast;
631 u8 secure_status:1;
632 u8 master_key[16];
633
634 u8 tag;
635 struct uwb_mac_addr virtual_addr;
636
637 u8 accept_enroll:1;
638 enum wlp_wss_state state;
639};
640
641
642
643
644
645
646struct wlp {
647 struct mutex mutex;
648 struct uwb_rc *rc;
649 struct net_device *ndev;
650 struct uwb_pal pal;
651 struct wlp_eda eda;
652 struct wlp_uuid uuid;
653 struct wlp_session *session;
654 struct wlp_wss wss;
655 struct mutex nbmutex;
656 struct list_head neighbors;
657 struct uwb_notifs_handler uwb_notifs_handler;
658 struct wlp_device_info *dev_info;
659 void (*fill_device_info)(struct wlp *wlp, struct wlp_device_info *info);
660 int (*xmit_frame)(struct wlp *, struct sk_buff *,
661 struct uwb_dev_addr *);
662 void (*stop_queue)(struct wlp *);
663 void (*start_queue)(struct wlp *);
664};
665
666
667
668
669struct wlp_wss_attribute {
670 struct attribute attr;
671 ssize_t (*show)(struct wlp_wss *wss, char *buf);
672 ssize_t (*store)(struct wlp_wss *wss, const char *buf, size_t count);
673};
674
675#define WSS_ATTR(_name, _mode, _show, _store) \
676static struct wlp_wss_attribute wss_attr_##_name = __ATTR(_name, _mode, \
677 _show, _store)
678
679extern int wlp_setup(struct wlp *, struct uwb_rc *, struct net_device *ndev);
680extern void wlp_remove(struct wlp *);
681extern ssize_t wlp_neighborhood_show(struct wlp *, char *);
682extern int wlp_wss_setup(struct net_device *, struct wlp_wss *);
683extern void wlp_wss_remove(struct wlp_wss *);
684extern ssize_t wlp_wss_activate_show(struct wlp_wss *, char *);
685extern ssize_t wlp_wss_activate_store(struct wlp_wss *, const char *, size_t);
686extern ssize_t wlp_eda_show(struct wlp *, char *);
687extern ssize_t wlp_eda_store(struct wlp *, const char *, size_t);
688extern ssize_t wlp_uuid_show(struct wlp *, char *);
689extern ssize_t wlp_uuid_store(struct wlp *, const char *, size_t);
690extern ssize_t wlp_dev_name_show(struct wlp *, char *);
691extern ssize_t wlp_dev_name_store(struct wlp *, const char *, size_t);
692extern ssize_t wlp_dev_manufacturer_show(struct wlp *, char *);
693extern ssize_t wlp_dev_manufacturer_store(struct wlp *, const char *, size_t);
694extern ssize_t wlp_dev_model_name_show(struct wlp *, char *);
695extern ssize_t wlp_dev_model_name_store(struct wlp *, const char *, size_t);
696extern ssize_t wlp_dev_model_nr_show(struct wlp *, char *);
697extern ssize_t wlp_dev_model_nr_store(struct wlp *, const char *, size_t);
698extern ssize_t wlp_dev_serial_show(struct wlp *, char *);
699extern ssize_t wlp_dev_serial_store(struct wlp *, const char *, size_t);
700extern ssize_t wlp_dev_prim_category_show(struct wlp *, char *);
701extern ssize_t wlp_dev_prim_category_store(struct wlp *, const char *,
702 size_t);
703extern ssize_t wlp_dev_prim_OUI_show(struct wlp *, char *);
704extern ssize_t wlp_dev_prim_OUI_store(struct wlp *, const char *, size_t);
705extern ssize_t wlp_dev_prim_OUI_sub_show(struct wlp *, char *);
706extern ssize_t wlp_dev_prim_OUI_sub_store(struct wlp *, const char *,
707 size_t);
708extern ssize_t wlp_dev_prim_subcat_show(struct wlp *, char *);
709extern ssize_t wlp_dev_prim_subcat_store(struct wlp *, const char *,
710 size_t);
711extern int wlp_receive_frame(struct device *, struct wlp *, struct sk_buff *,
712 struct uwb_dev_addr *);
713extern int wlp_prepare_tx_frame(struct device *, struct wlp *,
714 struct sk_buff *, struct uwb_dev_addr *);
715void wlp_reset_all(struct wlp *wlp);
716
717
718
719
720static inline
721void wlp_wss_init(struct wlp_wss *wss)
722{
723 mutex_init(&wss->mutex);
724}
725
726static inline
727void wlp_init(struct wlp *wlp)
728{
729 INIT_LIST_HEAD(&wlp->neighbors);
730 mutex_init(&wlp->mutex);
731 mutex_init(&wlp->nbmutex);
732 wlp_wss_init(&wlp->wss);
733}
734
735
736#endif
737