wlp.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. /*
  2. * WiMedia Logical Link Control Protocol (WLP)
  3. *
  4. * Copyright (C) 2005-2006 Intel Corporation
  5. * Reinette Chatre <reinette.chatre@intel.com>
  6. *
  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.
  10. *
  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.
  15. *
  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
  19. * 02110-1301, USA.
  20. *
  21. *
  22. * FIXME: docs
  23. *
  24. * - Does not (yet) include support for WLP control frames
  25. * WLP Draft 0.99 [6.5].
  26. *
  27. * A visual representation of the data structures.
  28. *
  29. * wssidB wssidB
  30. * ^ ^
  31. * | |
  32. * wssidA wssidA
  33. * wlp interface { ^ ^
  34. * ... | |
  35. * ... ... wssid wssid ...
  36. * wlp --- ... | |
  37. * }; neighbors --> neighbA --> neighbB
  38. * ...
  39. * wss
  40. * ...
  41. * eda cache --> neighborA --> neighborB --> neighborC ...
  42. */
  43. #ifndef __LINUX__WLP_H_
  44. #define __LINUX__WLP_H_
  45. #include <linux/netdevice.h>
  46. #include <linux/skbuff.h>
  47. #include <linux/list.h>
  48. #include <linux/uwb.h>
  49. /**
  50. * WLP Protocol ID
  51. * WLP Draft 0.99 [6.2]
  52. *
  53. * The MUX header for all WLP frames
  54. */
  55. #define WLP_PROTOCOL_ID 0x0100
  56. /**
  57. * WLP Version
  58. * WLP version placed in the association frames (WLP 0.99 [6.6])
  59. */
  60. #define WLP_VERSION 0x10
  61. /**
  62. * Bytes needed to print UUID as string
  63. */
  64. #define WLP_WSS_UUID_STRSIZE 48
  65. /**
  66. * Bytes needed to print nonce as string
  67. */
  68. #define WLP_WSS_NONCE_STRSIZE 48
  69. /**
  70. * Size used for WLP name size
  71. *
  72. * The WSS name is set to 65 bytes, 1 byte larger than the maximum
  73. * allowed by the WLP spec. This is to have a null terminated string
  74. * for display to the user. A maximum of 64 bytes will still be used
  75. * when placing the WSS name field in association frames.
  76. */
  77. #define WLP_WSS_NAME_SIZE 65
  78. /**
  79. * Number of bytes added by WLP to data frame
  80. *
  81. * A data frame transmitted from a host will be placed in a Standard or
  82. * Abbreviated WLP frame. These have an extra 4 bytes of header (struct
  83. * wlp_frame_std_abbrv_hdr).
  84. * When the stack sends this data frame for transmission it needs to ensure
  85. * there is enough headroom for this header.
  86. */
  87. #define WLP_DATA_HLEN 4
  88. /**
  89. * State of device regarding WLP Service Set
  90. *
  91. * WLP_WSS_STATE_NONE: the host does not participate in any WSS
  92. * WLP_WSS_STATE_PART_ENROLLED: used as part of the enrollment sequence
  93. * ("Partial Enroll"). This state is used to
  94. * indicate the first part of enrollment that is
  95. * unsecure. If the WSS is unsecure then the
  96. * state will promptly go to WLP_WSS_STATE_ENROLLED,
  97. * if the WSS is not secure then the enrollment
  98. * procedure is a few more steps before we are
  99. * enrolled.
  100. * WLP_WSS_STATE_ENROLLED: the host is enrolled in a WSS
  101. * WLP_WSS_STATE_ACTIVE: WSS is activated
  102. * WLP_WSS_STATE_CONNECTED: host is connected to neighbor in WSS
  103. *
  104. */
  105. enum wlp_wss_state {
  106. WLP_WSS_STATE_NONE = 0,
  107. WLP_WSS_STATE_PART_ENROLLED,
  108. WLP_WSS_STATE_ENROLLED,
  109. WLP_WSS_STATE_ACTIVE,
  110. WLP_WSS_STATE_CONNECTED,
  111. };
  112. /**
  113. * WSS Secure status
  114. * WLP 0.99 Table 6
  115. *
  116. * Set to one if the WSS is secure, zero if it is not secure
  117. */
  118. enum wlp_wss_sec_status {
  119. WLP_WSS_UNSECURE = 0,
  120. WLP_WSS_SECURE,
  121. };
  122. /**
  123. * WLP frame type
  124. * WLP Draft 0.99 [6.2 Table 1]
  125. */
  126. enum wlp_frame_type {
  127. WLP_FRAME_STANDARD = 0,
  128. WLP_FRAME_ABBREVIATED,
  129. WLP_FRAME_CONTROL,
  130. WLP_FRAME_ASSOCIATION,
  131. };
  132. /**
  133. * WLP Association Message Type
  134. * WLP Draft 0.99 [6.6.1.2 Table 8]
  135. */
  136. enum wlp_assoc_type {
  137. WLP_ASSOC_D1 = 2,
  138. WLP_ASSOC_D2 = 3,
  139. WLP_ASSOC_M1 = 4,
  140. WLP_ASSOC_M2 = 5,
  141. WLP_ASSOC_M3 = 7,
  142. WLP_ASSOC_M4 = 8,
  143. WLP_ASSOC_M5 = 9,
  144. WLP_ASSOC_M6 = 10,
  145. WLP_ASSOC_M7 = 11,
  146. WLP_ASSOC_M8 = 12,
  147. WLP_ASSOC_F0 = 14,
  148. WLP_ASSOC_E1 = 32,
  149. WLP_ASSOC_E2 = 33,
  150. WLP_ASSOC_C1 = 34,
  151. WLP_ASSOC_C2 = 35,
  152. WLP_ASSOC_C3 = 36,
  153. WLP_ASSOC_C4 = 37,
  154. };
  155. /**
  156. * WLP Attribute Type
  157. * WLP Draft 0.99 [6.6.1 Table 6]
  158. */
  159. enum wlp_attr_type {
  160. WLP_ATTR_AUTH = 0x1005, /* Authenticator */
  161. WLP_ATTR_DEV_NAME = 0x1011, /* Device Name */
  162. WLP_ATTR_DEV_PWD_ID = 0x1012, /* Device Password ID */
  163. WLP_ATTR_E_HASH1 = 0x1014, /* E-Hash1 */
  164. WLP_ATTR_E_HASH2 = 0x1015, /* E-Hash2 */
  165. WLP_ATTR_E_SNONCE1 = 0x1016, /* E-SNonce1 */
  166. WLP_ATTR_E_SNONCE2 = 0x1017, /* E-SNonce2 */
  167. WLP_ATTR_ENCR_SET = 0x1018, /* Encrypted Settings */
  168. WLP_ATTR_ENRL_NONCE = 0x101A, /* Enrollee Nonce */
  169. WLP_ATTR_KEYWRAP_AUTH = 0x101E, /* Key Wrap Authenticator */
  170. WLP_ATTR_MANUF = 0x1021, /* Manufacturer */
  171. WLP_ATTR_MSG_TYPE = 0x1022, /* Message Type */
  172. WLP_ATTR_MODEL_NAME = 0x1023, /* Model Name */
  173. WLP_ATTR_MODEL_NR = 0x1024, /* Model Number */
  174. WLP_ATTR_PUB_KEY = 0x1032, /* Public Key */
  175. WLP_ATTR_REG_NONCE = 0x1039, /* Registrar Nonce */
  176. WLP_ATTR_R_HASH1 = 0x103D, /* R-Hash1 */
  177. WLP_ATTR_R_HASH2 = 0x103E, /* R-Hash2 */
  178. WLP_ATTR_R_SNONCE1 = 0x103F, /* R-SNonce1 */
  179. WLP_ATTR_R_SNONCE2 = 0x1040, /* R-SNonce2 */
  180. WLP_ATTR_SERIAL = 0x1042, /* Serial number */
  181. WLP_ATTR_UUID_E = 0x1047, /* UUID-E */
  182. WLP_ATTR_UUID_R = 0x1048, /* UUID-R */
  183. WLP_ATTR_PRI_DEV_TYPE = 0x1054, /* Primary Device Type */
  184. WLP_ATTR_SEC_DEV_TYPE = 0x1055, /* Secondary Device Type */
  185. WLP_ATTR_PORT_DEV = 0x1056, /* Portable Device */
  186. WLP_ATTR_APP_EXT = 0x1058, /* Application Extension */
  187. WLP_ATTR_WLP_VER = 0x2000, /* WLP Version */
  188. WLP_ATTR_WSSID = 0x2001, /* WSSID */
  189. WLP_ATTR_WSS_NAME = 0x2002, /* WSS Name */
  190. WLP_ATTR_WSS_SEC_STAT = 0x2003, /* WSS Secure Status */
  191. WLP_ATTR_WSS_BCAST = 0x2004, /* WSS Broadcast Address */
  192. WLP_ATTR_WSS_M_KEY = 0x2005, /* WSS Master Key */
  193. WLP_ATTR_ACC_ENRL = 0x2006, /* Accepting Enrollment */
  194. WLP_ATTR_WSS_INFO = 0x2007, /* WSS Information */
  195. WLP_ATTR_WSS_SEL_MTHD = 0x2008, /* WSS Selection Method */
  196. WLP_ATTR_ASSC_MTHD_LIST = 0x2009, /* Association Methods List */
  197. WLP_ATTR_SEL_ASSC_MTHD = 0x200A, /* Selected Association Method */
  198. WLP_ATTR_ENRL_HASH_COMM = 0x200B, /* Enrollee Hash Commitment */
  199. WLP_ATTR_WSS_TAG = 0x200C, /* WSS Tag */
  200. WLP_ATTR_WSS_VIRT = 0x200D, /* WSS Virtual EUI-48 */
  201. WLP_ATTR_WLP_ASSC_ERR = 0x200E, /* WLP Association Error */
  202. WLP_ATTR_VNDR_EXT = 0x200F, /* Vendor Extension */
  203. };
  204. /**
  205. * WLP Category ID of primary/secondary device
  206. * WLP Draft 0.99 [6.6.1.8 Table 12]
  207. */
  208. enum wlp_dev_category_id {
  209. WLP_DEV_CAT_COMPUTER = 1,
  210. WLP_DEV_CAT_INPUT,
  211. WLP_DEV_CAT_PRINT_SCAN_FAX_COPIER,
  212. WLP_DEV_CAT_CAMERA,
  213. WLP_DEV_CAT_STORAGE,
  214. WLP_DEV_CAT_INFRASTRUCTURE,
  215. WLP_DEV_CAT_DISPLAY,
  216. WLP_DEV_CAT_MULTIM,
  217. WLP_DEV_CAT_GAMING,
  218. WLP_DEV_CAT_TELEPHONE,
  219. WLP_DEV_CAT_OTHER = 65535,
  220. };
  221. /**
  222. * WLP WSS selection method
  223. * WLP Draft 0.99 [6.6.1.6 Table 10]
  224. */
  225. enum wlp_wss_sel_mthd {
  226. WLP_WSS_ENRL_SELECT = 1, /* Enrollee selects */
  227. WLP_WSS_REG_SELECT, /* Registrar selects */
  228. };
  229. /**
  230. * WLP association error values
  231. * WLP Draft 0.99 [6.6.1.5 Table 9]
  232. */
  233. enum wlp_assc_error {
  234. WLP_ASSOC_ERROR_NONE,
  235. WLP_ASSOC_ERROR_AUTH, /* Authenticator Failure */
  236. WLP_ASSOC_ERROR_ROGUE, /* Rogue activity suspected */
  237. WLP_ASSOC_ERROR_BUSY, /* Device busy */
  238. WLP_ASSOC_ERROR_LOCK, /* Setup Locked */
  239. WLP_ASSOC_ERROR_NOT_READY, /* Registrar not ready */
  240. WLP_ASSOC_ERROR_INV, /* Invalid WSS selection */
  241. WLP_ASSOC_ERROR_MSG_TIME, /* Message timeout */
  242. WLP_ASSOC_ERROR_ENR_TIME, /* Enrollment session timeout */
  243. WLP_ASSOC_ERROR_PW, /* Device password invalid */
  244. WLP_ASSOC_ERROR_VER, /* Unsupported version */
  245. WLP_ASSOC_ERROR_INT, /* Internal error */
  246. WLP_ASSOC_ERROR_UNDEF, /* Undefined error */
  247. WLP_ASSOC_ERROR_NUM, /* Numeric comparison failure */
  248. WLP_ASSOC_ERROR_WAIT, /* Waiting for user input */
  249. };
  250. /**
  251. * WLP Parameters
  252. * WLP 0.99 [7.7]
  253. */
  254. enum wlp_parameters {
  255. WLP_PER_MSG_TIMEOUT = 15, /* Seconds to wait for response to
  256. association message. */
  257. };
  258. /**
  259. * WLP IE
  260. *
  261. * The WLP IE should be included in beacons by all devices.
  262. *
  263. * The driver can set only a few of the fields in this information element,
  264. * most fields are managed by the device self. When the driver needs to set
  265. * a field it will only provide values for the fields of interest, the rest
  266. * will be filled with zeroes. The fields of interest are:
  267. *
  268. * Element ID
  269. * Length
  270. * Capabilities (only to include WSSID Hash list length)
  271. * WSSID Hash List fields
  272. *
  273. * WLP 0.99 [6.7]
  274. *
  275. * Only the fields that will be used are detailed in this structure, rest
  276. * are not detailed or marked as "notused".
  277. */
  278. struct wlp_ie {
  279. struct uwb_ie_hdr hdr;
  280. __le16 capabilities;
  281. __le16 cycle_param;
  282. __le16 acw_anchor_addr;
  283. u8 wssid_hash_list[];
  284. } __packed;
  285. static inline int wlp_ie_hash_length(struct wlp_ie *ie)
  286. {
  287. return (le16_to_cpu(ie->capabilities) >> 12) & 0xf;
  288. }
  289. static inline void wlp_ie_set_hash_length(struct wlp_ie *ie, int hash_length)
  290. {
  291. u16 caps = le16_to_cpu(ie->capabilities);
  292. caps = (caps & ~(0xf << 12)) | (hash_length << 12);
  293. ie->capabilities = cpu_to_le16(caps);
  294. }
  295. /**
  296. * WLP nonce
  297. * WLP Draft 0.99 [6.6.1 Table 6]
  298. *
  299. * A 128-bit random number often used (E-SNonce1, E-SNonce2, Enrollee
  300. * Nonce, Registrar Nonce, R-SNonce1, R-SNonce2). It is passed to HW so
  301. * it is packed.
  302. */
  303. struct wlp_nonce {
  304. u8 data[16];
  305. } __packed;
  306. /**
  307. * WLP UUID
  308. * WLP Draft 0.99 [6.6.1 Table 6]
  309. *
  310. * Universally Unique Identifier (UUID) encoded as an octet string in the
  311. * order the octets are shown in string representation in RFC4122. A UUID
  312. * is often used (UUID-E, UUID-R, WSSID). It is passed to HW so it is packed.
  313. */
  314. struct wlp_uuid {
  315. u8 data[16];
  316. } __packed;
  317. /**
  318. * Primary and secondary device type attributes
  319. * WLP Draft 0.99 [6.6.1.8]
  320. */
  321. struct wlp_dev_type {
  322. enum wlp_dev_category_id category:16;
  323. u8 OUI[3];
  324. u8 OUIsubdiv;
  325. __le16 subID;
  326. } __packed;
  327. /**
  328. * WLP frame header
  329. * WLP Draft 0.99 [6.2]
  330. */
  331. struct wlp_frame_hdr {
  332. __le16 mux_hdr; /* WLP_PROTOCOL_ID */
  333. enum wlp_frame_type type:8;
  334. } __packed;
  335. /**
  336. * WLP attribute field header
  337. * WLP Draft 0.99 [6.6.1]
  338. *
  339. * Header of each attribute found in an association frame
  340. */
  341. struct wlp_attr_hdr {
  342. __le16 type;
  343. __le16 length;
  344. } __packed;
  345. /**
  346. * Device information commonly used together
  347. *
  348. * Each of these device information elements has a specified range in which it
  349. * should fit (WLP 0.99 [Table 6]). This range provided in the spec does not
  350. * include the termination null '\0' character (when used in the
  351. * association protocol the attribute fields are accompanied
  352. * with a "length" field so the full range from the spec can be used for
  353. * the value). We thus allocate an extra byte to be able to store a string
  354. * of max length with a terminating '\0'.
  355. */
  356. struct wlp_device_info {
  357. char name[33];
  358. char model_name[33];
  359. char manufacturer[65];
  360. char model_nr[33];
  361. char serial[33];
  362. struct wlp_dev_type prim_dev_type;
  363. };
  364. /**
  365. * Macros for the WLP attributes
  366. *
  367. * There are quite a few attributes (total is 43). The attribute layout can be
  368. * in one of three categories: one value, an array, an enum forced to 8 bits.
  369. * These macros help with their definitions.
  370. */
  371. #define wlp_attr(type, name) \
  372. struct wlp_attr_##name { \
  373. struct wlp_attr_hdr hdr; \
  374. type name; \
  375. } __packed;
  376. #define wlp_attr_array(type, name) \
  377. struct wlp_attr_##name { \
  378. struct wlp_attr_hdr hdr; \
  379. type name[]; \
  380. } __packed;
  381. /**
  382. * WLP association attribute fields
  383. * WLP Draft 0.99 [6.6.1 Table 6]
  384. *
  385. * Attributes appear in same order as the Table in the spec
  386. * FIXME Does not define all attributes yet
  387. */
  388. /* Device name: Friendly name of sending device */
  389. wlp_attr_array(u8, dev_name)
  390. /* Enrollee Nonce: Random number generated by enrollee for an enrollment
  391. * session */
  392. wlp_attr(struct wlp_nonce, enonce)
  393. /* Manufacturer name: Name of manufacturer of the sending device */
  394. wlp_attr_array(u8, manufacturer)
  395. /* WLP Message Type */
  396. wlp_attr(u8, msg_type)
  397. /* WLP Model name: Model name of sending device */
  398. wlp_attr_array(u8, model_name)
  399. /* WLP Model number: Model number of sending device */
  400. wlp_attr_array(u8, model_nr)
  401. /* Registrar Nonce: Random number generated by registrar for an enrollment
  402. * session */
  403. wlp_attr(struct wlp_nonce, rnonce)
  404. /* Serial number of device */
  405. wlp_attr_array(u8, serial)
  406. /* UUID of enrollee */
  407. wlp_attr(struct wlp_uuid, uuid_e)
  408. /* UUID of registrar */
  409. wlp_attr(struct wlp_uuid, uuid_r)
  410. /* WLP Primary device type */
  411. wlp_attr(struct wlp_dev_type, prim_dev_type)
  412. /* WLP Secondary device type */
  413. wlp_attr(struct wlp_dev_type, sec_dev_type)
  414. /* WLP protocol version */
  415. wlp_attr(u8, version)
  416. /* WLP service set identifier */
  417. wlp_attr(struct wlp_uuid, wssid)
  418. /* WLP WSS name */
  419. wlp_attr_array(u8, wss_name)
  420. /* WLP WSS Secure Status */
  421. wlp_attr(u8, wss_sec_status)
  422. /* WSS Broadcast Address */
  423. wlp_attr(struct uwb_mac_addr, wss_bcast)
  424. /* WLP Accepting Enrollment */
  425. wlp_attr(u8, accept_enrl)
  426. /**
  427. * WSS information attributes
  428. * WLP Draft 0.99 [6.6.3 Table 15]
  429. */
  430. struct wlp_wss_info {
  431. struct wlp_attr_wssid wssid;
  432. struct wlp_attr_wss_name name;
  433. struct wlp_attr_accept_enrl accept;
  434. struct wlp_attr_wss_sec_status sec_stat;
  435. struct wlp_attr_wss_bcast bcast;
  436. } __packed;
  437. /* WLP WSS Information */
  438. wlp_attr_array(struct wlp_wss_info, wss_info)
  439. /* WLP WSS Selection method */
  440. wlp_attr(u8, wss_sel_mthd)
  441. /* WLP WSS tag */
  442. wlp_attr(u8, wss_tag)
  443. /* WSS Virtual Address */
  444. wlp_attr(struct uwb_mac_addr, wss_virt)
  445. /* WLP association error */
  446. wlp_attr(u8, wlp_assc_err)
  447. /**
  448. * WLP standard and abbreviated frames
  449. *
  450. * WLP Draft 0.99 [6.3] and [6.4]
  451. *
  452. * The difference between the WLP standard frame and the WLP
  453. * abbreviated frame is that the standard frame includes the src
  454. * and dest addresses from the Ethernet header, the abbreviated frame does
  455. * not.
  456. * The src/dest (as well as the type/length and client data) are already
  457. * defined as part of the Ethernet header, we do not do this here.
  458. * From this perspective the standard and abbreviated frames appear the
  459. * same - they will be treated differently though.
  460. *
  461. * The size of this header is also captured in WLP_DATA_HLEN to enable
  462. * interfaces to prepare their headroom.
  463. */
  464. struct wlp_frame_std_abbrv_hdr {
  465. struct wlp_frame_hdr hdr;
  466. u8 tag;
  467. } __packed;
  468. /**
  469. * WLP association frames
  470. *
  471. * WLP Draft 0.99 [6.6]
  472. */
  473. struct wlp_frame_assoc {
  474. struct wlp_frame_hdr hdr;
  475. enum wlp_assoc_type type:8;
  476. struct wlp_attr_version version;
  477. struct wlp_attr_msg_type msg_type;
  478. u8 attr[];
  479. } __packed;
  480. /* Ethernet to dev address mapping */
  481. struct wlp_eda {
  482. spinlock_t lock;
  483. struct list_head cache; /* Eth<->Dev Addr cache */
  484. };
  485. /**
  486. * WSS information temporary storage
  487. *
  488. * This information is only stored temporarily during discovery. It should
  489. * not be stored unless the device is enrolled in the advertised WSS. This
  490. * is done mainly because we follow the letter of the spec in this regard.
  491. * See WLP 0.99 [7.2.3].
  492. * When the device does become enrolled in a WSS the WSS information will
  493. * be stored as part of the more comprehensive struct wlp_wss.
  494. */
  495. struct wlp_wss_tmp_info {
  496. char name[WLP_WSS_NAME_SIZE];
  497. u8 accept_enroll;
  498. u8 sec_status;
  499. struct uwb_mac_addr bcast;
  500. };
  501. struct wlp_wssid_e {
  502. struct list_head node;
  503. struct wlp_uuid wssid;
  504. struct wlp_wss_tmp_info *info;
  505. };
  506. /**
  507. * A cache entry of WLP neighborhood
  508. *
  509. * @node: head of list is wlp->neighbors
  510. * @wssid: list of wssids of this neighbor, element is wlp_wssid_e
  511. * @info: temporary storage for information learned during discovery. This
  512. * storage is used together with the wssid_e temporary storage
  513. * during discovery.
  514. */
  515. struct wlp_neighbor_e {
  516. struct list_head node;
  517. struct wlp_uuid uuid;
  518. struct uwb_dev *uwb_dev;
  519. struct list_head wssid; /* Elements are wlp_wssid_e */
  520. struct wlp_device_info *info;
  521. };
  522. struct wlp;
  523. /**
  524. * Information for an association session in progress.
  525. *
  526. * @exp_message: The type of the expected message. Both this message and a
  527. * F0 message (which can be sent in response to any
  528. * association frame) will be accepted as a valid message for
  529. * this session.
  530. * @cb: The function that will be called upon receipt of this
  531. * message.
  532. * @cb_priv: Private data of callback
  533. * @data: Data used in association process (always a sk_buff?)
  534. * @neighbor: Address of neighbor with which association session is in
  535. * progress.
  536. */
  537. struct wlp_session {
  538. enum wlp_assoc_type exp_message;
  539. void (*cb)(struct wlp *);
  540. void *cb_priv;
  541. void *data;
  542. struct uwb_dev_addr neighbor_addr;
  543. };
  544. /**
  545. * WLP Service Set
  546. *
  547. * @mutex: used to protect entire WSS structure.
  548. *
  549. * @name: The WSS name is set to 65 bytes, 1 byte larger than the maximum
  550. * allowed by the WLP spec. This is to have a null terminated string
  551. * for display to the user. A maximum of 64 bytes will still be used
  552. * when placing the WSS name field in association frames.
  553. *
  554. * @accept_enroll: Accepting enrollment: Set to one if registrar is
  555. * accepting enrollment in WSS, or zero otherwise.
  556. *
  557. * Global and local information for each WSS in which we are enrolled.
  558. * WLP 0.99 Section 7.2.1 and Section 7.2.2
  559. */
  560. struct wlp_wss {
  561. struct mutex mutex;
  562. struct kobject kobj;
  563. /* Global properties. */
  564. struct wlp_uuid wssid;
  565. u8 hash;
  566. char name[WLP_WSS_NAME_SIZE];
  567. struct uwb_mac_addr bcast;
  568. u8 secure_status:1;
  569. u8 master_key[16];
  570. /* Local properties. */
  571. u8 tag;
  572. struct uwb_mac_addr virtual_addr;
  573. /* Extra */
  574. u8 accept_enroll:1;
  575. enum wlp_wss_state state;
  576. };
  577. /**
  578. * WLP main structure
  579. * @mutex: protect changes to WLP structure. We only allow changes to the
  580. * uuid, so currently this mutex only protects this field.
  581. */
  582. struct wlp {
  583. struct mutex mutex;
  584. struct uwb_rc *rc; /* UWB radio controller */
  585. struct net_device *ndev;
  586. struct uwb_pal pal;
  587. struct wlp_eda eda;
  588. struct wlp_uuid uuid;
  589. struct wlp_session *session;
  590. struct wlp_wss wss;
  591. struct mutex nbmutex; /* Neighbor mutex protects neighbors list */
  592. struct list_head neighbors; /* Elements are wlp_neighbor_e */
  593. struct uwb_notifs_handler uwb_notifs_handler;
  594. struct wlp_device_info *dev_info;
  595. void (*fill_device_info)(struct wlp *wlp, struct wlp_device_info *info);
  596. int (*xmit_frame)(struct wlp *, struct sk_buff *,
  597. struct uwb_dev_addr *);
  598. void (*stop_queue)(struct wlp *);
  599. void (*start_queue)(struct wlp *);
  600. };
  601. /* sysfs */
  602. struct wlp_wss_attribute {
  603. struct attribute attr;
  604. ssize_t (*show)(struct wlp_wss *wss, char *buf);
  605. ssize_t (*store)(struct wlp_wss *wss, const char *buf, size_t count);
  606. };
  607. #define WSS_ATTR(_name, _mode, _show, _store) \
  608. static struct wlp_wss_attribute wss_attr_##_name = __ATTR(_name, _mode, \
  609. _show, _store)
  610. extern int wlp_setup(struct wlp *, struct uwb_rc *, struct net_device *ndev);
  611. extern void wlp_remove(struct wlp *);
  612. extern ssize_t wlp_neighborhood_show(struct wlp *, char *);
  613. extern int wlp_wss_setup(struct net_device *, struct wlp_wss *);
  614. extern void wlp_wss_remove(struct wlp_wss *);
  615. extern ssize_t wlp_wss_activate_show(struct wlp_wss *, char *);
  616. extern ssize_t wlp_wss_activate_store(struct wlp_wss *, const char *, size_t);
  617. extern ssize_t wlp_eda_show(struct wlp *, char *);
  618. extern ssize_t wlp_eda_store(struct wlp *, const char *, size_t);
  619. extern ssize_t wlp_uuid_show(struct wlp *, char *);
  620. extern ssize_t wlp_uuid_store(struct wlp *, const char *, size_t);
  621. extern ssize_t wlp_dev_name_show(struct wlp *, char *);
  622. extern ssize_t wlp_dev_name_store(struct wlp *, const char *, size_t);
  623. extern ssize_t wlp_dev_manufacturer_show(struct wlp *, char *);
  624. extern ssize_t wlp_dev_manufacturer_store(struct wlp *, const char *, size_t);
  625. extern ssize_t wlp_dev_model_name_show(struct wlp *, char *);
  626. extern ssize_t wlp_dev_model_name_store(struct wlp *, const char *, size_t);
  627. extern ssize_t wlp_dev_model_nr_show(struct wlp *, char *);
  628. extern ssize_t wlp_dev_model_nr_store(struct wlp *, const char *, size_t);
  629. extern ssize_t wlp_dev_serial_show(struct wlp *, char *);
  630. extern ssize_t wlp_dev_serial_store(struct wlp *, const char *, size_t);
  631. extern ssize_t wlp_dev_prim_category_show(struct wlp *, char *);
  632. extern ssize_t wlp_dev_prim_category_store(struct wlp *, const char *,
  633. size_t);
  634. extern ssize_t wlp_dev_prim_OUI_show(struct wlp *, char *);
  635. extern ssize_t wlp_dev_prim_OUI_store(struct wlp *, const char *, size_t);
  636. extern ssize_t wlp_dev_prim_OUI_sub_show(struct wlp *, char *);
  637. extern ssize_t wlp_dev_prim_OUI_sub_store(struct wlp *, const char *,
  638. size_t);
  639. extern ssize_t wlp_dev_prim_subcat_show(struct wlp *, char *);
  640. extern ssize_t wlp_dev_prim_subcat_store(struct wlp *, const char *,
  641. size_t);
  642. extern int wlp_receive_frame(struct device *, struct wlp *, struct sk_buff *,
  643. struct uwb_dev_addr *);
  644. extern int wlp_prepare_tx_frame(struct device *, struct wlp *,
  645. struct sk_buff *, struct uwb_dev_addr *);
  646. void wlp_reset_all(struct wlp *wlp);
  647. /**
  648. * Initialize WSS
  649. */
  650. static inline
  651. void wlp_wss_init(struct wlp_wss *wss)
  652. {
  653. mutex_init(&wss->mutex);
  654. }
  655. static inline
  656. void wlp_init(struct wlp *wlp)
  657. {
  658. INIT_LIST_HEAD(&wlp->neighbors);
  659. mutex_init(&wlp->mutex);
  660. mutex_init(&wlp->nbmutex);
  661. wlp_wss_init(&wlp->wss);
  662. }
  663. #endif /* #ifndef __LINUX__WLP_H_ */