1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2018 Microsoft Corp.
3 * Copyright (c) 2010 Jonathan Armani <armani@openbsd.org>
4 * Copyright (c) 2010 Fabien Romano <fabien@openbsd.org>
5 * Copyright (c) 2010 Michael Knudsen <mk@openbsd.org>
12 /* Canonical major/minor version as of 22th Aug. 2016. */
13 #define RNDIS_VERSION_MAJOR 0x00000001
14 #define RNDIS_VERSION_MINOR 0x00000000
16 #define RNDIS_STATUS_SUCCESS 0x00000000
17 #define RNDIS_STATUS_PENDING 0x00000103
19 #define RNDIS_STATUS_ONLINE 0x40010003
20 #define RNDIS_STATUS_RESET_START 0x40010004
21 #define RNDIS_STATUS_RESET_END 0x40010005
22 #define RNDIS_STATUS_RING_STATUS 0x40010006
23 #define RNDIS_STATUS_CLOSED 0x40010007
24 #define RNDIS_STATUS_WAN_LINE_UP 0x40010008
25 #define RNDIS_STATUS_WAN_LINE_DOWN 0x40010009
26 #define RNDIS_STATUS_WAN_FRAGMENT 0x4001000A
27 #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000B
28 #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000C
29 #define RNDIS_STATUS_HARDWARE_LINE_UP 0x4001000D
30 #define RNDIS_STATUS_HARDWARE_LINE_DOWN 0x4001000E
31 #define RNDIS_STATUS_INTERFACE_UP 0x4001000F
32 #define RNDIS_STATUS_INTERFACE_DOWN 0x40010010
33 #define RNDIS_STATUS_MEDIA_BUSY 0x40010011
34 #define RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION 0x40010012
35 #define RNDIS_STATUS_WW_INDICATION RDIA_SPECIFIC_INDICATION
36 #define RNDIS_STATUS_LINK_SPEED_CHANGE 0x40010013
37 #define RNDIS_STATUS_NETWORK_CHANGE 0x40010018
38 #define RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG 0x40020006
40 #define RNDIS_STATUS_FAILURE 0xC0000001
41 #define RNDIS_STATUS_RESOURCES 0xC000009A
42 #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BB
43 #define RNDIS_STATUS_CLOSING 0xC0010002
44 #define RNDIS_STATUS_BAD_VERSION 0xC0010004
45 #define RNDIS_STATUS_BAD_CHARACTERISTICS 0xC0010005
46 #define RNDIS_STATUS_ADAPTER_NOT_FOUND 0xC0010006
47 #define RNDIS_STATUS_OPEN_FAILED 0xC0010007
48 #define RNDIS_STATUS_DEVICE_FAILED 0xC0010008
49 #define RNDIS_STATUS_MULTICAST_FULL 0xC0010009
50 #define RNDIS_STATUS_MULTICAST_EXISTS 0xC001000A
51 #define RNDIS_STATUS_MULTICAST_NOT_FOUND 0xC001000B
52 #define RNDIS_STATUS_REQUEST_ABORTED 0xC001000C
53 #define RNDIS_STATUS_RESET_IN_PROGRESS 0xC001000D
54 #define RNDIS_STATUS_CLOSING_INDICATING 0xC001000E
55 #define RNDIS_STATUS_INVALID_PACKET 0xC001000F
56 #define RNDIS_STATUS_OPEN_LIST_FULL 0xC0010010
57 #define RNDIS_STATUS_ADAPTER_NOT_READY 0xC0010011
58 #define RNDIS_STATUS_ADAPTER_NOT_OPEN 0xC0010012
59 #define RNDIS_STATUS_NOT_INDICATING 0xC0010013
60 #define RNDIS_STATUS_INVALID_LENGTH 0xC0010014
61 #define RNDIS_STATUS_INVALID_DATA 0xC0010015
62 #define RNDIS_STATUS_BUFFER_TOO_SHORT 0xC0010016
63 #define RNDIS_STATUS_INVALID_OID 0xC0010017
64 #define RNDIS_STATUS_ADAPTER_REMOVED 0xC0010018
65 #define RNDIS_STATUS_UNSUPPORTED_MEDIA 0xC0010019
66 #define RNDIS_STATUS_GROUP_ADDRESS_IN_US 0xC001001A
67 #define RNDIS_STATUS_FILE_NOT_FOUND 0xC001001B
68 #define RNDIS_STATUS_ERROR_READING_FILE 0xC001001C
69 #define RNDIS_STATUS_ALREADY_MAPPED 0xC001001D
70 #define RNDIS_STATUS_RESOURCE_CONFLICT 0xC001001E
71 #define RNDIS_STATUS_NO_CABLE 0xC001001F
73 #define OID_GEN_SUPPORTED_LIST 0x00010101
74 #define OID_GEN_HARDWARE_STATUS 0x00010102
75 #define OID_GEN_MEDIA_SUPPORTED 0x00010103
76 #define OID_GEN_MEDIA_IN_USE 0x00010104
77 #define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105
78 #define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106
79 #define OID_GEN_LINK_SPEED 0x00010107
80 #define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108
81 #define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109
82 #define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A
83 #define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B
84 #define OID_GEN_VENDOR_ID 0x0001010C
85 #define OID_GEN_VENDOR_DESCRIPTION 0x0001010D
86 #define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E
87 #define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F
88 #define OID_GEN_DRIVER_VERSION 0x00010110
89 #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111
90 #define OID_GEN_PROTOCOL_OPTIONS 0x00010112
91 #define OID_GEN_MAC_OPTIONS 0x00010113
92 #define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114
93 #define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115
94 #define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116
95 #define OID_GEN_SUPPORTED_GUIDS 0x00010117
96 #define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118
97 #define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119
98 #define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203
99 #define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204
100 #define OID_GEN_MACHINE_NAME 0x0001021A
101 #define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B
102 #define OID_GEN_VLAN_ID 0x0001021C
104 #define OID_802_3_PERMANENT_ADDRESS 0x01010101
105 #define OID_802_3_CURRENT_ADDRESS 0x01010102
106 #define OID_802_3_MULTICAST_LIST 0x01010103
107 #define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104
108 #define OID_802_3_MAC_OPTIONS 0x01010105
109 #define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101
110 #define OID_802_3_XMIT_ONE_COLLISION 0x01020102
111 #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103
112 #define OID_802_3_XMIT_DEFERRED 0x01020201
113 #define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202
114 #define OID_802_3_RCV_OVERRUN 0x01020203
115 #define OID_802_3_XMIT_UNDERRUN 0x01020204
116 #define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205
117 #define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206
118 #define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207
120 #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C
121 #define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020D
123 #define RNDIS_MEDIUM_802_3 0x00000000
126 #define RNDIS_DF_CONNECTIONLESS 0x00000001
127 #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
130 * Common RNDIS message header.
132 struct rndis_msghdr {
140 #define RNDIS_PACKET_MSG 0x00000001
142 struct rndis_packet_msg {
147 uint32_t oobdataoffset;
149 uint32_t oobdataelements;
150 uint32_t pktinfooffset;
157 * Minimum value for dataoffset, oobdataoffset, and
160 #define RNDIS_PACKET_MSG_OFFSET_MIN \
161 (sizeof(struct rndis_packet_msg) - \
162 offsetof(struct rndis_packet_msg, dataoffset))
164 /* Offset from the beginning of rndis_packet_msg. */
165 #define RNDIS_PACKET_MSG_OFFSET_ABS(ofs) \
166 ((ofs) + offsetof(struct rndis_packet_msg, dataoffset))
168 #define RNDIS_PACKET_MSG_OFFSET_ALIGN 4
169 #define RNDIS_PACKET_MSG_OFFSET_ALIGNMASK \
170 (RNDIS_PACKET_MSG_OFFSET_ALIGN - 1)
172 /* Per-packet-info for RNDIS data message */
173 struct rndis_pktinfo {
175 uint32_t type; /* NDIS_PKTINFO_TYPE_ */
180 #define RNDIS_PKTINFO_OFFSET \
181 offsetof(struct rndis_pktinfo, data[0])
182 #define RNDIS_PKTINFO_SIZE_ALIGN 4
183 #define RNDIS_PKTINFO_SIZE_ALIGNMASK (RNDIS_PKTINFO_SIZE_ALIGN - 1)
185 #define NDIS_PKTINFO_TYPE_CSUM 0
186 #define NDIS_PKTINFO_TYPE_IPSEC 1
187 #define NDIS_PKTINFO_TYPE_LSO 2
188 #define NDIS_PKTINFO_TYPE_CLASSIFY 3
190 #define NDIS_PKTINFO_TYPE_SGLIST 5
191 #define NDIS_PKTINFO_TYPE_VLAN 6
192 #define NDIS_PKTINFO_TYPE_ORIG 7
193 #define NDIS_PKTINFO_TYPE_PKT_CANCELID 8
194 #define NDIS_PKTINFO_TYPE_ORIG_NBLIST 9
195 #define NDIS_PKTINFO_TYPE_CACHE_NBLIST 10
196 #define NDIS_PKTINFO_TYPE_PKT_PAD 11
198 /* RNDIS extension */
200 /* Per-packet hash info */
201 #define NDIS_HASH_INFO_SIZE sizeof(uint32_t)
202 #define NDIS_PKTINFO_TYPE_HASHINF NDIS_PKTINFO_TYPE_ORIG_NBLIST
205 /* Per-packet hash value */
206 #define NDIS_HASH_VALUE_SIZE sizeof(uint32_t)
207 #define NDIS_PKTINFO_TYPE_HASHVAL NDIS_PKTINFO_TYPE_PKT_CANCELID
209 /* Per-packet-info size */
210 #define RNDIS_PKTINFO_SIZE(dlen) offsetof(struct rndis_pktinfo, data[dlen])
213 * RNDIS control messages
217 * Common header for RNDIS completion messages.
219 * NOTE: It does not apply to RNDIS_RESET_CMPLT.
221 struct rndis_comp_hdr {
228 /* Initialize the device. */
229 #define RNDIS_INITIALIZE_MSG 0x00000002
230 #define RNDIS_INITIALIZE_CMPLT 0x80000002
232 struct rndis_init_req {
241 struct rndis_init_comp {
253 uint32_t aflistoffset;
257 #define RNDIS_INIT_COMP_SIZE_MIN \
258 offsetof(struct rndis_init_comp, aflistsz)
260 /* Halt the device. No response sent. */
261 #define RNDIS_HALT_MSG 0x00000003
263 struct rndis_halt_req {
269 /* Send a query object. */
270 #define RNDIS_QUERY_MSG 0x00000004
271 #define RNDIS_QUERY_CMPLT 0x80000004
273 struct rndis_query_req {
279 uint32_t infobufoffset;
280 uint32_t devicevchdl;
283 #define RNDIS_QUERY_REQ_INFOBUFOFFSET \
284 (sizeof(struct rndis_query_req) - \
285 offsetof(struct rndis_query_req, rid))
287 struct rndis_query_comp {
293 uint32_t infobufoffset;
296 /* infobuf offset from the beginning of rndis_query_comp. */
297 #define RNDIS_QUERY_COMP_INFOBUFOFFSET_ABS(ofs) \
298 ((ofs) + offsetof(struct rndis_query_comp, rid))
300 /* Send a set object request. */
301 #define RNDIS_SET_MSG 0x00000005
302 #define RNDIS_SET_CMPLT 0x80000005
304 struct rndis_set_req {
310 uint32_t infobufoffset;
311 uint32_t devicevchdl;
314 #define RNDIS_SET_REQ_INFOBUFOFFSET \
315 (sizeof(struct rndis_set_req) - \
316 offsetof(struct rndis_set_req, rid))
318 struct rndis_set_comp {
326 * Parameter used by OID_GEN_RNDIS_CONFIG_PARAMETER.
328 #define RNDIS_SET_PARAM_NUMERIC 0x00000000
329 #define RNDIS_SET_PARAM_STRING 0x00000002
331 struct rndis_set_parameter {
335 uint32_t valueoffset;
339 /* Perform a soft reset on the device. */
340 #define RNDIS_RESET_MSG 0x00000006
341 #define RNDIS_RESET_CMPLT 0x80000006
343 struct rndis_reset_req {
349 struct rndis_reset_comp {
356 /* 802.3 link-state or undefined message error. Sent by device. */
357 #define RNDIS_INDICATE_STATUS_MSG 0x00000007
359 struct rndis_status_msg {
364 uint32_t stbufoffset;
365 /* rndis_diag_info */
368 /* stbuf offset from the beginning of rndis_status_msg. */
369 #define RNDIS_STBUFOFFSET_ABS(ofs) \
370 ((ofs) + offsetof(struct rndis_status_msg, status))
373 * Immediately after rndis_status_msg.stbufoffset, if a control
374 * message is malformatted, or a packet message contains inappropriate
377 struct rndis_diag_info {
382 /* Keepalive message. May be sent by device. */
383 #define RNDIS_KEEPALIVE_MSG 0x00000008
384 #define RNDIS_KEEPALIVE_CMPLT 0x80000008
386 struct rndis_keepalive_req {
392 struct rndis_keepalive_comp {
399 /* Packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */
400 #define NDIS_PACKET_TYPE_NONE 0x00000000
401 #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
402 #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
403 #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
404 #define NDIS_PACKET_TYPE_BROADCAST 0x00000008
405 #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
406 #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
407 #define NDIS_PACKET_TYPE_SMT 0x00000040
408 #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
409 #define NDIS_PACKET_TYPE_GROUP 0x00001000
410 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000
411 #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00004000
412 #define NDIS_PACKET_TYPE_MAC_FRAME 0x00008000
414 #endif /* !_NET_RNDIS_H_ */