Contiki 2.6
|
00001 /** 00002 * \file rndis_protocol.h 00003 * RNDIS Defines 00004 * 00005 * \author 00006 * Colin O'Flynn <coflynn@newae.com> 00007 * 00008 * \addtogroup usbstick 00009 */ 00010 00011 /* Copyright (c) 2008 Colin O'Flynn 00012 00013 Redistribution and use in source and binary forms, with or without 00014 modification, are permitted provided that the following conditions are met: 00015 00016 * Redistributions of source code must retain the above copyright 00017 notice, this list of conditions and the following disclaimer. 00018 * Redistributions in binary form must reproduce the above copyright 00019 notice, this list of conditions and the following disclaimer in 00020 the documentation and/or other materials provided with the 00021 distribution. 00022 * Neither the name of the copyright holders nor the names of 00023 contributors may be used to endorse or promote products derived 00024 from this software without specific prior written permission. 00025 00026 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00030 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00031 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00032 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00034 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00035 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 POSSIBILITY OF SUCH DAMAGE. 00037 */ 00038 00039 #ifndef _RNDIS_H 00040 #define _RNDIS_H 00041 00042 /** 00043 \addtogroup RNDIS 00044 @{ 00045 */ 00046 00047 #include <stdint.h> 00048 00049 #define RNDIS_MAJOR_VERSION 1 00050 #define RNDIS_MINOR_VERSION 0 00051 00052 #define RNDIS_STATUS_SUCCESS 0X00000000 00053 #define RNDIS_STATUS_FAILURE 0XC0000001 00054 #define RNDIS_STATUS_INVALID_DATA 0XC0010015 00055 #define RNDIS_STATUS_NOT_SUPPORTED 0XC00000BB 00056 #define RNDIS_STATUS_MEDIA_CONNECT 0X4001000B 00057 #define RNDIS_STATUS_MEDIA_DISCONNECT 0X4001000C 00058 00059 00060 /* Message set for Connectionless (802.3) Devices */ 00061 #define REMOTE_NDIS_PACKET_MSG 0x00000001 00062 #define REMOTE_NDIS_INITIALIZE_MSG 0X00000002 00063 #define REMOTE_NDIS_HALT_MSG 0X00000003 00064 #define REMOTE_NDIS_QUERY_MSG 0X00000004 00065 #define REMOTE_NDIS_SET_MSG 0X00000005 00066 #define REMOTE_NDIS_RESET_MSG 0X00000006 00067 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0X00000007 00068 #define REMOTE_NDIS_KEEPALIVE_MSG 0X00000008 00069 #define REMOTE_NDIS_INITIALIZE_CMPLT 0X80000002 00070 #define REMOTE_NDIS_QUERY_CMPLT 0X80000004 00071 #define REMOTE_NDIS_SET_CMPLT 0X80000005 00072 #define REMOTE_NDIS_RESET_CMPLT 0X80000006 00073 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0X80000008 00074 00075 typedef uint32_t rndis_MessageType_t; 00076 typedef uint32_t rndis_MessageLength_t; 00077 typedef uint32_t rndis_RequestId_t; 00078 typedef uint32_t rndis_MajorVersion_t; 00079 typedef uint32_t rndis_MinorVersion_t; 00080 typedef uint32_t rndis_MaxTransferSize_t; 00081 typedef uint32_t rndis_Status_t; 00082 00083 00084 /* Device Flags */ 00085 #define RNDIS_DF_CONNECTIONLESS 0x00000001 00086 #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 00087 typedef uint32_t rndis_DeviceFlags_t; 00088 00089 /* Mediums */ 00090 #define RNDIS_MEDIUM_802_3 0x00000000 00091 typedef uint32_t rndis_Medium_t; 00092 00093 00094 typedef uint32_t rndis_MaxPacketsPerTransfer_t; 00095 typedef uint32_t rndis_PacketAlignmentFactor_t; 00096 typedef uint32_t rndis_AfListOffset_t; 00097 typedef uint32_t rndis_AfListSize_t; 00098 00099 /*** Remote NDIS Generic Message type ***/ 00100 typedef struct{ 00101 rndis_MessageType_t MessageType; 00102 rndis_MessageLength_t MessageLength; 00103 } rndis_generic_msg_t; 00104 00105 00106 /*** Remote NDIS Initialize Message ***/ 00107 typedef struct{ 00108 rndis_MessageType_t MessageType; 00109 rndis_MessageLength_t MessageLength; 00110 rndis_RequestId_t RequestId; 00111 rndis_MajorVersion_t MajorVersion; 00112 rndis_MinorVersion_t MinorVersion; 00113 rndis_MaxTransferSize_t MaxTransferSize; 00114 } rndis_initialize_msg_t; 00115 00116 /* Response: */ 00117 typedef struct{ 00118 rndis_MessageType_t MessageType; 00119 rndis_MessageLength_t MessageLength; 00120 rndis_RequestId_t RequestId; 00121 rndis_Status_t Status; 00122 rndis_MajorVersion_t MajorVersion; 00123 rndis_MinorVersion_t MinorVersion; 00124 rndis_DeviceFlags_t DeviceFlags; 00125 rndis_Medium_t Medium; 00126 rndis_MaxPacketsPerTransfer_t MaxPacketsPerTransfer; 00127 rndis_MaxTransferSize_t MaxTransferSize; 00128 rndis_PacketAlignmentFactor_t PacketAlignmentFactor; 00129 rndis_AfListOffset_t AfListOffset; 00130 rndis_AfListSize_t AfListSize; 00131 } rndis_initialize_cmplt_t; 00132 00133 00134 /*** Remote NDIS Halt Message ***/ 00135 typedef struct{ 00136 rndis_MessageType_t MessageType; 00137 rndis_MessageLength_t MessageLength; 00138 rndis_RequestId_t RequestId; 00139 } rndis_halt_msg_t; 00140 00141 typedef uint32_t rndis_Oid_t; 00142 typedef uint32_t rndis_InformationBufferLength_t; 00143 typedef uint32_t rndis_InformationBufferOffset_t; 00144 typedef uint32_t rndis_DeviceVcHandle_t; 00145 00146 /*** Remote NDIS Query Message ***/ 00147 typedef struct{ 00148 rndis_MessageType_t MessageType; 00149 rndis_MessageLength_t MessageLength; 00150 rndis_RequestId_t RequestId; 00151 rndis_Oid_t Oid; 00152 rndis_InformationBufferLength_t InformationBufferLength; 00153 rndis_InformationBufferOffset_t InformationBufferOffset; 00154 rndis_DeviceVcHandle_t DeviceVcHandle; 00155 } rndis_query_msg_t; 00156 00157 /* Response: */ 00158 00159 typedef struct{ 00160 rndis_MessageType_t MessageType; 00161 rndis_MessageLength_t MessageLength; 00162 rndis_RequestId_t RequestId; 00163 rndis_Status_t Status; 00164 rndis_InformationBufferLength_t InformationBufferLength; 00165 rndis_InformationBufferOffset_t InformationBufferOffset; 00166 } rndis_query_cmplt_t; 00167 00168 /*** Remote NDIS Set Message ***/ 00169 typedef struct{ 00170 rndis_MessageType_t MessageType; 00171 rndis_MessageLength_t MessageLength; 00172 rndis_RequestId_t RequestId; 00173 rndis_Oid_t Oid; 00174 rndis_InformationBufferLength_t InformationBufferLength; 00175 rndis_InformationBufferOffset_t InformationBufferOffset; 00176 rndis_DeviceVcHandle_t DeviceVcHandle; 00177 } rndis_set_msg_t; 00178 00179 /* Response */ 00180 typedef struct{ 00181 rndis_MessageType_t MessageType; 00182 rndis_MessageLength_t MessageLength; 00183 rndis_RequestId_t RequestId; 00184 rndis_Status_t Status; 00185 }rndis_set_cmplt_t; 00186 00187 /* Information buffer layout for OID_GEN_RNDIS_CONFIG_PARAMETER */ 00188 typedef uint32_t rndis_ParameterNameOffset_t; 00189 typedef uint32_t rndis_ParameterNameLength_t; 00190 typedef uint32_t rndis_ParameterType_t; 00191 typedef uint32_t rndis_ParameterValueOffset_t; 00192 typedef uint32_t rndis_ParameterValueLength_t; 00193 00194 #define PARAMETER_TYPE_STRING 2 00195 #define PARAMETER_TYPE_NUMERICAL 0 00196 00197 typedef struct{ 00198 rndis_ParameterNameOffset_t ParameterNameOffset; 00199 rndis_ParameterNameLength_t ParameterNameLength; 00200 rndis_ParameterType_t ParameterType; 00201 rndis_ParameterValueOffset_t ParameterValueOffset; 00202 rndis_ParameterValueLength_t ParameterValueLength; 00203 }rndis_config_parameter_t; 00204 00205 typedef uint32_t rndis_Reserved_t; 00206 00207 /*** Remote NDIS Soft Reset Message ***/ 00208 typedef struct{ 00209 rndis_MessageType_t MessageType; 00210 rndis_MessageLength_t MessageLength; 00211 rndis_Reserved_t Reserved; 00212 } rndis_reset_msg_t; 00213 00214 typedef uint32_t rndis_AddressingReset_t; 00215 00216 /* Response: */ 00217 typedef struct{ 00218 rndis_MessageType_t MessageType; 00219 rndis_MessageLength_t MessageLength; 00220 rndis_Status_t Status; 00221 rndis_AddressingReset_t AddressingReset; 00222 } rndis_reset_cmplt_t; 00223 00224 /*** Remote NDIS Indicate Status Message ***/ 00225 typedef struct{ 00226 rndis_MessageType_t MessageType; 00227 rndis_MessageLength_t MessageLength; 00228 rndis_Status_t Status; 00229 rndis_Status_t StatusBufferLength; 00230 rndis_Status_t StatusBufferOffset; 00231 } rndis_indicate_status_t; 00232 00233 typedef uint32_t rndis_DiagStatus_t; 00234 typedef uint32_t rndis_ErrorOffset_t; 00235 00236 typedef struct { 00237 rndis_DiagStatus_t DiagStatus; 00238 rndis_ErrorOffset_t ErrorOffset; 00239 }rndis_diagnostic_info_t; 00240 00241 /*** Remote NDIS Keepalive Message */ 00242 typedef struct{ 00243 rndis_MessageType_t MessageType; 00244 rndis_MessageLength_t MessageLength; 00245 rndis_RequestId_t RequestId; 00246 }rndis_keepalive_msg_t; 00247 00248 /* Response: */ 00249 typedef struct{ 00250 rndis_MessageType_t MessageType; 00251 rndis_MessageLength_t MessageLength; 00252 rndis_RequestId_t RequestId; 00253 rndis_Status_t Status; 00254 }rndis_keepalive_cmplt_t; 00255 00256 /*** Remote NDIS Data Packet ***/ 00257 00258 typedef uint32_t rndis_DataOffset_t; 00259 typedef uint32_t rndis_DataLength_t; 00260 typedef uint32_t rndis_OOBDataOffset_t; 00261 typedef uint32_t rndis_OOBDataLength_t; 00262 typedef uint32_t rndis_NumOOBDataElements_t; 00263 typedef uint32_t rndis_PerPacketInfoOffset_t; 00264 typedef uint32_t rndis_PerPacketInfoLength_t; 00265 00266 typedef struct{ 00267 rndis_MessageType_t MessageType; 00268 rndis_MessageLength_t MessageLength; 00269 rndis_DataOffset_t DataOffset; 00270 rndis_DataLength_t DataLength; 00271 rndis_OOBDataOffset_t OOBDataOffset; 00272 rndis_OOBDataLength_t OOBDataLength; 00273 rndis_NumOOBDataElements_t NumOOBDataElements; 00274 rndis_PerPacketInfoOffset_t PerPacketInfoOffset; 00275 rndis_PerPacketInfoLength_t PerPacketInfoLength; 00276 rndis_DeviceVcHandle_t DeviceVcHandle; 00277 rndis_Reserved_t Reserved; 00278 }rndis_data_packet_t; 00279 00280 typedef uint32_t rndis_ClassInformationOffset_t; 00281 typedef uint32_t rndis_Size_t; 00282 typedef uint32_t rndis_Type_t; 00283 00284 typedef struct{ 00285 rndis_Size_t Size; 00286 rndis_Type_t Type; 00287 rndis_ClassInformationOffset_t ClassInformationType; 00288 }rndis_OOB_packet_t; 00289 00290 00291 00292 #include "ndis.h" 00293 00294 00295 typedef enum rnids_state_e { 00296 rndis_uninitialized, 00297 rndis_initialized, 00298 rndis_data_initialized 00299 } rndis_state_t; 00300 00301 typedef struct{ 00302 uint32_t txok; 00303 uint32_t rxok; 00304 uint32_t txbad; 00305 uint32_t rxbad; 00306 } usb_eth_stat_t; 00307 00308 extern usb_eth_stat_t usb_eth_stat; 00309 00310 extern rndis_state_t rndis_state; 00311 00312 extern uint8_t schedule_interrupt; 00313 00314 uint8_t rndis_send_encapsulated_command(uint16_t wLength); 00315 uint8_t rndis_get_encapsulated_command(void); 00316 void rndis_send_interrupt(void); 00317 void rndis_query_process(void); 00318 void rndis_set_process(void); 00319 uint8_t rndis_send_status(rndis_Status_t stat); 00320 uint8_t rndis_process(void); 00321 uint8_t rndis_send(uint8_t * senddata, uint16_t sendlen, uint8_t led); 00322 extern void rndis_configure_endpoints(); 00323 00324 #endif //_RNDIS_H 00325 00326 /** @} */