1beacf11bSopenharmony_ci/**************************************************************************** 2beacf11bSopenharmony_ci * drivers/usbdev/rndis.c 3beacf11bSopenharmony_ci * 4beacf11bSopenharmony_ci * Copyright (C) 2011-2017 Gregory Nutt. All rights reserved. 5beacf11bSopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2017-2019. All rights reserved. 6beacf11bSopenharmony_ci * Authors: Sakari Kapanen <sakari.m.kapanen@gmail.com>, 7beacf11bSopenharmony_ci * Petteri Aimonen <jpa@git.mail.kapsi.fi> 8beacf11bSopenharmony_ci * 9beacf11bSopenharmony_ci * Redistribution and use in source and binary forms, with or without 10beacf11bSopenharmony_ci * modification, are permitted provided that the following conditions 11beacf11bSopenharmony_ci * are met: 12beacf11bSopenharmony_ci * 13beacf11bSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 14beacf11bSopenharmony_ci * notice, this list of conditions and the following disclaimer. 15beacf11bSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 16beacf11bSopenharmony_ci * notice, this list of conditions and the following disclaimer in 17beacf11bSopenharmony_ci * the documentation and/or other materials provided with the 18beacf11bSopenharmony_ci * distribution. 19beacf11bSopenharmony_ci * 3. Neither the name NuttX nor the names of its contributors may be 20beacf11bSopenharmony_ci * used to endorse or promote products derived from this software 21beacf11bSopenharmony_ci * without specific prior written permission. 22beacf11bSopenharmony_ci * 23beacf11bSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24beacf11bSopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25beacf11bSopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26beacf11bSopenharmony_ci * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27beacf11bSopenharmony_ci * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28beacf11bSopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29beacf11bSopenharmony_ci * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 30beacf11bSopenharmony_ci * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 31beacf11bSopenharmony_ci * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32beacf11bSopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33beacf11bSopenharmony_ci * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34beacf11bSopenharmony_ci * POSSIBILITY OF SUCH DAMAGE. 35beacf11bSopenharmony_ci * 36beacf11bSopenharmony_ci ****************************************************************************/ 37beacf11bSopenharmony_ci/**************************************************************************** 38beacf11bSopenharmony_ci * Notice of Export Control Law 39beacf11bSopenharmony_ci * =============================================== 40beacf11bSopenharmony_ci * Huawei LiteOS may be subject to applicable export control laws and regulations, 41beacf11bSopenharmony_ci * which might include those applicable to Huawei LiteOS of U.S. and the country in 42beacf11bSopenharmony_ci * which you are located. 43beacf11bSopenharmony_ci * Import, export and usage of Huawei LiteOS in any manner by you shall be in 44beacf11bSopenharmony_ci * compliance with such applicable export control laws and regulations. 45beacf11bSopenharmony_ci ****************************************************************************/ 46beacf11bSopenharmony_ci 47beacf11bSopenharmony_ci#ifndef __NUTTX_DRIVERS_USBDEV_RNDIS_STD_H 48beacf11bSopenharmony_ci#define __NUTTX_DRIVERS_USBDEV_RNDIS_STD_H 49beacf11bSopenharmony_ci 50beacf11bSopenharmony_ci/**************************************************************************** 51beacf11bSopenharmony_ci * Pre-processor definitions 52beacf11bSopenharmony_ci ****************************************************************************/ 53beacf11bSopenharmony_ci 54beacf11bSopenharmony_ci/* Definitions for Microsoft RNDIS protocol. 55beacf11bSopenharmony_ci * Documentation: 56beacf11bSopenharmony_ci * https://docs.microsoft.com/en-us/windows-hardware/drivers/network/remote-ndis--rndis-2 57beacf11bSopenharmony_ci * https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/WinArchive/[MS-RNDIS].pdf 58beacf11bSopenharmony_ci */ 59beacf11bSopenharmony_ci 60beacf11bSopenharmony_ci#define RNDIS_MAJOR_VERSION 1 61beacf11bSopenharmony_ci#define RNDIS_MINOR_VERSION 0 62beacf11bSopenharmony_ci 63beacf11bSopenharmony_ci#define RNDIS_DEVICEFLAGS 0x00000001 64beacf11bSopenharmony_ci#define RNDIS_MEDIUM_802_3 0x00000000 65beacf11bSopenharmony_ci 66beacf11bSopenharmony_ci/* Message types */ 67beacf11bSopenharmony_ci 68beacf11bSopenharmony_ci#define RNDIS_MSG_COMPLETE 0x80000000 69beacf11bSopenharmony_ci#define RNDIS_PACKET_MSG 0x00000001 70beacf11bSopenharmony_ci#define RNDIS_INITIALIZE_MSG 0x00000002 71beacf11bSopenharmony_ci#define RNDIS_HALT_MSG 0x00000003 72beacf11bSopenharmony_ci#define RNDIS_QUERY_MSG 0x00000004 73beacf11bSopenharmony_ci#define RNDIS_SET_MSG 0x00000005 74beacf11bSopenharmony_ci#define RNDIS_RESET_MSG 0x00000006 75beacf11bSopenharmony_ci#define RNDIS_INDICATE_MSG 0x00000007 76beacf11bSopenharmony_ci#define RNDIS_KEEPALIVE_MSG 0x00000008 77beacf11bSopenharmony_ci 78beacf11bSopenharmony_ci/* Status codes */ 79beacf11bSopenharmony_ci 80beacf11bSopenharmony_ci#define RNDIS_STATUS_SUCCESS 0x00000000 81beacf11bSopenharmony_ci#define RNDIS_STATUS_FAILURE 0xC0000001 82beacf11bSopenharmony_ci#define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BB 83beacf11bSopenharmony_ci 84beacf11bSopenharmony_ci/* ObjectIDs for query commands */ 85beacf11bSopenharmony_ci 86beacf11bSopenharmony_ci#define RNDIS_OID_GEN_SUPPORTED_LIST 0x00010101 87beacf11bSopenharmony_ci#define RNDIS_OID_GEN_HARDWARE_STATUS 0x00010102 88beacf11bSopenharmony_ci#define RNDIS_OID_GEN_MEDIA_SUPPORTED 0x00010103 89beacf11bSopenharmony_ci#define RNDIS_OID_GEN_MEDIA_IN_USE 0x00010104 90beacf11bSopenharmony_ci#define RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 91beacf11bSopenharmony_ci#define RNDIS_OID_GEN_LINK_SPEED 0x00010107 92beacf11bSopenharmony_ci#define RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A 93beacf11bSopenharmony_ci#define RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B 94beacf11bSopenharmony_ci#define RNDIS_OID_GEN_VENDOR_ID 0x0001010C 95beacf11bSopenharmony_ci#define RNDIS_OID_GEN_VENDOR_DESCRIPTION 0x0001010D 96beacf11bSopenharmony_ci#define RNDIS_OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 97beacf11bSopenharmony_ci#define RNDIS_OID_GEN_CURRENT_PACKET_FILTER 0x0001010E 98beacf11bSopenharmony_ci#define RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 99beacf11bSopenharmony_ci#define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 100beacf11bSopenharmony_ci#define RNDIS_OID_GEN_PHYSICAL_MEDIUM 0x00010202 101beacf11bSopenharmony_ci#define RNDIS_OID_GEN_XMIT_OK 0x00020101 102beacf11bSopenharmony_ci#define RNDIS_OID_GEN_RCV_OK 0x00020102 103beacf11bSopenharmony_ci#define RNDIS_OID_GEN_XMIT_ERROR 0x00020103 104beacf11bSopenharmony_ci#define RNDIS_OID_GEN_RCV_ERROR 0x00020104 105beacf11bSopenharmony_ci#define RNDIS_OID_GEN_RCV_NO_BUFFER 0x00020105 106beacf11bSopenharmony_ci#define RNDIS_OID_802_3_PERMANENT_ADDRESS 0x01010101 107beacf11bSopenharmony_ci#define RNDIS_OID_802_3_CURRENT_ADDRESS 0x01010102 108beacf11bSopenharmony_ci#define RNDIS_OID_802_3_MULTICAST_LIST 0x01010103 109beacf11bSopenharmony_ci#define RNDIS_OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 110beacf11bSopenharmony_ci#define RNDIS_OID_802_3_MAC_OPTIONS 0x01010105 111beacf11bSopenharmony_ci#define RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 112beacf11bSopenharmony_ci#define RNDIS_OID_802_3_XMIT_ONE_COLLISION 0x01020102 113beacf11bSopenharmony_ci#define RNDIS_OID_802_3_XMIT_MORE_COLLISION 0x01020103 114beacf11bSopenharmony_ci 115beacf11bSopenharmony_ci#define RNDIS_SEND_ENCAPSULATED_COMMAND 0x00 116beacf11bSopenharmony_ci#define RNDIS_GET_ENCAPSULATED_RESPONSE 0x01 117beacf11bSopenharmony_ci 118beacf11bSopenharmony_ci#define RNDIS_NOTIFICATION_RESPONSE_AVAILABLE 0x01 119beacf11bSopenharmony_ci 120beacf11bSopenharmony_ci/**************************************************************************** 121beacf11bSopenharmony_ci * Public types 122beacf11bSopenharmony_ci ****************************************************************************/ 123beacf11bSopenharmony_ci 124beacf11bSopenharmony_cistruct rndis_notification 125beacf11bSopenharmony_ci{ 126beacf11bSopenharmony_ci uint32_t notification; /* Notification */ 127beacf11bSopenharmony_ci uint32_t reserved; /* Reserved */ 128beacf11bSopenharmony_ci}; 129beacf11bSopenharmony_ci 130beacf11bSopenharmony_cistruct rndis_command_header 131beacf11bSopenharmony_ci{ 132beacf11bSopenharmony_ci uint32_t msgtype; /* MessageType */ 133beacf11bSopenharmony_ci uint32_t msglen; /* MessageLength */ 134beacf11bSopenharmony_ci uint32_t reqid; /* RequestID */ 135beacf11bSopenharmony_ci}; 136beacf11bSopenharmony_ci 137beacf11bSopenharmony_cistruct rndis_response_header 138beacf11bSopenharmony_ci{ 139beacf11bSopenharmony_ci uint32_t msgtype; /* MessageType */ 140beacf11bSopenharmony_ci uint32_t msglen; /* MessageLength */ 141beacf11bSopenharmony_ci uint32_t reqid; /* RequestID */ 142beacf11bSopenharmony_ci uint32_t status; /* Status */ 143beacf11bSopenharmony_ci}; 144beacf11bSopenharmony_ci 145beacf11bSopenharmony_cistruct rndis_initialize_msg 146beacf11bSopenharmony_ci{ 147beacf11bSopenharmony_ci struct rndis_command_header hdr; 148beacf11bSopenharmony_ci uint32_t major; /* MajorVersion */ 149beacf11bSopenharmony_ci uint32_t minor; /* MinorVersion */ 150beacf11bSopenharmony_ci uint32_t xfrsize; /* MaxTransferSize */ 151beacf11bSopenharmony_ci}; 152beacf11bSopenharmony_ci 153beacf11bSopenharmony_cistruct rndis_initialize_cmplt 154beacf11bSopenharmony_ci{ 155beacf11bSopenharmony_ci struct rndis_response_header hdr; 156beacf11bSopenharmony_ci uint32_t major; /* MajorVersion */ 157beacf11bSopenharmony_ci uint32_t minor; /* MinorVersion */ 158beacf11bSopenharmony_ci uint32_t devflags; /* DeviceFlags */ 159beacf11bSopenharmony_ci uint32_t medium; /* Medium */ 160beacf11bSopenharmony_ci uint32_t pktperxfer; /* MaxPacketsPerTransfer */ 161beacf11bSopenharmony_ci uint32_t xfrsize; /* MaxTransferSize */ 162beacf11bSopenharmony_ci uint32_t pktalign; /* PacketAlignmentFactor */ 163beacf11bSopenharmony_ci uint32_t reserved1; /* Reserved1 */ 164beacf11bSopenharmony_ci uint32_t reserved2; /* Reserved2 */ 165beacf11bSopenharmony_ci}; 166beacf11bSopenharmony_ci 167beacf11bSopenharmony_cistruct rndis_query_msg 168beacf11bSopenharmony_ci{ 169beacf11bSopenharmony_ci struct rndis_command_header hdr; 170beacf11bSopenharmony_ci uint32_t objid; /* ObjectID */ 171beacf11bSopenharmony_ci uint32_t buflen; /* InformationBufferLength */ 172beacf11bSopenharmony_ci uint32_t bufoffset; /* InformationBufferOffset */ 173beacf11bSopenharmony_ci uint32_t reserved; /* Reserved */ 174beacf11bSopenharmony_ci uint32_t buffer[]; /* Buffer */ 175beacf11bSopenharmony_ci}; 176beacf11bSopenharmony_ci 177beacf11bSopenharmony_cistruct rndis_query_cmplt 178beacf11bSopenharmony_ci{ 179beacf11bSopenharmony_ci struct rndis_response_header hdr; 180beacf11bSopenharmony_ci uint32_t buflen; /* InformationBufferLength */ 181beacf11bSopenharmony_ci uint32_t bufoffset; /* InformationBufferOffset */ 182beacf11bSopenharmony_ci uint32_t buffer[]; /* Buffer */ 183beacf11bSopenharmony_ci}; 184beacf11bSopenharmony_ci 185beacf11bSopenharmony_cistruct rndis_set_msg 186beacf11bSopenharmony_ci{ 187beacf11bSopenharmony_ci struct rndis_command_header hdr; 188beacf11bSopenharmony_ci uint32_t objid; /* ObjectID */ 189beacf11bSopenharmony_ci uint32_t buflen; /* InformationBufferLength */ 190beacf11bSopenharmony_ci uint32_t bufoffset; /* InformationBufferOffset */ 191beacf11bSopenharmony_ci uint32_t reserved; /* Reserved */ 192beacf11bSopenharmony_ci uint32_t buffer[]; /* Buffer */ 193beacf11bSopenharmony_ci}; 194beacf11bSopenharmony_ci 195beacf11bSopenharmony_cistruct rndis_reset_cmplt 196beacf11bSopenharmony_ci{ 197beacf11bSopenharmony_ci struct rndis_response_header hdr; 198beacf11bSopenharmony_ci uint32_t addreset; /* AddressingReset */ 199beacf11bSopenharmony_ci}; 200beacf11bSopenharmony_ci 201beacf11bSopenharmony_cistruct rndis_indicate_msg 202beacf11bSopenharmony_ci{ 203beacf11bSopenharmony_ci uint32_t msgtype; /* MessageType */ 204beacf11bSopenharmony_ci uint32_t msglen; /* MessageLength */ 205beacf11bSopenharmony_ci uint32_t status; /* Status */ 206beacf11bSopenharmony_ci uint32_t buflen; /* StatusBufferLength */ 207beacf11bSopenharmony_ci uint32_t bufoffset; /* StatusBufferOffset */ 208beacf11bSopenharmony_ci uint32_t buffer[]; /* Buffer */ 209beacf11bSopenharmony_ci}; 210beacf11bSopenharmony_ci 211beacf11bSopenharmony_cistruct rndis_packet_msg 212beacf11bSopenharmony_ci{ 213beacf11bSopenharmony_ci uint32_t msgtype; /* MessageType */ 214beacf11bSopenharmony_ci uint32_t msglen; /* MessageLength */ 215beacf11bSopenharmony_ci uint32_t dataoffset; /* DataOffset */ 216beacf11bSopenharmony_ci uint32_t datalen; /* DataLength */ 217beacf11bSopenharmony_ci uint32_t ooboffset; /* OutOfBandDataOffset */ 218beacf11bSopenharmony_ci uint32_t ooblen; /* OutOfBandDataLength */ 219beacf11bSopenharmony_ci uint32_t noobelem; /* NumOutOfBandDataElements */ 220beacf11bSopenharmony_ci uint32_t infooffset; /* PerPacketInfoOffset */ 221beacf11bSopenharmony_ci uint32_t infolen; /* PerPacketInfoLength */ 222beacf11bSopenharmony_ci uint32_t handle; 223beacf11bSopenharmony_ci uint32_t reserved; 224beacf11bSopenharmony_ci}; 225beacf11bSopenharmony_ci 226beacf11bSopenharmony_ci#endif 227