rndis_protocol.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /**
  2. * \file rndis_protocol.h
  3. * RNDIS Defines
  4. *
  5. * \author
  6. * Colin O'Flynn <coflynn@newae.com>
  7. *
  8. * \addtogroup usbstick
  9. */
  10. /* Copyright (c) 2008 Colin O'Flynn
  11. Redistribution and use in source and binary forms, with or without
  12. modification, are permitted provided that the following conditions are met:
  13. * Redistributions of source code must retain the above copyright
  14. notice, this list of conditions and the following disclaimer.
  15. * Redistributions in binary form must reproduce the above copyright
  16. notice, this list of conditions and the following disclaimer in
  17. the documentation and/or other materials provided with the
  18. distribution.
  19. * Neither the name of the copyright holders nor the names of
  20. contributors may be used to endorse or promote products derived
  21. from this software without specific prior written permission.
  22. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _RNDIS_H
  35. #define _RNDIS_H
  36. /**
  37. \addtogroup RNDIS
  38. @{
  39. */
  40. #include <stdint.h>
  41. #define RNDIS_MAJOR_VERSION 1
  42. #define RNDIS_MINOR_VERSION 0
  43. #define RNDIS_STATUS_SUCCESS 0X00000000
  44. #define RNDIS_STATUS_FAILURE 0XC0000001
  45. #define RNDIS_STATUS_INVALID_DATA 0XC0010015
  46. #define RNDIS_STATUS_NOT_SUPPORTED 0XC00000BB
  47. #define RNDIS_STATUS_MEDIA_CONNECT 0X4001000B
  48. #define RNDIS_STATUS_MEDIA_DISCONNECT 0X4001000C
  49. /* Message set for Connectionless (802.3) Devices */
  50. #define REMOTE_NDIS_PACKET_MSG 0x00000001
  51. #define REMOTE_NDIS_INITIALIZE_MSG 0X00000002
  52. #define REMOTE_NDIS_HALT_MSG 0X00000003
  53. #define REMOTE_NDIS_QUERY_MSG 0X00000004
  54. #define REMOTE_NDIS_SET_MSG 0X00000005
  55. #define REMOTE_NDIS_RESET_MSG 0X00000006
  56. #define REMOTE_NDIS_INDICATE_STATUS_MSG 0X00000007
  57. #define REMOTE_NDIS_KEEPALIVE_MSG 0X00000008
  58. #define REMOTE_NDIS_INITIALIZE_CMPLT 0X80000002
  59. #define REMOTE_NDIS_QUERY_CMPLT 0X80000004
  60. #define REMOTE_NDIS_SET_CMPLT 0X80000005
  61. #define REMOTE_NDIS_RESET_CMPLT 0X80000006
  62. #define REMOTE_NDIS_KEEPALIVE_CMPLT 0X80000008
  63. typedef uint32_t rndis_MessageType_t;
  64. typedef uint32_t rndis_MessageLength_t;
  65. typedef uint32_t rndis_RequestId_t;
  66. typedef uint32_t rndis_MajorVersion_t;
  67. typedef uint32_t rndis_MinorVersion_t;
  68. typedef uint32_t rndis_MaxTransferSize_t;
  69. typedef uint32_t rndis_Status_t;
  70. /* Device Flags */
  71. #define RNDIS_DF_CONNECTIONLESS 0x00000001
  72. #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
  73. typedef uint32_t rndis_DeviceFlags_t;
  74. /* Mediums */
  75. #define RNDIS_MEDIUM_802_3 0x00000000
  76. typedef uint32_t rndis_Medium_t;
  77. typedef uint32_t rndis_MaxPacketsPerTransfer_t;
  78. typedef uint32_t rndis_PacketAlignmentFactor_t;
  79. typedef uint32_t rndis_AfListOffset_t;
  80. typedef uint32_t rndis_AfListSize_t;
  81. /*** Remote NDIS Generic Message type ***/
  82. typedef struct{
  83. rndis_MessageType_t MessageType;
  84. rndis_MessageLength_t MessageLength;
  85. } rndis_generic_msg_t;
  86. /*** Remote NDIS Initialize Message ***/
  87. typedef struct{
  88. rndis_MessageType_t MessageType;
  89. rndis_MessageLength_t MessageLength;
  90. rndis_RequestId_t RequestId;
  91. rndis_MajorVersion_t MajorVersion;
  92. rndis_MinorVersion_t MinorVersion;
  93. rndis_MaxTransferSize_t MaxTransferSize;
  94. } rndis_initialize_msg_t;
  95. /* Response: */
  96. typedef struct{
  97. rndis_MessageType_t MessageType;
  98. rndis_MessageLength_t MessageLength;
  99. rndis_RequestId_t RequestId;
  100. rndis_Status_t Status;
  101. rndis_MajorVersion_t MajorVersion;
  102. rndis_MinorVersion_t MinorVersion;
  103. rndis_DeviceFlags_t DeviceFlags;
  104. rndis_Medium_t Medium;
  105. rndis_MaxPacketsPerTransfer_t MaxPacketsPerTransfer;
  106. rndis_MaxTransferSize_t MaxTransferSize;
  107. rndis_PacketAlignmentFactor_t PacketAlignmentFactor;
  108. rndis_AfListOffset_t AfListOffset;
  109. rndis_AfListSize_t AfListSize;
  110. } rndis_initialize_cmplt_t;
  111. /*** Remote NDIS Halt Message ***/
  112. typedef struct{
  113. rndis_MessageType_t MessageType;
  114. rndis_MessageLength_t MessageLength;
  115. rndis_RequestId_t RequestId;
  116. } rndis_halt_msg_t;
  117. typedef uint32_t rndis_Oid_t;
  118. typedef uint32_t rndis_InformationBufferLength_t;
  119. typedef uint32_t rndis_InformationBufferOffset_t;
  120. typedef uint32_t rndis_DeviceVcHandle_t;
  121. /*** Remote NDIS Query Message ***/
  122. typedef struct{
  123. rndis_MessageType_t MessageType;
  124. rndis_MessageLength_t MessageLength;
  125. rndis_RequestId_t RequestId;
  126. rndis_Oid_t Oid;
  127. rndis_InformationBufferLength_t InformationBufferLength;
  128. rndis_InformationBufferOffset_t InformationBufferOffset;
  129. rndis_DeviceVcHandle_t DeviceVcHandle;
  130. } rndis_query_msg_t;
  131. /* Response: */
  132. typedef struct{
  133. rndis_MessageType_t MessageType;
  134. rndis_MessageLength_t MessageLength;
  135. rndis_RequestId_t RequestId;
  136. rndis_Status_t Status;
  137. rndis_InformationBufferLength_t InformationBufferLength;
  138. rndis_InformationBufferOffset_t InformationBufferOffset;
  139. } rndis_query_cmplt_t;
  140. /*** Remote NDIS Set Message ***/
  141. typedef struct{
  142. rndis_MessageType_t MessageType;
  143. rndis_MessageLength_t MessageLength;
  144. rndis_RequestId_t RequestId;
  145. rndis_Oid_t Oid;
  146. rndis_InformationBufferLength_t InformationBufferLength;
  147. rndis_InformationBufferOffset_t InformationBufferOffset;
  148. rndis_DeviceVcHandle_t DeviceVcHandle;
  149. } rndis_set_msg_t;
  150. /* Response */
  151. typedef struct{
  152. rndis_MessageType_t MessageType;
  153. rndis_MessageLength_t MessageLength;
  154. rndis_RequestId_t RequestId;
  155. rndis_Status_t Status;
  156. }rndis_set_cmplt_t;
  157. /* Information buffer layout for OID_GEN_RNDIS_CONFIG_PARAMETER */
  158. typedef uint32_t rndis_ParameterNameOffset_t;
  159. typedef uint32_t rndis_ParameterNameLength_t;
  160. typedef uint32_t rndis_ParameterType_t;
  161. typedef uint32_t rndis_ParameterValueOffset_t;
  162. typedef uint32_t rndis_ParameterValueLength_t;
  163. #define PARAMETER_TYPE_STRING 2
  164. #define PARAMETER_TYPE_NUMERICAL 0
  165. typedef struct{
  166. rndis_ParameterNameOffset_t ParameterNameOffset;
  167. rndis_ParameterNameLength_t ParameterNameLength;
  168. rndis_ParameterType_t ParameterType;
  169. rndis_ParameterValueOffset_t ParameterValueOffset;
  170. rndis_ParameterValueLength_t ParameterValueLength;
  171. }rndis_config_parameter_t;
  172. typedef uint32_t rndis_Reserved_t;
  173. /*** Remote NDIS Soft Reset Message ***/
  174. typedef struct{
  175. rndis_MessageType_t MessageType;
  176. rndis_MessageLength_t MessageLength;
  177. rndis_Reserved_t Reserved;
  178. } rndis_reset_msg_t;
  179. typedef uint32_t rndis_AddressingReset_t;
  180. /* Response: */
  181. typedef struct{
  182. rndis_MessageType_t MessageType;
  183. rndis_MessageLength_t MessageLength;
  184. rndis_Status_t Status;
  185. rndis_AddressingReset_t AddressingReset;
  186. } rndis_reset_cmplt_t;
  187. /*** Remote NDIS Indicate Status Message ***/
  188. typedef struct{
  189. rndis_MessageType_t MessageType;
  190. rndis_MessageLength_t MessageLength;
  191. rndis_Status_t Status;
  192. rndis_Status_t StatusBufferLength;
  193. rndis_Status_t StatusBufferOffset;
  194. } rndis_indicate_status_t;
  195. typedef uint32_t rndis_DiagStatus_t;
  196. typedef uint32_t rndis_ErrorOffset_t;
  197. typedef struct {
  198. rndis_DiagStatus_t DiagStatus;
  199. rndis_ErrorOffset_t ErrorOffset;
  200. }rndis_diagnostic_info_t;
  201. /*** Remote NDIS Keepalive Message */
  202. typedef struct{
  203. rndis_MessageType_t MessageType;
  204. rndis_MessageLength_t MessageLength;
  205. rndis_RequestId_t RequestId;
  206. }rndis_keepalive_msg_t;
  207. /* Response: */
  208. typedef struct{
  209. rndis_MessageType_t MessageType;
  210. rndis_MessageLength_t MessageLength;
  211. rndis_RequestId_t RequestId;
  212. rndis_Status_t Status;
  213. }rndis_keepalive_cmplt_t;
  214. /*** Remote NDIS Data Packet ***/
  215. typedef uint32_t rndis_DataOffset_t;
  216. typedef uint32_t rndis_DataLength_t;
  217. typedef uint32_t rndis_OOBDataOffset_t;
  218. typedef uint32_t rndis_OOBDataLength_t;
  219. typedef uint32_t rndis_NumOOBDataElements_t;
  220. typedef uint32_t rndis_PerPacketInfoOffset_t;
  221. typedef uint32_t rndis_PerPacketInfoLength_t;
  222. typedef struct{
  223. rndis_MessageType_t MessageType;
  224. rndis_MessageLength_t MessageLength;
  225. rndis_DataOffset_t DataOffset;
  226. rndis_DataLength_t DataLength;
  227. rndis_OOBDataOffset_t OOBDataOffset;
  228. rndis_OOBDataLength_t OOBDataLength;
  229. rndis_NumOOBDataElements_t NumOOBDataElements;
  230. rndis_PerPacketInfoOffset_t PerPacketInfoOffset;
  231. rndis_PerPacketInfoLength_t PerPacketInfoLength;
  232. rndis_DeviceVcHandle_t DeviceVcHandle;
  233. rndis_Reserved_t Reserved;
  234. }rndis_data_packet_t;
  235. typedef uint32_t rndis_ClassInformationOffset_t;
  236. typedef uint32_t rndis_Size_t;
  237. typedef uint32_t rndis_Type_t;
  238. typedef struct{
  239. rndis_Size_t Size;
  240. rndis_Type_t Type;
  241. rndis_ClassInformationOffset_t ClassInformationType;
  242. }rndis_OOB_packet_t;
  243. #include "ndis.h"
  244. typedef enum rnids_state_e {
  245. rndis_uninitialized,
  246. rndis_initialized,
  247. rndis_data_initialized
  248. } rndis_state_t;
  249. typedef struct {
  250. uint32_t txok;
  251. uint32_t rxok;
  252. uint32_t txbad;
  253. uint32_t rxbad;
  254. } usb_eth_stat_t;
  255. #endif //_RNDIS_H
  256. /** @} */