xref: /nrf52832-nimble/rt-thread/components/drivers/usb/usbdevice/class/rndis.h (revision 042d53a763ad75cb1465103098bb88c245d95138)
1 /*
2  * Copyright (c) 2006-2018, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author            Notes
8  * 2012-12-24     heyuanjie87       first version
9  */
10 
11 #ifndef  __RNDIS_H__
12 #define  __RNDIS_H__
13 
14 #include <rtthread.h>
15 
16 #define USB_ETH_MTU	                    1500+14
17 #define RNDIS_MESSAGE_BUFFER_SIZE       128
18 
19 #define RESPONSE_AVAILABLE            0x00000001
20 
21 /* Remote NDIS version numbers */
22 #define RNDIS_MAJOR_VERSION	1
23 #define RNDIS_MINOR_VERSION 0
24 
25 /* common status values */
26 #define RNDIS_STATUS_SUCCESS 			0X00000000
27 #define RNDIS_STATUS_FAILURE			0XC0000001
28 #define RNDIS_STATUS_INVALID_DATA		0XC0010015
29 #define RNDIS_STATUS_NOT_SUPPORTED 		0XC00000BB
30 #define RNDIS_STATUS_MEDIA_CONNECT		0X4001000B
31 #define RNDIS_STATUS_MEDIA_DISCONNECT	0X4001000C
32 
33 /* Remote NDIS message types */
34 #define REMOTE_NDIS_PACKET_MSG			0x00000001
35 #define REMOTE_NDIS_INITIALIZE_MSG		0X00000002
36 #define REMOTE_NDIS_HALT_MSG			0X00000003
37 #define REMOTE_NDIS_QUERY_MSG			0X00000004
38 #define REMOTE_NDIS_SET_MSG				0X00000005
39 #define REMOTE_NDIS_RESET_MSG			0X00000006
40 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0X00000007
41 #define REMOTE_NDIS_KEEPALIVE_MSG		0X00000008
42 #define REMOTE_NDIS_INITIALIZE_CMPLT	0X80000002
43 #define REMOTE_NDIS_QUERY_CMPLT			0X80000004
44 #define REMOTE_NDIS_SET_CMPLT			0X80000005
45 #define REMOTE_NDIS_RESET_CMPLT			0X80000006
46 #define REMOTE_NDIS_KEEPALIVE_CMPLT		0X80000008
47 
48 /* device flags */
49 #define RNDIS_DF_CONNECTIONLESS			0x00000001
50 #define RNDIS_DF_CONNECTION_ORIENTED	0x00000002
51 /* mediums */
52 #define RNDIS_MEDIUM_802_3				0x00000000
53 
54 struct ucls_rndis
55 {
56     uep_t notify;
57     rt_uint32_t filter;
58     rt_bool_t header;
59     rt_uint8_t rndis_state;
60     rt_uint8_t media_state;
61     rt_uint8_t ethaddr[6];
62 };
63 
64 /* Remote NDIS generic message type */
65 struct rndis_gen_msg
66 {
67     rt_uint32_t	MessageType;
68     rt_uint32_t	MessageLength;
69 };
70 typedef struct rndis_gen_msg* rndis_gen_msg_t;
71 
72 struct rndis_packet_msg
73 {
74 	rt_uint32_t	MessageType;
75 	rt_uint32_t	MessageLength;
76 	rt_uint32_t	DataOffset;
77 	rt_uint32_t	DataLength;
78 	rt_uint32_t	OOBDataOffset;
79 	rt_uint32_t	OOBDataLength;
80 	rt_uint32_t	NumOOBDataElements;
81 	rt_uint32_t	PerPacketInfoOffset;
82 	rt_uint32_t	PerPacketInfoLength;
83 	rt_uint32_t	VcHandle;
84 	rt_uint32_t	Reserved;
85 };
86 typedef struct rndis_packet_msg* rndis_packet_msg_t;
87 
88 /* Remote NDIS Initialize Message */
89 struct rndis_init_msg
90 {
91     rt_uint32_t MessageType;
92     rt_uint32_t	MessageLength;
93     rt_uint32_t	RequestId;
94     rt_uint32_t	MajorVersion;
95     rt_uint32_t	MinorVersion;
96     rt_uint32_t	MaxTransferSize;
97 };
98 typedef struct rndis_init_msg* rndis_init_msg_t;
99 
100 /* Response */
101 struct rndis_init_cmplt
102 {
103     rt_uint32_t	MessageType;
104     rt_uint32_t	MessageLength;
105     rt_uint32_t	RequestId;
106     rt_uint32_t	Status;
107     rt_uint32_t	MajorVersion;
108     rt_uint32_t	MinorVersion;
109     rt_uint32_t	DeviceFlags;
110     rt_uint32_t	Medium;
111     rt_uint32_t MaxPacketsPerTransfer;
112     rt_uint32_t	MaxTransferSize;
113     rt_uint32_t PacketAlignmentFactor;
114     rt_uint32_t	AfListOffset;
115     rt_uint32_t	AfListSize;
116 };
117 typedef struct rndis_init_cmplt* rndis_init_cmplt_t;
118 
119 /* Remote NDIS Halt Message */
120 struct rndis_halt_msg
121 {
122     rt_uint32_t	MessageType;
123     rt_uint32_t	MessageLength;
124     rt_uint32_t	RequestId;
125 };
126 
127 /* Remote NDIS Query Message */
128 struct rndis_query_msg
129 {
130     rt_uint32_t	MessageType;
131     rt_uint32_t	MessageLength;
132     rt_uint32_t	RequestId;
133     rt_uint32_t	Oid;
134     rt_uint32_t	InformationBufferLength;
135     rt_uint32_t	InformationBufferOffset;
136     rt_uint32_t	DeviceVcHandle;
137 };
138 typedef struct rndis_query_msg* rndis_query_msg_t;
139 
140 /* Response */
141 struct rndis_query_cmplt
142 {
143     rt_uint32_t	MessageType;
144     rt_uint32_t	MessageLength;
145     rt_uint32_t	RequestId;
146     rt_uint32_t	Status;
147     rt_uint32_t	InformationBufferLength;
148     rt_uint32_t	InformationBufferOffset;
149 };
150 typedef struct rndis_query_cmplt* rndis_query_cmplt_t;
151 
152 /* Remote NDIS Set Message */
153 struct rndis_set_msg
154 {
155     rt_uint32_t	MessageType;
156     rt_uint32_t	MessageLength;
157     rt_uint32_t	RequestId;
158     rt_uint32_t	Oid;
159     rt_uint32_t	InformationBufferLength;
160     rt_uint32_t	InformationBufferOffset;
161     rt_uint32_t	DeviceVcHandle;
162 };
163 typedef struct rndis_set_msg* rndis_set_msg_t;
164 
165 /* Response */
166 struct rndis_set_cmplt
167 {
168     rt_uint32_t	MessageType;
169     rt_uint32_t	MessageLength;
170     rt_uint32_t	RequestId;
171     rt_uint32_t	Status;
172 };
173 typedef struct rndis_set_cmplt* rndis_set_cmplt_t;
174 
175 /* Remote NDIS Soft Reset Message */
176 struct rndis_reset_msg
177 {
178     rt_uint32_t	MessageType;
179     rt_uint32_t	MessageLength;
180     rt_uint32_t	Reserved;
181 };
182 
183 /* Remote NDIS Indicate Status Message */
184 struct rndis_indicate_status_msg
185 {
186     rt_uint32_t MessageType;
187     rt_uint32_t	MessageLength;
188     rt_uint32_t	Status;
189     rt_uint32_t	StatusBufferLength;
190     rt_uint32_t	StatusBufferOffset;
191 };
192 typedef struct rndis_indicate_status_msg* rndis_indicate_status_msg_t;
193 
194 struct rndis_keepalive_msg
195 {
196 	rt_uint32_t	MessageType;
197 	rt_uint32_t	MessageLength;
198 	rt_uint32_t	RequestID;
199 };
200 typedef struct rndis_keepalive_msg* rndis_keepalive_msg_t;
201 
202 /* Response: */
203 struct rndis_keepalive_cmplt
204 {
205 	rt_uint32_t	MessageType;
206 	rt_uint32_t	MessageLength;
207 	rt_uint32_t	RequestId;
208 	rt_uint32_t	Status;
209 };
210 typedef struct rndis_keepalive_cmplt* rndis_keepalive_cmplt_t;
211 
212 
213 
214 
215 
216 
217 
218 #endif
219