wlp-internal.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * WiMedia Logical Link Control Protocol (WLP)
  3. * Internal API
  4. *
  5. * Copyright (C) 2007 Intel Corporation
  6. * Reinette Chatre <reinette.chatre@intel.com>
  7. *
  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.
  11. *
  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.
  16. *
  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
  20. * 02110-1301, USA.
  21. *
  22. */
  23. #ifndef __WLP_INTERNAL_H__
  24. #define __WLP_INTERNAL_H__
  25. /**
  26. * State of WSS connection
  27. *
  28. * A device needs to connect to a neighbor in an activated WSS before data
  29. * can be transmitted. The spec also distinguishes between a new connection
  30. * attempt and a connection attempt after previous connection attempts. The
  31. * state WLP_WSS_CONNECT_FAILED is used for this scenario. See WLP 0.99
  32. * [7.2.6]
  33. */
  34. enum wlp_wss_connect {
  35. WLP_WSS_UNCONNECTED = 0,
  36. WLP_WSS_CONNECTED,
  37. WLP_WSS_CONNECT_FAILED,
  38. };
  39. extern struct kobj_type wss_ktype;
  40. extern struct attribute_group wss_attr_group;
  41. extern int uwb_rc_ie_add(struct uwb_rc *, const struct uwb_ie_hdr *, size_t);
  42. extern int uwb_rc_ie_rm(struct uwb_rc *, enum uwb_ie);
  43. /* This should be changed to a dynamic array where entries are sorted
  44. * by eth_addr and search is done in a binary form
  45. *
  46. * Although thinking twice about it: this technologie's maximum reach
  47. * is 10 meters...unless you want to pack too much stuff in around
  48. * your radio controller/WLP device, the list will probably not be
  49. * too big.
  50. *
  51. * In any case, there is probably some data structure in the kernel
  52. * than we could reused for that already.
  53. *
  54. * The below structure is really just good while we support one WSS per
  55. * host.
  56. */
  57. struct wlp_eda_node {
  58. struct list_head list_node;
  59. unsigned char eth_addr[ETH_ALEN];
  60. struct uwb_dev_addr dev_addr;
  61. struct wlp_wss *wss;
  62. unsigned char virt_addr[ETH_ALEN];
  63. u8 tag;
  64. enum wlp_wss_connect state;
  65. };
  66. typedef int (*wlp_eda_for_each_f)(struct wlp *, struct wlp_eda_node *, void *);
  67. extern void wlp_eda_init(struct wlp_eda *);
  68. extern void wlp_eda_release(struct wlp_eda *);
  69. extern int wlp_eda_create_node(struct wlp_eda *,
  70. const unsigned char eth_addr[ETH_ALEN],
  71. const struct uwb_dev_addr *);
  72. extern void wlp_eda_rm_node(struct wlp_eda *, const struct uwb_dev_addr *);
  73. extern int wlp_eda_update_node(struct wlp_eda *,
  74. const struct uwb_dev_addr *,
  75. struct wlp_wss *,
  76. const unsigned char virt_addr[ETH_ALEN],
  77. const u8, const enum wlp_wss_connect);
  78. extern int wlp_eda_update_node_state(struct wlp_eda *,
  79. const struct uwb_dev_addr *,
  80. const enum wlp_wss_connect);
  81. extern int wlp_copy_eda_node(struct wlp_eda *, struct uwb_dev_addr *,
  82. struct wlp_eda_node *);
  83. extern int wlp_eda_for_each(struct wlp_eda *, wlp_eda_for_each_f , void *);
  84. extern int wlp_eda_for_virtual(struct wlp_eda *,
  85. const unsigned char eth_addr[ETH_ALEN],
  86. struct uwb_dev_addr *,
  87. wlp_eda_for_each_f , void *);
  88. extern void wlp_remove_neighbor_tmp_info(struct wlp_neighbor_e *);
  89. extern size_t wlp_wss_key_print(char *, size_t, u8 *);
  90. /* Function called when no more references to WSS exists */
  91. extern void wlp_wss_release(struct kobject *);
  92. extern void wlp_wss_reset(struct wlp_wss *);
  93. extern int wlp_wss_create_activate(struct wlp_wss *, struct wlp_uuid *,
  94. char *, unsigned, unsigned);
  95. extern int wlp_wss_enroll_activate(struct wlp_wss *, struct wlp_uuid *,
  96. struct uwb_dev_addr *);
  97. extern ssize_t wlp_discover(struct wlp *);
  98. extern int wlp_enroll_neighbor(struct wlp *, struct wlp_neighbor_e *,
  99. struct wlp_wss *, struct wlp_uuid *);
  100. extern int wlp_wss_is_active(struct wlp *, struct wlp_wss *,
  101. struct uwb_dev_addr *);
  102. struct wlp_assoc_conn_ctx {
  103. struct work_struct ws;
  104. struct wlp *wlp;
  105. struct sk_buff *skb;
  106. struct wlp_eda_node eda_entry;
  107. };
  108. extern int wlp_wss_connect_prep(struct wlp *, struct wlp_eda_node *, void *);
  109. extern int wlp_wss_send_copy(struct wlp *, struct wlp_eda_node *, void *);
  110. /* Message handling */
  111. struct wlp_assoc_frame_ctx {
  112. struct work_struct ws;
  113. struct wlp *wlp;
  114. struct sk_buff *skb;
  115. struct uwb_dev_addr src;
  116. };
  117. extern int wlp_wss_prep_hdr(struct wlp *, struct wlp_eda_node *, void *);
  118. extern void wlp_handle_d1_frame(struct work_struct *);
  119. extern int wlp_parse_d2_frame_to_cache(struct wlp *, struct sk_buff *,
  120. struct wlp_neighbor_e *);
  121. extern int wlp_parse_d2_frame_to_enroll(struct wlp_wss *, struct sk_buff *,
  122. struct wlp_neighbor_e *,
  123. struct wlp_uuid *);
  124. extern void wlp_handle_c1_frame(struct work_struct *);
  125. extern void wlp_handle_c3_frame(struct work_struct *);
  126. extern int wlp_parse_c3c4_frame(struct wlp *, struct sk_buff *,
  127. struct wlp_uuid *, u8 *,
  128. struct uwb_mac_addr *);
  129. extern int wlp_parse_f0(struct wlp *, struct sk_buff *);
  130. extern int wlp_send_assoc_frame(struct wlp *, struct wlp_wss *,
  131. struct uwb_dev_addr *, enum wlp_assoc_type);
  132. extern ssize_t wlp_get_version(struct wlp *, struct wlp_attr_version *,
  133. u8 *, ssize_t);
  134. extern ssize_t wlp_get_wssid(struct wlp *, struct wlp_attr_wssid *,
  135. struct wlp_uuid *, ssize_t);
  136. extern int __wlp_alloc_device_info(struct wlp *);
  137. extern int __wlp_setup_device_info(struct wlp *);
  138. extern struct wlp_wss_attribute wss_attribute_properties;
  139. extern struct wlp_wss_attribute wss_attribute_members;
  140. extern struct wlp_wss_attribute wss_attribute_state;
  141. static inline
  142. size_t wlp_wss_uuid_print(char *buf, size_t bufsize, struct wlp_uuid *uuid)
  143. {
  144. size_t result;
  145. result = scnprintf(buf, bufsize,
  146. "%02x:%02x:%02x:%02x:%02x:%02x:"
  147. "%02x:%02x:%02x:%02x:%02x:%02x:"
  148. "%02x:%02x:%02x:%02x",
  149. uuid->data[0], uuid->data[1],
  150. uuid->data[2], uuid->data[3],
  151. uuid->data[4], uuid->data[5],
  152. uuid->data[6], uuid->data[7],
  153. uuid->data[8], uuid->data[9],
  154. uuid->data[10], uuid->data[11],
  155. uuid->data[12], uuid->data[13],
  156. uuid->data[14], uuid->data[15]);
  157. return result;
  158. }
  159. /**
  160. * FIXME: How should a nonce be displayed?
  161. */
  162. static inline
  163. size_t wlp_wss_nonce_print(char *buf, size_t bufsize, struct wlp_nonce *nonce)
  164. {
  165. size_t result;
  166. result = scnprintf(buf, bufsize,
  167. "%02x %02x %02x %02x %02x %02x "
  168. "%02x %02x %02x %02x %02x %02x "
  169. "%02x %02x %02x %02x",
  170. nonce->data[0], nonce->data[1],
  171. nonce->data[2], nonce->data[3],
  172. nonce->data[4], nonce->data[5],
  173. nonce->data[6], nonce->data[7],
  174. nonce->data[8], nonce->data[9],
  175. nonce->data[10], nonce->data[11],
  176. nonce->data[12], nonce->data[13],
  177. nonce->data[14], nonce->data[15]);
  178. return result;
  179. }
  180. static inline
  181. void wlp_session_cb(struct wlp *wlp)
  182. {
  183. struct completion *completion = wlp->session->cb_priv;
  184. complete(completion);
  185. }
  186. static inline
  187. int wlp_uuid_is_set(struct wlp_uuid *uuid)
  188. {
  189. struct wlp_uuid zero_uuid = { .data = { 0x00, 0x00, 0x00, 0x00,
  190. 0x00, 0x00, 0x00, 0x00,
  191. 0x00, 0x00, 0x00, 0x00,
  192. 0x00, 0x00, 0x00, 0x00} };
  193. if (!memcmp(uuid, &zero_uuid, sizeof(*uuid)))
  194. return 0;
  195. return 1;
  196. }
  197. #endif /* __WLP_INTERNAL_H__ */