rndis_host.h 5.3 KB

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