1 /* $FreeBSD$ */ 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_BUFFER_OVERFLOW 0x80000005L 35 #define RNDIS_STATUS_FAILURE 0xC0000001L 36 #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL 37 #define RNDIS_STATUS_RESOURCES 0xC000009AL 38 #define RNDIS_STATUS_INVALID_DATA 0xC0010015L 39 40 #define OID_GEN_SUPPORTED_LIST 0x00010101 41 #define OID_GEN_HARDWARE_STATUS 0x00010102 42 #define OID_GEN_MEDIA_SUPPORTED 0x00010103 43 #define OID_GEN_MEDIA_IN_USE 0x00010104 44 #define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 45 #define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 46 #define OID_GEN_LINK_SPEED 0x00010107 47 #define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 48 #define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 49 #define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A 50 #define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B 51 #define OID_GEN_VENDOR_ID 0x0001010C 52 #define OID_GEN_VENDOR_DESCRIPTION 0x0001010D 53 #define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E 54 #define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F 55 #define OID_GEN_DRIVER_VERSION 0x00010110 56 #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 57 #define OID_GEN_PROTOCOL_OPTIONS 0x00010112 58 #define OID_GEN_MAC_OPTIONS 0x00010113 59 #define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 60 #define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 61 #define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 62 #define OID_GEN_SUPPORTED_GUIDS 0x00010117 63 #define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118 64 #define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119 65 #define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203 66 #define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204 67 #define OID_GEN_MACHINE_NAME 0x0001021A 68 #define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B 69 #define OID_GEN_VLAN_ID 0x0001021C 70 71 #define OID_802_3_PERMANENT_ADDRESS 0x01010101 72 #define OID_802_3_CURRENT_ADDRESS 0x01010102 73 #define OID_802_3_MULTICAST_LIST 0x01010103 74 #define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 75 #define OID_802_3_MAC_OPTIONS 0x01010105 76 #define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 77 #define OID_802_3_XMIT_ONE_COLLISION 0x01020102 78 #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103 79 #define OID_802_3_XMIT_DEFERRED 0x01020201 80 #define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202 81 #define OID_802_3_RCV_OVERRUN 0x01020203 82 #define OID_802_3_XMIT_UNDERRUN 0x01020204 83 #define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205 84 #define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 85 #define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 86 87 #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C 88 89 #define RNDIS_MEDIUM_802_3 0x00000000 90 91 /* Device flags */ 92 #define RNDIS_DF_CONNECTIONLESS 0x00000001 93 #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 94 95 /* 96 * RNDIS data message 97 */ 98 #define REMOTE_NDIS_PACKET_MSG 0x00000001 99 100 struct rndis_packet_msg { 101 uint32_t rm_type; 102 uint32_t rm_len; 103 uint32_t rm_dataoffset; 104 uint32_t rm_datalen; 105 uint32_t rm_oobdataoffset; 106 uint32_t rm_oobdatalen; 107 uint32_t rm_oobdataelements; 108 uint32_t rm_pktinfooffset; 109 uint32_t rm_pktinfolen; 110 uint32_t rm_vchandle; 111 uint32_t rm_reserved; 112 }; 113 114 /* 115 * RNDIS control messages 116 */ 117 struct rndis_comp_hdr { 118 uint32_t rm_type; 119 uint32_t rm_len; 120 uint32_t rm_rid; 121 uint32_t rm_status; 122 }; 123 124 /* Initialize the device. */ 125 #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002 126 #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002 127 128 struct rndis_init_req { 129 uint32_t rm_type; 130 uint32_t rm_len; 131 uint32_t rm_rid; 132 uint32_t rm_ver_major; 133 uint32_t rm_ver_minor; 134 uint32_t rm_max_xfersz; 135 }; 136 137 struct rndis_init_comp { 138 uint32_t rm_type; 139 uint32_t rm_len; 140 uint32_t rm_rid; 141 uint32_t rm_status; 142 uint32_t rm_ver_major; 143 uint32_t rm_ver_minor; 144 uint32_t rm_devflags; 145 uint32_t rm_medium; 146 uint32_t rm_pktmaxcnt; 147 uint32_t rm_pktmaxsz; 148 uint32_t rm_align; 149 uint32_t rm_aflistoffset; 150 uint32_t rm_aflistsz; 151 }; 152 153 #define RNDIS_INIT_COMP_SIZE_MIN \ 154 __offsetof(struct rndis_init_comp, rm_aflistsz) 155 156 /* Halt the device. No response sent. */ 157 #define REMOTE_NDIS_HALT_MSG 0x00000003 158 159 struct rndis_halt_req { 160 uint32_t rm_type; 161 uint32_t rm_len; 162 uint32_t rm_rid; 163 }; 164 165 /* Send a query object. */ 166 #define REMOTE_NDIS_QUERY_MSG 0x00000004 167 #define REMOTE_NDIS_QUERY_CMPLT 0x80000004 168 169 struct rndis_query_req { 170 uint32_t rm_type; 171 uint32_t rm_len; 172 uint32_t rm_rid; 173 uint32_t rm_oid; 174 uint32_t rm_infobuflen; 175 uint32_t rm_infobufoffset; 176 uint32_t rm_devicevchdl; 177 }; 178 179 #define RNDIS_QUERY_REQ_INFOBUFOFFSET \ 180 (sizeof(struct rndis_query_req) - \ 181 __offsetof(struct rndis_query_req, rm_rid)) 182 183 struct rndis_query_comp { 184 uint32_t rm_type; 185 uint32_t rm_len; 186 uint32_t rm_rid; 187 uint32_t rm_status; 188 uint32_t rm_infobuflen; 189 uint32_t rm_infobufoffset; 190 }; 191 192 #define RNDIS_QUERY_COMP_INFOBUFABS(ofs) \ 193 ((ofs) + __offsetof(struct rndis_query_req, rm_rid)) 194 195 /* Send a set object request. */ 196 #define REMOTE_NDIS_SET_MSG 0x00000005 197 #define REMOTE_NDIS_SET_CMPLT 0x80000005 198 199 struct rndis_set_req { 200 uint32_t rm_type; 201 uint32_t rm_len; 202 uint32_t rm_rid; 203 uint32_t rm_oid; 204 uint32_t rm_infobuflen; 205 uint32_t rm_infobufoffset; 206 uint32_t rm_devicevchdl; 207 }; 208 209 #define RNDIS_SET_REQ_INFOBUFOFFSET \ 210 (sizeof(struct rndis_set_req) - \ 211 __offsetof(struct rndis_set_req, rm_rid)) 212 213 struct rndis_set_comp { 214 uint32_t rm_type; 215 uint32_t rm_len; 216 uint32_t rm_rid; 217 uint32_t rm_status; 218 }; 219 220 #define REMOTE_NDIS_SET_PARAM_NUMERIC 0x00000000 221 #define REMOTE_NDIS_SET_PARAM_STRING 0x00000002 222 223 struct rndis_set_parameter { 224 uint32_t rm_nameoffset; 225 uint32_t rm_namelen; 226 uint32_t rm_type; 227 uint32_t rm_valueoffset; 228 uint32_t rm_valuelen; 229 }; 230 231 /* Perform a soft reset on the device. */ 232 #define REMOTE_NDIS_RESET_MSG 0x00000006 233 #define REMOTE_NDIS_RESET_CMPLT 0x80000006 234 235 struct rndis_reset_req { 236 uint32_t rm_type; 237 uint32_t rm_len; 238 uint32_t rm_rid; 239 }; 240 241 struct rndis_reset_comp { 242 uint32_t rm_type; 243 uint32_t rm_len; 244 uint32_t rm_status; 245 uint32_t rm_adrreset; 246 }; 247 248 /* 802.3 link-state or undefined message error. */ 249 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 250 251 /* Keepalive messsage. May be sent by device. */ 252 #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 253 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 254 255 struct rndis_keepalive_req { 256 uint32_t rm_type; 257 uint32_t rm_len; 258 uint32_t rm_rid; 259 }; 260 261 struct rndis_keepalive_comp { 262 uint32_t rm_type; 263 uint32_t rm_len; 264 uint32_t rm_rid; 265 uint32_t rm_status; 266 }; 267 268 /* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */ 269 #define RNDIS_PACKET_TYPE_DIRECTED 0x00000001 270 #define RNDIS_PACKET_TYPE_MULTICAST 0x00000002 271 #define RNDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 272 #define RNDIS_PACKET_TYPE_BROADCAST 0x00000008 273 #define RNDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 274 #define RNDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 275 #define RNDIS_PACKET_TYPE_SMT 0x00000040 276 #define RNDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 277 #define RNDIS_PACKET_TYPE_GROUP 0x00001000 278 #define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000 279 #define RNDIS_PACKET_TYPE_FUNCTIONAL 0x00004000 280 #define RNDIS_PACKET_TYPE_MAC_FRAME 0x00008000 281 282 /* RNDIS offsets */ 283 #define RNDIS_HEADER_OFFSET 8 /* bytes */ 284 #define RNDIS_DATA_OFFSET \ 285 ((uint32_t)(sizeof(struct rndis_packet_msg) - RNDIS_HEADER_OFFSET)) 286 287 #endif /* !_NET_RNDIS_H_ */ 288