rndis.h revision 307260
1/* $FreeBSD: stable/10/sys/net/rndis.h 307260 2016-10-14 05:05:23Z sephe $ */ 2/* $OpenBSD: if_urndisreg.h,v 1.19 2013/11/21 14:08:05 mpi Exp $ */ 3 4/* 5 * Copyright (c) 2010 Jonathan Armani <armani@openbsd.org> 6 * Copyright (c) 2010 Fabien Romano <fabien@openbsd.org> 7 * Copyright (c) 2010 Michael Knudsen <mk@openbsd.org> 8 * All rights reserved. 9 * 10 * Permission to use, copy, modify, and distribute this software for any 11 * purpose with or without fee is hereby granted, provided that the above 12 * copyright notice and this permission notice appear in all copies. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 */ 22 23#ifndef _NET_RNDIS_H_ 24#define _NET_RNDIS_H_ 25 26/* Canonical major/minor version as of 22th Aug. 2016. */ 27#define RNDIS_VERSION_MAJOR 0x00000001 28#define RNDIS_VERSION_MINOR 0x00000000 29 30#define RNDIS_STATUS_SUCCESS 0x00000000L 31#define RNDIS_STATUS_PENDING 0x00000103L 32#define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL 33#define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL 34#define RNDIS_STATUS_NETWORK_CHANGE 0x40010018L 35#define RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG 0x40020006L 36#define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L 37#define RNDIS_STATUS_FAILURE 0xC0000001L 38#define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL 39#define RNDIS_STATUS_RESOURCES 0xC000009AL 40#define RNDIS_STATUS_INVALID_DATA 0xC0010015L 41 42#define OID_GEN_SUPPORTED_LIST 0x00010101 43#define OID_GEN_HARDWARE_STATUS 0x00010102 44#define OID_GEN_MEDIA_SUPPORTED 0x00010103 45#define OID_GEN_MEDIA_IN_USE 0x00010104 46#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 47#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 48#define OID_GEN_LINK_SPEED 0x00010107 49#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 50#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 51#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A 52#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B 53#define OID_GEN_VENDOR_ID 0x0001010C 54#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D 55#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E 56#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F 57#define OID_GEN_DRIVER_VERSION 0x00010110 58#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 59#define OID_GEN_PROTOCOL_OPTIONS 0x00010112 60#define OID_GEN_MAC_OPTIONS 0x00010113 61#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 62#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 63#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 64#define OID_GEN_SUPPORTED_GUIDS 0x00010117 65#define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118 66#define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119 67#define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203 68#define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204 69#define OID_GEN_MACHINE_NAME 0x0001021A 70#define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B 71#define OID_GEN_VLAN_ID 0x0001021C 72 73#define OID_802_3_PERMANENT_ADDRESS 0x01010101 74#define OID_802_3_CURRENT_ADDRESS 0x01010102 75#define OID_802_3_MULTICAST_LIST 0x01010103 76#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 77#define OID_802_3_MAC_OPTIONS 0x01010105 78#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 79#define OID_802_3_XMIT_ONE_COLLISION 0x01020102 80#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103 81#define OID_802_3_XMIT_DEFERRED 0x01020201 82#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202 83#define OID_802_3_RCV_OVERRUN 0x01020203 84#define OID_802_3_XMIT_UNDERRUN 0x01020204 85#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205 86#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 87#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 88 89#define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C 90 91#define RNDIS_MEDIUM_802_3 0x00000000 92 93/* Device flags */ 94#define RNDIS_DF_CONNECTIONLESS 0x00000001 95#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 96 97/* 98 * Common RNDIS message header. 99 */ 100struct rndis_msghdr { 101 uint32_t rm_type; 102 uint32_t rm_len; 103}; 104 105/* 106 * RNDIS data message 107 */ 108#define REMOTE_NDIS_PACKET_MSG 0x00000001 109 110struct rndis_packet_msg { 111 uint32_t rm_type; 112 uint32_t rm_len; 113 uint32_t rm_dataoffset; 114 uint32_t rm_datalen; 115 uint32_t rm_oobdataoffset; 116 uint32_t rm_oobdatalen; 117 uint32_t rm_oobdataelements; 118 uint32_t rm_pktinfooffset; 119 uint32_t rm_pktinfolen; 120 uint32_t rm_vchandle; 121 uint32_t rm_reserved; 122}; 123 124/* 125 * Minimum value for rm_dataoffset, rm_oobdataoffset, and 126 * rm_pktinfooffset. 127 */ 128#define RNDIS_PACKET_MSG_OFFSET_MIN \ 129 (sizeof(struct rndis_packet_msg) - \ 130 __offsetof(struct rndis_packet_msg, rm_dataoffset)) 131 132/* Offset from the beginning of rndis_packet_msg. */ 133#define RNDIS_PACKET_MSG_OFFSET_ABS(ofs) \ 134 ((ofs) + __offsetof(struct rndis_packet_msg, rm_dataoffset)) 135 136#define RNDIS_PACKET_MSG_OFFSET_ALIGN 4 137#define RNDIS_PACKET_MSG_OFFSET_ALIGNMASK \ 138 (RNDIS_PACKET_MSG_OFFSET_ALIGN - 1) 139 140/* Per-packet-info for RNDIS data message */ 141struct rndis_pktinfo { 142 uint32_t rm_size; 143 uint32_t rm_type; /* NDIS_PKTINFO_TYPE_ */ 144 uint32_t rm_pktinfooffset; 145 uint8_t rm_data[]; 146}; 147 148#define RNDIS_PKTINFO_OFFSET \ 149 __offsetof(struct rndis_pktinfo, rm_data[0]) 150#define RNDIS_PKTINFO_SIZE_ALIGN 4 151#define RNDIS_PKTINFO_SIZE_ALIGNMASK (RNDIS_PKTINFO_SIZE_ALIGN - 1) 152 153#define NDIS_PKTINFO_TYPE_CSUM 0 154#define NDIS_PKTINFO_TYPE_IPSEC 1 155#define NDIS_PKTINFO_TYPE_LSO 2 156#define NDIS_PKTINFO_TYPE_CLASSIFY 3 157/* reserved 4 */ 158#define NDIS_PKTINFO_TYPE_SGLIST 5 159#define NDIS_PKTINFO_TYPE_VLAN 6 160#define NDIS_PKTINFO_TYPE_ORIG 7 161#define NDIS_PKTINFO_TYPE_PKT_CANCELID 8 162#define NDIS_PKTINFO_TYPE_ORIG_NBLIST 9 163#define NDIS_PKTINFO_TYPE_CACHE_NBLIST 10 164#define NDIS_PKTINFO_TYPE_PKT_PAD 11 165 166/* 167 * RNDIS control messages 168 */ 169 170/* 171 * Common header for RNDIS completion messages. 172 * 173 * NOTE: It does not apply to REMOTE_NDIS_RESET_CMPLT. 174 */ 175struct rndis_comp_hdr { 176 uint32_t rm_type; 177 uint32_t rm_len; 178 uint32_t rm_rid; 179 uint32_t rm_status; 180}; 181 182/* Initialize the device. */ 183#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002 184#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002 185 186struct rndis_init_req { 187 uint32_t rm_type; 188 uint32_t rm_len; 189 uint32_t rm_rid; 190 uint32_t rm_ver_major; 191 uint32_t rm_ver_minor; 192 uint32_t rm_max_xfersz; 193}; 194 195struct rndis_init_comp { 196 uint32_t rm_type; 197 uint32_t rm_len; 198 uint32_t rm_rid; 199 uint32_t rm_status; 200 uint32_t rm_ver_major; 201 uint32_t rm_ver_minor; 202 uint32_t rm_devflags; 203 uint32_t rm_medium; 204 uint32_t rm_pktmaxcnt; 205 uint32_t rm_pktmaxsz; 206 uint32_t rm_align; 207 uint32_t rm_aflistoffset; 208 uint32_t rm_aflistsz; 209}; 210 211#define RNDIS_INIT_COMP_SIZE_MIN \ 212 __offsetof(struct rndis_init_comp, rm_aflistsz) 213 214/* Halt the device. No response sent. */ 215#define REMOTE_NDIS_HALT_MSG 0x00000003 216 217struct rndis_halt_req { 218 uint32_t rm_type; 219 uint32_t rm_len; 220 uint32_t rm_rid; 221}; 222 223/* Send a query object. */ 224#define REMOTE_NDIS_QUERY_MSG 0x00000004 225#define REMOTE_NDIS_QUERY_CMPLT 0x80000004 226 227struct rndis_query_req { 228 uint32_t rm_type; 229 uint32_t rm_len; 230 uint32_t rm_rid; 231 uint32_t rm_oid; 232 uint32_t rm_infobuflen; 233 uint32_t rm_infobufoffset; 234 uint32_t rm_devicevchdl; 235}; 236 237#define RNDIS_QUERY_REQ_INFOBUFOFFSET \ 238 (sizeof(struct rndis_query_req) - \ 239 __offsetof(struct rndis_query_req, rm_rid)) 240 241struct rndis_query_comp { 242 uint32_t rm_type; 243 uint32_t rm_len; 244 uint32_t rm_rid; 245 uint32_t rm_status; 246 uint32_t rm_infobuflen; 247 uint32_t rm_infobufoffset; 248}; 249 250/* infobuf offset from the beginning of rndis_query_comp. */ 251#define RNDIS_QUERY_COMP_INFOBUFOFFSET_ABS(ofs) \ 252 ((ofs) + __offsetof(struct rndis_query_req, rm_rid)) 253 254/* Send a set object request. */ 255#define REMOTE_NDIS_SET_MSG 0x00000005 256#define REMOTE_NDIS_SET_CMPLT 0x80000005 257 258struct rndis_set_req { 259 uint32_t rm_type; 260 uint32_t rm_len; 261 uint32_t rm_rid; 262 uint32_t rm_oid; 263 uint32_t rm_infobuflen; 264 uint32_t rm_infobufoffset; 265 uint32_t rm_devicevchdl; 266}; 267 268#define RNDIS_SET_REQ_INFOBUFOFFSET \ 269 (sizeof(struct rndis_set_req) - \ 270 __offsetof(struct rndis_set_req, rm_rid)) 271 272struct rndis_set_comp { 273 uint32_t rm_type; 274 uint32_t rm_len; 275 uint32_t rm_rid; 276 uint32_t rm_status; 277}; 278 279/* 280 * Parameter used by OID_GEN_RNDIS_CONFIG_PARAMETER. 281 */ 282#define REMOTE_NDIS_SET_PARAM_NUMERIC 0x00000000 283#define REMOTE_NDIS_SET_PARAM_STRING 0x00000002 284 285struct rndis_set_parameter { 286 uint32_t rm_nameoffset; 287 uint32_t rm_namelen; 288 uint32_t rm_type; 289 uint32_t rm_valueoffset; 290 uint32_t rm_valuelen; 291}; 292 293/* Perform a soft reset on the device. */ 294#define REMOTE_NDIS_RESET_MSG 0x00000006 295#define REMOTE_NDIS_RESET_CMPLT 0x80000006 296 297struct rndis_reset_req { 298 uint32_t rm_type; 299 uint32_t rm_len; 300 uint32_t rm_rid; 301}; 302 303struct rndis_reset_comp { 304 uint32_t rm_type; 305 uint32_t rm_len; 306 uint32_t rm_status; 307 uint32_t rm_adrreset; 308}; 309 310/* 802.3 link-state or undefined message error. Sent by device. */ 311#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 312 313struct rndis_status_msg { 314 uint32_t rm_type; 315 uint32_t rm_len; 316 uint32_t rm_status; 317 uint32_t rm_stbuflen; 318 uint32_t rm_stbufoffset; 319 /* rndis_diag_info */ 320}; 321 322/* 323 * Immediately after rndis_status_msg.rm_stbufoffset, if a control 324 * message is malformatted, or a packet message contains inappropriate 325 * content. 326 */ 327struct rndis_diag_info { 328 uint32_t rm_diagstatus; 329 uint32_t rm_erroffset; 330}; 331 332/* Keepalive messsage. May be sent by device. */ 333#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 334#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 335 336struct rndis_keepalive_req { 337 uint32_t rm_type; 338 uint32_t rm_len; 339 uint32_t rm_rid; 340}; 341 342struct rndis_keepalive_comp { 343 uint32_t rm_type; 344 uint32_t rm_len; 345 uint32_t rm_rid; 346 uint32_t rm_status; 347}; 348 349/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */ 350#define NDIS_PACKET_TYPE_DIRECTED 0x00000001 351#define NDIS_PACKET_TYPE_MULTICAST 0x00000002 352#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 353#define NDIS_PACKET_TYPE_BROADCAST 0x00000008 354#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 355#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 356#define NDIS_PACKET_TYPE_SMT 0x00000040 357#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 358#define NDIS_PACKET_TYPE_GROUP 0x00001000 359#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000 360#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00004000 361#define NDIS_PACKET_TYPE_MAC_FRAME 0x00008000 362 363/* RNDIS offsets */ 364#define RNDIS_HEADER_OFFSET ((uint32_t)sizeof(struct rndis_msghdr)) 365#define RNDIS_DATA_OFFSET \ 366 ((uint32_t)(sizeof(struct rndis_packet_msg) - RNDIS_HEADER_OFFSET)) 367 368#endif /* !_NET_RNDIS_H_ */ 369