mikroSDK Reference Manual
cdc_rndis.h
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2019 Ha Thach (tinyusb.org)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
33#ifndef _TUSB_CDC_RNDIS_H_
34#define _TUSB_CDC_RNDIS_H_
35
36#include "cdc.h"
37
38#ifdef __cplusplus
39 extern "C" {
40#endif
41
42#ifdef __CC_ARM
43#pragma diag_suppress 66 // Suppress Keil warnings #66-D: enumeration value is out of "int" range
44#endif
45
47typedef enum
48{
49 RNDIS_MSG_PACKET = 0x00000001UL,
50
51 RNDIS_MSG_INITIALIZE = 0x00000002UL,
53
54 RNDIS_MSG_HALT = 0x00000003UL,
55
56 RNDIS_MSG_QUERY = 0x00000004UL,
57 RNDIS_MSG_QUERY_CMPLT = 0x80000004UL,
58
59 RNDIS_MSG_SET = 0x00000005UL,
60 RNDIS_MSG_SET_CMPLT = 0x80000005UL,
61
62 RNDIS_MSG_RESET = 0x00000006UL,
63 RNDIS_MSG_RESET_CMPLT = 0x80000006UL,
64
66
67 RNDIS_MSG_KEEP_ALIVE = 0x00000008UL,
68 RNDIS_MSG_KEEP_ALIVE_CMPLT = 0x80000008UL
70
81
82#ifdef __CC_ARM
83#pragma diag_default 66 // return Keil 66 to normal severity
84#endif
85
86//--------------------------------------------------------------------+
87// MESSAGE STRUCTURE
88//--------------------------------------------------------------------+
89
90//------------- Initialize -------------//
93typedef struct {
94 uint32_t type ;
95 uint32_t length ;
96 uint32_t request_id ;
97 uint32_t major_version ;
98 uint32_t minor_version ;
99 uint32_t max_xfer_size ;
101
104typedef struct {
105 uint32_t type ;
106 uint32_t length ;
107 uint32_t request_id ;
108 uint32_t status ;
109 uint32_t major_version ;
110 uint32_t minor_version ;
111 uint32_t device_flags ;
112 uint32_t medium ;
114 uint32_t max_xfer_size ;
116 uint32_t reserved[2] ;
118
119//------------- Query -------------//
122typedef struct {
123 uint32_t type ;
124 uint32_t length ;
125 uint32_t request_id ;
126 uint32_t oid ;
127 uint32_t buffer_length ;
128 uint32_t buffer_offset ;
129 uint32_t reserved ;
130 uint8_t oid_buffer[] ;
132
133TU_VERIFY_STATIC(sizeof(rndis_msg_query_t) == 28, "Make sure flexible array member does not affect layout");
134
137typedef struct {
138 uint32_t type ;
139 uint32_t length ;
140 uint32_t request_id ;
141 uint32_t status ;
142 uint32_t buffer_length ;
143 uint32_t buffer_offset ;
144 uint8_t oid_buffer[] ;
146
147TU_VERIFY_STATIC(sizeof(rndis_msg_query_cmplt_t) == 24, "Make sure flexible array member does not affect layout");
148
149//------------- Reset -------------//
152typedef struct {
153 uint32_t type ;
154 uint32_t length ;
155 uint32_t reserved ;
157
160typedef struct {
161 uint32_t type ;
162 uint32_t length ;
163 uint32_t status ;
166
167//typedef struct {
168// uint32_t type;
169// uint32_t length;
170// uint32_t status;
171// uint32_t buffer_length;
172// uint32_t buffer_offset;
173// uint32_t diagnostic_status; // optional
174// uint32_t diagnostic_error_offset; // optional
175// uint32_t status_buffer[0]; // optional
176//} rndis_msg_indicate_status_t;
177
180typedef struct {
181 uint32_t type ;
182 uint32_t length ;
183 uint32_t request_id ;
185
188typedef struct {
189 uint32_t type ;
190 uint32_t length ;
191 uint32_t request_id ;
192 uint32_t status ;
194
197typedef struct {
198 uint32_t type ;
199 uint32_t length ;
200 uint32_t data_offset ;
201 uint32_t data_length ;
207 uint32_t reserved[2] ;
208 uint32_t payload[0] ;
209
210 // uint8_t padding[0]
211 // Additional bytes of zeros added at the end of the message to comply with
212 // the internal and external padding requirements. Internal padding SHOULD be as per the
213 // specification of the out-of-band data record and per-packet-info data record. The external
214 //padding size SHOULD be determined based on the PacketAlignmentFactor field specification
215 //in REMOTE_NDIS_INITIALIZE_CMPLT message by the device, when multiple
216 //REMOTE_NDIS_PACKET_MSG messages are bundled together in a single bus-native message.
217 //In this case, all but the very last REMOTE_NDIS_PACKET_MSG MUST respect the
218 //PacketAlignmentFactor field.
219
220 // rndis_msg_packet_t [0] : (optional) more packet if multiple packet per bus transaction is supported
222
223
224typedef struct {
225 uint32_t size ;
226 uint32_t type ;
227 uint32_t offset ;
228 uint32_t data[0] ;
230
231//--------------------------------------------------------------------+
232// NDIS Object ID
233//--------------------------------------------------------------------+
234
236typedef enum
237{
238 //------------- General Required OIDs -------------//
243 RNDIS_OID_GEN_MAXIMUM_LOOKAHEAD = 0x00010105,
260
261 //------------- General Optional OIDs -------------//
266 RNDIS_OID_GEN_MEDIA_CAPABILITIES = 0x00010201,
268
269 //------------- 802.3 Objects (Ethernet) -------------//
275
293
294#ifdef __cplusplus
295 }
296#endif
297
298#endif /* _TUSB_CDC_RNDIS_H_ */
299
rndis_oid_type_t
NDIS Object ID.
Definition cdc_rndis.h:237
rndis_packet_filter_type_t
RNDIS Packet Filter Bits RNDIS_OID_GEN_CURRENT_PACKET_FILTER.
Definition cdc_rndis.h:278
rndis_msg_status_t
RNDIS Message Status Values.
Definition cdc_rndis.h:73
rndis_msg_type_t
RNDIS Message Types.
Definition cdc_rndis.h:48
@ RNDIS_OID_GEN_TRANSMIT_BUFFER_SPACE
Transmit buffer space.
Definition cdc_rndis.h:246
@ RNDIS_OID_GEN_CURRENT_PACKET_FILTER
Current packet filter (encoded)
Definition cdc_rndis.h:252
@ RNDIS_OID_GEN_TRANSPORT_HEADER_OFFSET
Size of packets' additional headers.
Definition cdc_rndis.h:265
@ RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE
Maximum total packet length in bytes.
Definition cdc_rndis.h:255
@ RNDIS_OID_GEN_LINK_SPEED
Link speed in units of 100 bps.
Definition cdc_rndis.h:245
@ RNDIS_OID_GEN_VENDOR_ID
Vendor NIC code.
Definition cdc_rndis.h:250
@ RNDIS_OID_GEN_MEDIA_SUPPORTED
Media types supported (encoded)
Definition cdc_rndis.h:241
@ RNDIS_OID_GEN_CURRENT_LOOKAHEAD
Current lookahead size in bytes.
Definition cdc_rndis.h:253
@ RNDIS_OID_GEN_PHYSICAL_MEDIUM
Physical media supported by the miniport driver (encoded)
Definition cdc_rndis.h:267
@ RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE
Amount of storage, in bytes, that a single packet occupies in the receive buffer space of the NIC.
Definition cdc_rndis.h:249
@ RNDIS_OID_GEN_VENDOR_DRIVER_VERSION
Vendor-assigned version number of the driver.
Definition cdc_rndis.h:262
@ RNDIS_OID_GEN_MAXIMUM_SEND_PACKETS
The maximum number of send packets the driver can accept per call to its MiniportSendPacketsfunction.
Definition cdc_rndis.h:259
@ RNDIS_OID_802_3_MAXIMUM_LIST_SIZE
Maximum size of multicast address list.
Definition cdc_rndis.h:273
@ RNDIS_OID_GEN_PROTOCOL_OPTIONS
Optional protocol flags (encoded)
Definition cdc_rndis.h:256
@ RNDIS_OID_GEN_DRIVER_VERSION
NDIS version number used by the driver.
Definition cdc_rndis.h:254
@ RNDIS_OID_GEN_MEDIA_CONNECT_STATUS
Whether the NIC is connected to the network.
Definition cdc_rndis.h:258
@ RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE
Minimum amount of storage, in bytes, that a single packet occupies in the transmit buffer space of th...
Definition cdc_rndis.h:248
@ RNDIS_OID_GEN_MEDIA_IN_USE
Media types in use (encoded)
Definition cdc_rndis.h:242
@ RNDIS_OID_802_3_MULTICAST_LIST
Current multicast address list.
Definition cdc_rndis.h:272
@ RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE
Maximum frame size in bytes.
Definition cdc_rndis.h:244
@ RNDIS_OID_GEN_SUPPORTED_LIST
List of supported OIDs.
Definition cdc_rndis.h:239
@ RNDIS_OID_GEN_MAC_OPTIONS
Optional NIC flags (encoded)
Definition cdc_rndis.h:257
@ RNDIS_OID_GEN_SUPPORTED_GUIDS
The custom GUIDs (Globally Unique Identifier) supported by the miniport driver.
Definition cdc_rndis.h:263
@ RNDIS_OID_802_3_PERMANENT_ADDRESS
Permanent station address.
Definition cdc_rndis.h:270
@ RNDIS_OID_GEN_RECEIVE_BUFFER_SPACE
Receive buffer space.
Definition cdc_rndis.h:247
@ RNDIS_OID_GEN_HARDWARE_STATUS
Hardware status.
Definition cdc_rndis.h:240
@ RNDIS_OID_GEN_VENDOR_DESCRIPTION
Vendor network card description.
Definition cdc_rndis.h:251
@ RNDIS_OID_802_3_CURRENT_ADDRESS
Current station address.
Definition cdc_rndis.h:271
@ RNDIS_OID_GEN_NETWORK_LAYER_ADDRESSES
List of network-layer addresses associated with the binding between a transport and the driver.
Definition cdc_rndis.h:264
@ RNDIS_PACKET_TYPE_DIRECTED
Directed packets. Directed packets contain a destination address equal to the station address of the ...
Definition cdc_rndis.h:279
@ RNDIS_PACKET_TYPE_MAC_FRAME
NIC driver frames that a Token Ring NIC receives.
Definition cdc_rndis.h:290
@ RNDIS_PACKET_TYPE_ALL_LOCAL
All packets sent by installed protocols and all packets indicated by the NIC that is identified by a ...
Definition cdc_rndis.h:286
@ RNDIS_PACKET_TYPE_GROUP
Packets sent to the current group address.
Definition cdc_rndis.h:287
@ RNDIS_PACKET_TYPE_SOURCE_ROUTING
All source routing packets. If the protocol driver sets this bit, the NDIS library attempts to act as...
Definition cdc_rndis.h:283
@ RNDIS_PACKET_TYPE_ALL_FUNCTIONAL
All functional address packets, not just the ones in the current functional address.
Definition cdc_rndis.h:288
@ RNDIS_PACKET_TYPE_BROADCAST
Broadcast packets.
Definition cdc_rndis.h:282
@ RNDIS_PACKET_TYPE_MULTICAST
Multicast address packets sent to addresses in the multicast address list.
Definition cdc_rndis.h:280
@ RNDIS_PACKET_TYPE_PROMISCUOUS
Specifies all packets regardless of whether VLAN filtering is enabled or not and whether the VLAN ide...
Definition cdc_rndis.h:284
@ RNDIS_PACKET_TYPE_FUNCTIONAL
Functional address packets sent to addresses included in the current functional address.
Definition cdc_rndis.h:289
@ RNDIS_PACKET_TYPE_ALL_MULTICAST
All multicast address packets, not just the ones enumerated in the multicast address list.
Definition cdc_rndis.h:281
@ RNDIS_PACKET_TYPE_SMT
SMT packets that an FDDI NIC receives.
Definition cdc_rndis.h:285
@ RNDIS_STATUS_FAILURE
Unspecified error.
Definition cdc_rndis.h:75
@ RNDIS_STATUS_NOT_SUPPORTED
Unsupported request error.
Definition cdc_rndis.h:77
@ RNDIS_STATUS_SUCCESS
Success.
Definition cdc_rndis.h:74
@ RNDIS_STATUS_MEDIA_DISCONNECT
Device is disconnected from the medium.
Definition cdc_rndis.h:79
@ RNDIS_STATUS_MEDIA_CONNECT
Device is connected to a network medium.
Definition cdc_rndis.h:78
@ RNDIS_STATUS_INVALID_DATA
Invalid data error.
Definition cdc_rndis.h:76
@ RNDIS_MSG_PACKET
The host and device use this to send network data to one another.
Definition cdc_rndis.h:49
@ RNDIS_MSG_INITIALIZE_CMPLT
Device response to an initialize message.
Definition cdc_rndis.h:52
@ RNDIS_MSG_RESET
Sent by the host to perform a soft reset on the device.
Definition cdc_rndis.h:62
@ RNDIS_MSG_QUERY
Sent by the host to send a query OID.
Definition cdc_rndis.h:56
@ RNDIS_MSG_RESET_CMPLT
Device response to reset message.
Definition cdc_rndis.h:63
@ RNDIS_MSG_KEEP_ALIVE
During idle periods, sent every few seconds by the host to check that the device is still responsive....
Definition cdc_rndis.h:67
@ RNDIS_MSG_QUERY_CMPLT
Device response to a query OID.
Definition cdc_rndis.h:57
@ RNDIS_MSG_SET_CMPLT
Device response to a set OID.
Definition cdc_rndis.h:60
@ RNDIS_MSG_INDICATE_STATUS
Sent by the device to indicate its status or an error when an unrecognized message is received.
Definition cdc_rndis.h:65
@ RNDIS_MSG_KEEP_ALIVE_CMPLT
The device response to a keepalivemessage. The host can respond with this message to a keepalive mess...
Definition cdc_rndis.h:68
@ RNDIS_MSG_HALT
Sent by the host to halt the device. This does not have a response. It is optional for the device to ...
Definition cdc_rndis.h:54
@ RNDIS_MSG_INITIALIZE
Sent by the host to initialize the device.
Definition cdc_rndis.h:51
@ RNDIS_MSG_SET
Sent by the host to send a set OID.
Definition cdc_rndis.h:59
Initialize Complete Message.
Definition cdc_rndis.h:104
uint32_t type
Message Type, must be RNDIS_MSG_INITIALIZE_CMPLT.
Definition cdc_rndis.h:105
uint32_t major_version
the highest-numbered RNDIS Protocol version supported by the device.
Definition cdc_rndis.h:109
uint32_t status
The initialization status of the device, has value from rndis_msg_status_t.
Definition cdc_rndis.h:108
uint32_t max_xfer_size
The maximum size, in bytes, of any single bus data transfer that the device expects to receive from t...
Definition cdc_rndis.h:114
uint32_t minor_version
the highest-numbered RNDIS Protocol version supported by the device.
Definition cdc_rndis.h:110
uint32_t request_id
A 32-bit integer value from request_id field of the rndis_msg_initialize_t to which this message is a...
Definition cdc_rndis.h:107
uint32_t max_packet_per_xfer
The maximum number of concatenated RNDIS_MSG_PACKET messages that the device can handle in a single b...
Definition cdc_rndis.h:113
uint32_t packet_alignment_factor
The byte alignment the device expects for each RNDIS message that is part of a multimessage transfer ...
Definition cdc_rndis.h:115
uint32_t length
Message length in bytes, must be 0x30.
Definition cdc_rndis.h:106
uint32_t device_flags
MUST be set to 0x000000010. Other values are reserved for future use.
Definition cdc_rndis.h:111
uint32_t medium
is 0x00 for RNDIS_MEDIUM_802_3
Definition cdc_rndis.h:112
Initialize Message.
Definition cdc_rndis.h:93
uint32_t max_xfer_size
The maximum size, in bytes, of any single bus data transfer that the host expects to receive from the...
Definition cdc_rndis.h:99
uint32_t request_id
A 32-bit integer value, generated by the host, used to match the host's sent request to the response ...
Definition cdc_rndis.h:96
uint32_t length
Message length in bytes, must be 0x18.
Definition cdc_rndis.h:95
uint32_t type
Message type, must be RNDIS_MSG_INITIALIZE.
Definition cdc_rndis.h:94
uint32_t minor_version
The minor version of the RNDIS Protocol implemented by the host.
Definition cdc_rndis.h:98
uint32_t major_version
The major version of the RNDIS Protocol implemented by the host.
Definition cdc_rndis.h:97
Keep Alive Message.
Definition cdc_rndis.h:180
uint32_t length
Message length in bytes, MUST be 0x10.
Definition cdc_rndis.h:182
uint32_t type
Message Type.
Definition cdc_rndis.h:181
Definition cdc_rndis.h:224
uint32_t size
Length, in bytes, of this header and appended data and padding. This value MUST be an integer multipl...
Definition cdc_rndis.h:225
uint32_t offset
The byte offset from the beginning of this record to the beginning of data.
Definition cdc_rndis.h:227
uint32_t type
MUST be as per host operating system specification.
Definition cdc_rndis.h:226
Packet Data Message.
Definition cdc_rndis.h:197
uint32_t per_packet_info_length
Specifies, in bytes, the total length of per-packetinformation contained in this message.
Definition cdc_rndis.h:206
uint32_t type
Message Type, must be RNDIS_MSG_PACKET.
Definition cdc_rndis.h:198
uint32_t out_of_band_data_length
Specifies, in bytes, the total length of the out-of-band data.
Definition cdc_rndis.h:203
uint32_t per_packet_info_offset
Specifies the offset, in bytes, of the start of per-packet-info data record from the start of the dat...
Definition cdc_rndis.h:205
uint32_t num_out_of_band_data_elements
Specifies the number of out-of-band records in this message.
Definition cdc_rndis.h:204
uint32_t data_length
Specifies the number of bytes in the payload of this message.
Definition cdc_rndis.h:201
uint32_t data_offset
Specifies the offset, in bytes, from the start of this data_offset field of this message to the start...
Definition cdc_rndis.h:200
uint32_t length
Message length in bytes, The total length of this RNDIS message including the header,...
Definition cdc_rndis.h:199
uint32_t out_of_band_data_offet
Specifies the offset, in bytes, of the first out-of-band data record from the start of the DataOffset...
Definition cdc_rndis.h:202
Query Complete Message.
Definition cdc_rndis.h:137
uint32_t buffer_offset
The offset, in bytes, from the beginning of request_id field where the response data for the query is...
Definition cdc_rndis.h:143
uint32_t status
The status of processing for the query request, has value from rndis_msg_status_t.
Definition cdc_rndis.h:141
uint32_t type
Message Type, must be RNDIS_MSG_QUERY_CMPLT.
Definition cdc_rndis.h:138
uint32_t buffer_length
The length, in bytes, of the data in the response to the query. This MUST be set to 0 when there is n...
Definition cdc_rndis.h:142
uint32_t request_id
A 32-bit integer value from request_id field of the rndis_msg_query_t to which this message is a resp...
Definition cdc_rndis.h:140
uint32_t length
Message length in bytes, including the header and the oid_buffer.
Definition cdc_rndis.h:139
Query Message.
Definition cdc_rndis.h:122
uint32_t request_id
A 32-bit integer value, generated by the host, used to match the host's sent request to the response ...
Definition cdc_rndis.h:125
uint32_t type
Message Type, must be RNDIS_MSG_QUERY.
Definition cdc_rndis.h:123
uint32_t oid
The integer value of the host operating system-defined identifier, for the parameter of the device be...
Definition cdc_rndis.h:126
uint32_t buffer_offset
The offset, in bytes, from the beginning of request_id field where the input data for the query is lo...
Definition cdc_rndis.h:128
uint32_t buffer_length
The length, in bytes, of the input data required for the OID query. This MUST be set to 0 when there ...
Definition cdc_rndis.h:127
uint32_t length
Message length in bytes, including the header and the oid_buffer.
Definition cdc_rndis.h:124
Reset Complete Message.
Definition cdc_rndis.h:160
uint32_t type
Message Type, must be RNDIS_MSG_RESET_CMPLT.
Definition cdc_rndis.h:161
uint32_t length
Message length in bytes, MUST be 0x10.
Definition cdc_rndis.h:162
uint32_t status
The status of processing for the rndis_msg_reset_t, has value from rndis_msg_status_t.
Definition cdc_rndis.h:163
uint32_t addressing_reset
This field indicates whether the addressing information, which is the multicast address list or packe...
Definition cdc_rndis.h:164
Reset Message.
Definition cdc_rndis.h:152
uint32_t type
Message Type, must be RNDIS_MSG_RESET.
Definition cdc_rndis.h:153
uint32_t length
Message length in bytes, MUST be 0x06.
Definition cdc_rndis.h:154
Set Complete Message.
Definition cdc_rndis.h:188
uint32_t status
The status of processing for the request message request by the device to which this message is the r...
Definition cdc_rndis.h:192
uint32_t length
Message length in bytes, MUST be 0x10.
Definition cdc_rndis.h:190
uint32_t request_id
must be the same as requesting message
Definition cdc_rndis.h:191
uint32_t type
Message Type.
Definition cdc_rndis.h:189