rndis_host.h 5.9 KB

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