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