rndis_std.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /****************************************************************************
  2. * drivers/usbdev/rndis.c
  3. *
  4. * Copyright (C) 2011-2017 Gregory Nutt. All rights reserved.
  5. * Authors: Sakari Kapanen <sakari.m.kapanen@gmail.com>,
  6. * Petteri Aimonen <jpa@git.mail.kapsi.fi>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * 3. Neither the name NuttX nor the names of its contributors may be
  19. * used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ****************************************************************************/
  36. #ifndef __NUTTX_DRIVERS_USBDEV_RNDIS_STD_H
  37. #define __NUTTX_DRIVERS_USBDEV_RNDIS_STD_H
  38. /****************************************************************************
  39. * Pre-processor definitions
  40. ****************************************************************************/
  41. /* Definitions for Microsoft RNDIS protocol.
  42. * Documentation:
  43. * https://docs.microsoft.com/en-us/windows-hardware/drivers/network/remote-ndis--rndis-2
  44. * https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/WinArchive/[MS-RNDIS].pdf
  45. */
  46. #define RNDIS_MAJOR_VERSION 1
  47. #define RNDIS_MINOR_VERSION 0
  48. #define RNDIS_DEVICEFLAGS 0x00000001
  49. #define RNDIS_MEDIUM_802_3 0x00000000
  50. /* Message types */
  51. #define RNDIS_MSG_COMPLETE 0x80000000
  52. #define RNDIS_PACKET_MSG 0x00000001
  53. #define RNDIS_INITIALIZE_MSG 0x00000002
  54. #define RNDIS_HALT_MSG 0x00000003
  55. #define RNDIS_QUERY_MSG 0x00000004
  56. #define RNDIS_SET_MSG 0x00000005
  57. #define RNDIS_RESET_MSG 0x00000006
  58. #define RNDIS_INDICATE_MSG 0x00000007
  59. #define RNDIS_KEEPALIVE_MSG 0x00000008
  60. /* Status codes */
  61. #define RNDIS_STATUS_SUCCESS 0x00000000
  62. #define RNDIS_STATUS_FAILURE 0xC0000001
  63. #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BB
  64. /* ObjectIDs for query commands */
  65. #define RNDIS_OID_GEN_SUPPORTED_LIST 0x00010101
  66. #define RNDIS_OID_GEN_HARDWARE_STATUS 0x00010102
  67. #define RNDIS_OID_GEN_MEDIA_SUPPORTED 0x00010103
  68. #define RNDIS_OID_GEN_MEDIA_IN_USE 0x00010104
  69. #define RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106
  70. #define RNDIS_OID_GEN_LINK_SPEED 0x00010107
  71. #define RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A
  72. #define RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B
  73. #define RNDIS_OID_GEN_VENDOR_ID 0x0001010C
  74. #define RNDIS_OID_GEN_VENDOR_DESCRIPTION 0x0001010D
  75. #define RNDIS_OID_GEN_VENDOR_DRIVER_VERSION 0x00010116
  76. #define RNDIS_OID_GEN_CURRENT_PACKET_FILTER 0x0001010E
  77. #define RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111
  78. #define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS 0x00010114
  79. #define RNDIS_OID_GEN_PHYSICAL_MEDIUM 0x00010202
  80. #define RNDIS_OID_GEN_XMIT_OK 0x00020101
  81. #define RNDIS_OID_GEN_RCV_OK 0x00020102
  82. #define RNDIS_OID_GEN_XMIT_ERROR 0x00020103
  83. #define RNDIS_OID_GEN_RCV_ERROR 0x00020104
  84. #define RNDIS_OID_GEN_RCV_NO_BUFFER 0x00020105
  85. #define RNDIS_OID_802_3_PERMANENT_ADDRESS 0x01010101
  86. #define RNDIS_OID_802_3_CURRENT_ADDRESS 0x01010102
  87. #define RNDIS_OID_802_3_MULTICAST_LIST 0x01010103
  88. #define RNDIS_OID_802_3_MAXIMUM_LIST_SIZE 0x01010104
  89. #define RNDIS_OID_802_3_MAC_OPTIONS 0x01010105
  90. #define RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101
  91. #define RNDIS_OID_802_3_XMIT_ONE_COLLISION 0x01020102
  92. #define RNDIS_OID_802_3_XMIT_MORE_COLLISION 0x01020103
  93. #define RNDIS_SEND_ENCAPSULATED_COMMAND 0x00
  94. #define RNDIS_GET_ENCAPSULATED_RESPONSE 0x01
  95. #define RNDIS_NOTIFICATION_RESPONSE_AVAILABLE 0x01
  96. /****************************************************************************
  97. * Public types
  98. ****************************************************************************/
  99. struct rndis_notification
  100. {
  101. uint32_t notification; /* Notification */
  102. uint32_t reserved; /* Reserved */
  103. };
  104. struct rndis_command_header
  105. {
  106. uint32_t msgtype; /* MessageType */
  107. uint32_t msglen; /* MessageLength */
  108. uint32_t reqid; /* RequestID */
  109. };
  110. struct rndis_response_header
  111. {
  112. uint32_t msgtype; /* MessageType */
  113. uint32_t msglen; /* MessageLength */
  114. uint32_t reqid; /* RequestID */
  115. uint32_t status; /* Status */
  116. };
  117. struct rndis_initialize_msg
  118. {
  119. struct rndis_command_header hdr;
  120. uint32_t major; /* MajorVersion */
  121. uint32_t minor; /* MinorVersion */
  122. uint32_t xfrsize; /* MaxTransferSize */
  123. };
  124. struct rndis_initialize_cmplt
  125. {
  126. struct rndis_response_header hdr;
  127. uint32_t major; /* MajorVersion */
  128. uint32_t minor; /* MinorVersion */
  129. uint32_t devflags; /* DeviceFlags */
  130. uint32_t medium; /* Medium */
  131. uint32_t pktperxfer; /* MaxPacketsPerTransfer */
  132. uint32_t xfrsize; /* MaxTransferSize */
  133. uint32_t pktalign; /* PacketAlignmentFactor */
  134. uint32_t reserved1; /* Reserved1 */
  135. uint32_t reserved2; /* Reserved2 */
  136. };
  137. struct rndis_query_msg
  138. {
  139. struct rndis_command_header hdr;
  140. uint32_t objid; /* ObjectID */
  141. uint32_t buflen; /* InformationBufferLength */
  142. uint32_t bufoffset; /* InformationBufferOffset */
  143. uint32_t reserved; /* Reserved */
  144. uint32_t buffer[]; /* Buffer */
  145. };
  146. struct rndis_query_cmplt
  147. {
  148. struct rndis_response_header hdr;
  149. uint32_t buflen; /* InformationBufferLength */
  150. uint32_t bufoffset; /* InformationBufferOffset */
  151. uint32_t buffer[]; /* Buffer */
  152. };
  153. struct rndis_set_msg
  154. {
  155. struct rndis_command_header hdr;
  156. uint32_t objid; /* ObjectID */
  157. uint32_t buflen; /* InformationBufferLength */
  158. uint32_t bufoffset; /* InformationBufferOffset */
  159. uint32_t reserved; /* Reserved */
  160. uint32_t buffer[]; /* Buffer */
  161. };
  162. struct rndis_reset_cmplt
  163. {
  164. struct rndis_response_header hdr;
  165. uint32_t addreset; /* AddressingReset */
  166. };
  167. struct rndis_indicate_msg
  168. {
  169. uint32_t msgtype; /* MessageType */
  170. uint32_t msglen; /* MessageLength */
  171. uint32_t status; /* Status */
  172. uint32_t buflen; /* StatusBufferLength */
  173. uint32_t bufoffset; /* StatusBufferOffset */
  174. uint32_t buffer[]; /* Buffer */
  175. };
  176. struct rndis_packet_msg
  177. {
  178. uint32_t msgtype; /* MessageType */
  179. uint32_t msglen; /* MessageLength */
  180. uint32_t dataoffset; /* DataOffset */
  181. uint32_t datalen; /* DataLength */
  182. uint32_t ooboffset; /* OutOfBandDataOffset */
  183. uint32_t ooblen; /* OutOfBandDataLength */
  184. uint32_t noobelem; /* NumOutOfBandDataElements */
  185. uint32_t infooffset; /* PerPacketInfoOffset */
  186. uint32_t infolen; /* PerPacketInfoLength */
  187. };
  188. #endif