rndis_host.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * Host Side support for RNDIS Networking Links
  3. * Copyright (C) 2005 by David Brownell
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __LINUX_USB_RNDIS_HOST_H
  20. #define __LINUX_USB_RNDIS_HOST_H
  21. #include <linux/rndis.h>
  22. /*
  23. * CONTROL uses CDC "encapsulated commands" with funky notifications.
  24. * - control-out: SEND_ENCAPSULATED
  25. * - interrupt-in: RESPONSE_AVAILABLE
  26. * - control-in: GET_ENCAPSULATED
  27. *
  28. * We'll try to ignore the RESPONSE_AVAILABLE notifications.
  29. *
  30. * REVISIT some RNDIS implementations seem to have curious issues still
  31. * to be resolved.
  32. */
  33. struct rndis_msg_hdr {
  34. __le32 msg_type; /* RNDIS_MSG_* */
  35. __le32 msg_len;
  36. /* followed by data that varies between messages */
  37. __le32 request_id;
  38. __le32 status;
  39. /* ... and more */
  40. } __attribute__ ((packed));
  41. /* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */
  42. #define CONTROL_BUFFER_SIZE 1025
  43. /* RNDIS defines an (absurdly huge) 10 second control timeout,
  44. * but ActiveSync seems to use a more usual 5 second timeout
  45. * (which matches the USB 2.0 spec).
  46. */
  47. #define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000)
  48. struct rndis_data_hdr {
  49. __le32 msg_type; /* RNDIS_MSG_PACKET */
  50. __le32 msg_len; /* rndis_data_hdr + data_len + pad */
  51. __le32 data_offset; /* 36 -- right after header */
  52. __le32 data_len; /* ... real packet size */
  53. __le32 oob_data_offset; /* zero */
  54. __le32 oob_data_len; /* zero */
  55. __le32 num_oob; /* zero */
  56. __le32 packet_data_offset; /* zero */
  57. __le32 packet_data_len; /* zero */
  58. __le32 vc_handle; /* zero */
  59. __le32 reserved; /* zero */
  60. } __attribute__ ((packed));
  61. struct rndis_init { /* OUT */
  62. /* header and: */
  63. __le32 msg_type; /* RNDIS_MSG_INIT */
  64. __le32 msg_len; /* 24 */
  65. __le32 request_id;
  66. __le32 major_version; /* of rndis (1.0) */
  67. __le32 minor_version;
  68. __le32 max_transfer_size;
  69. } __attribute__ ((packed));
  70. struct rndis_init_c { /* IN */
  71. /* header and: */
  72. __le32 msg_type; /* RNDIS_MSG_INIT_C */
  73. __le32 msg_len;
  74. __le32 request_id;
  75. __le32 status;
  76. __le32 major_version; /* of rndis (1.0) */
  77. __le32 minor_version;
  78. __le32 device_flags;
  79. __le32 medium; /* zero == 802.3 */
  80. __le32 max_packets_per_message;
  81. __le32 max_transfer_size;
  82. __le32 packet_alignment; /* max 7; (1<<n) bytes */
  83. __le32 af_list_offset; /* zero */
  84. __le32 af_list_size; /* zero */
  85. } __attribute__ ((packed));
  86. struct rndis_halt { /* OUT (no reply) */
  87. /* header and: */
  88. __le32 msg_type; /* RNDIS_MSG_HALT */
  89. __le32 msg_len;
  90. __le32 request_id;
  91. } __attribute__ ((packed));
  92. struct rndis_query { /* OUT */
  93. /* header and: */
  94. __le32 msg_type; /* RNDIS_MSG_QUERY */
  95. __le32 msg_len;
  96. __le32 request_id;
  97. __le32 oid;
  98. __le32 len;
  99. __le32 offset;
  100. /*?*/ __le32 handle; /* zero */
  101. } __attribute__ ((packed));
  102. struct rndis_query_c { /* IN */
  103. /* header and: */
  104. __le32 msg_type; /* RNDIS_MSG_QUERY_C */
  105. __le32 msg_len;
  106. __le32 request_id;
  107. __le32 status;
  108. __le32 len;
  109. __le32 offset;
  110. } __attribute__ ((packed));
  111. struct rndis_set { /* OUT */
  112. /* header and: */
  113. __le32 msg_type; /* RNDIS_MSG_SET */
  114. __le32 msg_len;
  115. __le32 request_id;
  116. __le32 oid;
  117. __le32 len;
  118. __le32 offset;
  119. /*?*/ __le32 handle; /* zero */
  120. } __attribute__ ((packed));
  121. struct rndis_set_c { /* IN */
  122. /* header and: */
  123. __le32 msg_type; /* RNDIS_MSG_SET_C */
  124. __le32 msg_len;
  125. __le32 request_id;
  126. __le32 status;
  127. } __attribute__ ((packed));
  128. struct rndis_reset { /* IN */
  129. /* header and: */
  130. __le32 msg_type; /* RNDIS_MSG_RESET */
  131. __le32 msg_len;
  132. __le32 reserved;
  133. } __attribute__ ((packed));
  134. struct rndis_reset_c { /* OUT */
  135. /* header and: */
  136. __le32 msg_type; /* RNDIS_MSG_RESET_C */
  137. __le32 msg_len;
  138. __le32 status;
  139. __le32 addressing_lost;
  140. } __attribute__ ((packed));
  141. struct rndis_indicate { /* IN (unrequested) */
  142. /* header and: */
  143. __le32 msg_type; /* RNDIS_MSG_INDICATE */
  144. __le32 msg_len;
  145. __le32 status;
  146. __le32 length;
  147. __le32 offset;
  148. /**/ __le32 diag_status;
  149. __le32 error_offset;
  150. /**/ __le32 message;
  151. } __attribute__ ((packed));
  152. struct rndis_keepalive { /* OUT (optionally IN) */
  153. /* header and: */
  154. __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
  155. __le32 msg_len;
  156. __le32 request_id;
  157. } __attribute__ ((packed));
  158. struct rndis_keepalive_c { /* IN (optionally OUT) */
  159. /* header and: */
  160. __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
  161. __le32 msg_len;
  162. __le32 request_id;
  163. __le32 status;
  164. } __attribute__ ((packed));
  165. /* default filter used with RNDIS devices */
  166. #define RNDIS_DEFAULT_FILTER ( \
  167. RNDIS_PACKET_TYPE_DIRECTED | \
  168. RNDIS_PACKET_TYPE_BROADCAST | \
  169. RNDIS_PACKET_TYPE_ALL_MULTICAST | \
  170. RNDIS_PACKET_TYPE_PROMISCUOUS)
  171. /* Flags to require specific physical medium type for generic_rndis_bind() */
  172. #define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001
  173. #define FLAG_RNDIS_PHYM_WIRELESS 0x0002
  174. /* Flags for driver_info::data */
  175. #define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */
  176. extern void rndis_status(struct usbnet *dev, struct urb *urb);
  177. extern int
  178. rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
  179. extern int
  180. generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
  181. extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
  182. extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
  183. extern struct sk_buff *
  184. rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags);
  185. #endif /* __LINUX_USB_RNDIS_HOST_H */