微软RNDIS协议
微软RNDIS协议
Remote NDIS SpecificationRev 1.1August 9, 2002© 1998-2001 Microsoft Corporation. All rights reserved.1INTRODUCTION (4)1.1L ICENSE A GREEMENT (5)2CONCEPTS AND DEFINITIONS (6)2.1C ONTROL CHANNEL (6)2.2D ATA CHANNEL (6)2.3I NITIALIZATION AND T EARDOWN (6)2.4D EVICE S TATE D EFINITIONS (6)2.4.1Halt (7)2.4.2Reset (7)2.5F LOW C ONTROL (7)2.6B YTE O RDERING (7)2.7E NCAPSULATION (7)2.8R EMOTE NDIS V ERSION (7)2.9S TATUS V ALUES (8)3MESSAGE SET FOR CONNECTIONLESS (802.3) DEVICES (9)3.1REMOTE_NDIS_INITIALIZE_MSG (9)3.1.1REMOTE_NDIS_INITIALIZE_MSG Format (10)3.1.2Response to REMOTE_NDIS_INITIALIZE_MSG (10)3.2REMOTE_NDIS_HALT_MSG (12)3.3REMOTE_NDIS_QUERY_MSG (13)3.3.1REMOTE_NDIS_QUERY_MSG Format (13)3.3.2Response to REMOTE_NDIS_QUERY_MSG (14)3.4REMOTE_NDIS_SET_MSG (14)3.4.1REMOTE_NDIS_SET_MSG Format (15)3.4.2Response to REMOTE_NDIS_SET_MSG (15)3.4.3Setting Device-specific Parameters (16)3.5REMOTE_NDIS_RESET_MSG (17)3.5.1REMOTE_NDIS_RESET_MSG Format (17)3.5.2Response to REMOTE_NDIS_RESET_MSG (17)3.6REMOTE_NDIS_INDICATE_STATUS_MSG (18)3.6.1REMOTE_NDIS_INDICATE_STATUS_MSG Format (19)3.7REMOTE_NDIS_KEEPALIVE_MSG (19)3.7.1REMOTE_NDIS_KEEPALIVE_MSG Format (20)3.7.2Response to REMOTE_NDIS_KEEPALIVE_MSG (20)3.8E XAMPLE C ONNECTIONLESS (802.3)I NITIALIZATION S EQUENCE (21)3.9D ATA M ESSAGES (REMOTE_NDIS_PACKET_MSG) (22)3.9.1REMOTE_NDIS_PACKET_MSG Format (22)3.9.2Multi-Packet Transfers (24)4REQUIRED NDIS OIDS (27)4.1G ENERAL OID S (27)4.2802.3OID S (29)4.3O PTIONAL P OWER M ANAGEMENT OID S (30)4.3.1Network Wake-Up (31)5REMOTE NDIS TO USB MAPPING (32)5.1R ELATED S PECIFICATIONS (32)5.2O VERVIEW (32)5.3P N P AND USB-LEVEL INITIALIZATION (32)5.3.1USB Device Descriptor (32)5.3.2USB Configuration Descriptor (33)5.3.3Communication Class Interface (33)5.3.4Data Class Interface (33)5.4USB-LEVEL TERMINATION (34)5.5C ONTROL CHANNEL CHARACTERISTICS (34)5.6D ATA CHANNEL CHARACTERISTICS (35)5.6.1USB Short Packets (35)5.6.2Flow Control (36)5.7P OWER MANAGEMENT (36)5.8T IMER CONSTANTS (36)1IntroductionRemote NDIS is a bus-independent class specification for Ethernet (802.3) network devices on dynamic PnP busses such as USB, 1394, BlueTooth, and InfiniBand. This specification defines a bus-independent message protocol between a host PC and a Remote NDIS device over abstract control and data channels. Also included are bus-mapping chapters which define specific features of the specification on the respective busses.The “legacy-free” PC revolution is eliminating not only legacy connection ports (e.g. serial, parallel, PS/2) but also legacy expansion buses like ISA and PCI in mainstream PCs. The resulting “sealed case” PCs will require either built-in networking support on the motherboard or support for network adapters on external busses. This specification defines a message protocol for external bus attached network devices. It is precise enough to allow vendor-independent class driver support for Remote NDIS devices on the host PC. Remote NDIS is a fairly simple extension of the well-understood and time-tested NDIS architecture. NDIS defines a function-call interface for device-specific NDIS miniport drivers. This interface defines primitives to send and receive network data, and to query and set configuration parameters and statistics. Remote NDIS leverages NDIS by defining a message wrapping for the NDIS miniport interface, thus moving the NDIS-handling code from a miniport driver into the device itself. In this and other ways, the Remote NDIS specification allows for a wide range of device functionality and performance levels.1.1License AgreementThe Remote NDIS Specification and any accompanying materials (the “Specification”) provided by Microsoft is for your personal use only, and may be used solely for the purpose of implementing the Remote NDIS protocol message set to interface with (i) a Microsoft Windows operating system or (ii) a bus or network-connected communications device, such as a USB, 1394 or TCP/IP device. THE SPECIFICATION MAY NOT BE COPIED OR DISTRIBUTED.Microsoft may have copyrights, patents or pending patent applications covering subject matter in the Specification. To the extent Microsoft has such copyrights, patents or applications, Microsoft agrees to grant a nonexclusive, royalty-free, world-wide license under these copyrights, patents or applications solely to implement the Remote NDIS Specification to interface with (i) a Microsoft Windows operating system or (ii) a bus or network-connected communications device, such as a USB, 1394 or TCP/IP device, on condition that you agree not to assert any intellectual property rights against Microsoft or other companies for their implementation of the Specification. Microsoft reserves all other rights it may have in the Specification. The furnishing of this document does not give you any license to any other Microsoft patents, trademarks, copyrights, or other intellectual property rights. Specifically, neither this document nor the Specification give you any license to the NDIS Specification or to USB Communication Device Class technology.The Specification is provided "AS IS" without warranty of any kind. To the maximum extent permitted by applicable law, Microsoft further disclaims all warranties, including without limitation any implied warranties of merchantability and fitness for a particular purpose, as well as warranties of title and noninfringement. The entire risk arising out of the use or performance of the Specification remains with you.To the maximum extent permitted by applicable law, in no event shall Microsoft or its suppliers be liable for any consequential, incidental, direct, indirect, special, punitive, or other damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the Specification, even if Microsoft has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.2Concepts and DefinitionsThis section discusses requirements and characteristics of the channels used to communicate between the host and the remote device. Device state transitions and major operations such as initialization, halt and reset are also defined here.2.1Control channelThe specifics of the control channel are given in the appropriate bus-mapping chapter. The control channel must be reliable and ensure sequenced delivery. It is used for all communication except for the transmission of network data packets. All required control messages except REMOTE_NDIS_HALT and REMOTE_NDIS_INDICATE_STATUS_MSG are request/response exchanges initiated by the host. The device must respond within the ControlTimeoutPeriod as specified in the appropriate bus-mapping chapter.2.2Data channelThe specifics of the data channel are given in the appropriate bus-mapping chapter. The data channel is used exclusively for the transmission of network data packets. It may consist of multiple sub-channels (e.g. for varying quality of service) as defined in the appropriate bus-mapping chapter. The reliability and delivery specifics of the data channel are likewise defined in the respective bus-mapping chapter.2.3Initialization and TeardownThe control and data channels are initialized as specified in the respective bus-mapping chapter. The host and Remote NDIS device then exchange initialization messages. The host sendsREMOTE_NDIS_INITIALIZE_MSG to the device, and the device provides information about its type, supported medium and version in the response message REMOTE_NDIS_INITIALIZE_CMPLT.Either the host or the remote device can halt the network connection in an abortive fashion via the REMOTE_NDIS_HALT_MSG message. All outstanding requests and packets should be discarded on receipt of this message.2.4Device State DefinitionsFollowing bus-level initialization, the device is in the rndis-uninitialized state. Upon receiving REMOTE_NDIS_INITIALIZE_MSG and returning REMOTE_NDIS_INITIALIZE_CMPLT with status success, the device enters the rndis-initialized state.Upon receiving REMOTE_NDIS_SET_MSG for the OID_GEN_CURRENT_PACKET_FILTER parameter with a non-zero filter, the device enters the rndis-data-initialized state. When in the rndis-data-initialized state, receiving REMOTE_NDIS_SET_MSG for OID_GEN_CURRENT_PACKET_FILTER with a zero filter value forces the device back into the rndis-initialized state.Receiving REMOTE_NDIS_HALT_MSG or a bus-level disconnect or hard-reset at any time forces the device into the rndis-uninitialized state.2.4.1HaltAt any time that the device is in the rndis-initialized or rndis-data-initialized state, the host computer may terminate the Remote NDIS functionality of the device in an abortive fashion by sendingREMOTE_NDIS_HALT_MSG to the device.2.4.2ResetThe communication channel is “soft-reset” when an error such as message tim eout occurs. The host may initiate a soft-reset at any time when the device is in the rndis_initialized state by sendingREMOTE_NDIS_RESET_MSG to the device (see details below); and the device must send a response message when it has completed the reset. For example, the host may initiate a soft-reset when an error, such as a message timeout has occurred.Note that this is a soft reset in the sense that any handles (e.g. VCs for connection-oriented devices) continue to be valid after the reset. The Remote NDIS device, as part of the reset process, discards all outstanding requests and packets. The remote device may reset some of its hardware components, but keeps all communication channels to the host intact.2.4.2.1Hard ResetIf the Remote NDIS device performs a hard reset (i.e. reboot), this event is assumed to be equivalent of “Remove” followed by “Add” plug-and-play events. The host NDIS mini-port will be halted and removed, and a new instance will be added and started. All bus-level and Remote NDIS initialization will be re-executed. A Remote NDIS device may hard-reset itself in the event of a critical device failure.2.5Flow ControlThe Remote NDIS device may need to exercise flow control to prevent the host from overflowing its data buffers with packets. Any flow control provisions or requirements are given in the respective bus-mapping chapter.2.6Byte OrderingAll numeric values in message fields defined by this specification are assumed to be coded in little-endian format, i.e. least significant byte first.2.7EncapsulationThis section does not specify the way NDIS messages are encapsulated in native bus messages or primitives. Please refer to the appropriate bus-mapping chapter for more details.2.8Remote NDIS VersionTable 2-1 defines the Remote NDIS protocol version identifiers exchanged between host and device.Note that these are unrelated to the revision number of this specification.Table 2-1: Remote NDIS Protocol Version2.9Status ValuesThe Remote NDIS status values are generally equivalent to the 32-bit status values defined in the Windows 2000 DDK. Specifically, high bit set indicates an error state and the high bit clear indicates a success state. The specific Remote NDIS status values used in this specification are listed below, others can be inferred from the Windows 2000 DDK or MSDN. A device may return any semantically correct Remote NDIS status value in a Status field of a message that it generates.Table 2-2: Remote NDIS Status Values3Message Set for Connectionless (802.3) Devices The following Remote NDIS control messages that must be supported by an 802.3 connectionless device, seeTable 3-1 for an overview. In the more detailed descriptions below, some messages include a RequestId field. This is used to match sent messages with responses. With this mechanism, a host driver can send multiple Remote NDIS messages to a device without concern for the ordering of responses. A Remote NDIS device must maintain the RequestId field when returning a response.Table 3-1: Control Messages Set3.1REMOTE_NDIS_INITIALIZE_MSGThis message is sent by the host to a Remote NDIS device to initialize the network connection. It is sent via the control channel and only when the device is in the rndis-uninitialized state. SeeTable 3-2 for details of the message.The MaxTransferSize indicates the maximum size, in bytes, of any single bus data transfer that the host expects to receive from the device. Typically, each bus data transfer accommodates a single Remote NDIS message. However, as described below (seeMulti-Packet Transfers), the device may bundle several Remote NDIS messages containing Data packets into a single transfer.MajorVersion and MinorVersion indicate the highest Remote NDIS protocol version implemented by the host. There is no guarantee that the host supports any lower versions; specifics of Remote NDIS version(s) supported by various Windows operating system versions will be documented in appropriate product documentation, e.g. the DDK. SeeTable 2-1 for more details.3.1.1REMOTE_NDIS_INITIALIZE_MSG FormatTable 3-2: REMOTE_NDIS_INITIALIZE_MSG3.1.2Response to REMOTE_NDIS_INITIALIZE_MSGThe device should report its medium type, Remote NDIS version numbers, and its type (connection-less or connection-oriented) in its response to REMOTE_NDIS_INITIALIZE_MSG.The Status field should be set to RNDIS_STATUS_SUCCESS if the device initialized successfully; otherwise it is set to an error code indicating the failure.The device should return the highest Remote NDIS protocol version that it can support, in MajorVersion and MinorVersion– the combined version number should be less than or equal to the version number specified by the host in the REMOTE_NDIS_INITIALIZE_MSG message. This allows for the device to fall back to a compatibility mode when the host implements a Remote NDIS protocol version that is lower than that supported by the device.The DeviceFlags field specifies the device type. MaxPacketsPerTransfer is the maximum number of REMOTE_NDIS_PACKET_MSGs that the device can handle in a single transfer to it - this should be at least 1. MaxTransferSize is the maximum size, in bytes, of a single data transfer that the device expects to receive from the host. The device can specify the byte alignment it expects for each Remote NDIS message that is part of a multi-message transfer to it –PacketAlignmentFactor contains this value as an exponent of 2. For example, this is set to 3 to indicate 8-byte alignment.NOTE: The AFListSize and AFListOffset fields are only relevant for connection-oriented devices that include a call manager. Connectionless devices should set these fields to 0.Table 3-3: REMOTE_NDIS_INITIALIZE_CMPLT3.2REMOTE_NDIS_HALT_MSGThis message is sent by the host in order to terminate the network connection. Unlike the other host initiated control messages, there is no device response to REMOTE_NDIS_HALT_MSG. The message may be sent at any time that the device is in the rndis-initialized or rndis-data-initialized state.Table 3-4: REMOTE_NDIS_HALT_MSG MessageIt is optional for the device to implement sending the REMOTE_NDIS_HALT_MSG. If implemented, the device sends this message to the host via the control channel only when the device is in the rndis-initialized or rndis-data-initialized state. The device must terminate all communication immediately after sending this message. Sending this message causes the device to enter the rndis-uninitialized state.3.3REMOTE_NDIS_QUERY_MSGREMOTE_NDIS_QUERY_MSG is sent to a Remote NDIS device from a host when it needs to query the device for its characteristics or statistics information or status. The parameter or statistics being queried for is identified by means of an Object Identifier (OID). The host may send REMOTE_NDIS_QUERY_MSG to the device via the control channel at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to REMOTE_NDIS_QUERY_MSG with information about the desired capabilities or status.3.3.1REMOTE_NDIS_QUERY_MSG FormatTable 3-5: REMOTE_NDIS_QUERY_MSG Message3.3.2Response to REMOTE_NDIS_QUERY_MSGThe device sends REMOTE_NDIS_QUERY_CMPLT to the host in response toREMOTE_NDIS_QUERY_MSG. This message is used to relay the result of a query for a device parameter or statistics counter to the host.Table 3-6: REMOTE_NDIS_QUERY_CMPLT3.4REMOTE_NDIS_SET_MSGREMOTE_NDIS_SET_MSG is sent to a Remote NDIS device from a host, when it needs to set the value of some operational parameter on the device. The specific parameter being set is identified by means of an Object Identifier (OID), and the value it is to be set to is contained in an information buffer sent along with the message. (For a complete list of required and optional OIDs, please refer to Section 1.) The host may send REMOTE_NDIS_SET_MSG to the device via the control channel at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to aREMOTE_NDIS_SET_MSG message with a status.3.4.1REMOTE_NDIS_SET_MSG FormatTable 3-7: REMOTE_NDIS_SET_MSG Message3.4.2Response to REMOTE_NDIS_SET_MSGThe device sends the REMOTE_NDIS_SET_CMPLT message to the host in response toREMOTE_NDIS_SET_MSG. This message is used to relay the result of setting the value of a device operational parameter to the host.Table 3-8: REMOTE_NDIS_SET_CMPLT3.4.3Setting Device-specific ParametersIt is expected that most Remote NDIS devices will function well without the need to configure parameters on the host. However, there may be cases where proper network operation requires some configuration on the host. If the device supports configurable parameters, then it should include the following optional OID in the list of supported OIDs it reports in response to a query for OID_GEN_SUPPORTED_LIST:OID_GEN_RNDIS_CONFIG_PARAMETER (0x0001021B)If the device supports this OID, the host uses it to set device-specific parameters, soon after the device enters the rndis_initialized state from rndis_uninitialized. The host will send zero or moreREMOTE_NDIS_SET_MSGs to the device, with OID_GEN_RNDIS_CONFIG_PARAMETER as the OID value to set. Each such REMOTE_NDIS_SET_MSG corresponds to one device-specific parameter that is configured on the host.The InformationBuffer associated with each such REMOTE_NDIS_SET_MSG has the following format. Note that the Offset values are relative to the beginning of the information buffer.Table 3-9: InformationBuffer for OID_GEN_RNDIS_CONFIG_PARAMETERThe device sends a REMOTE_NDIS_SET_CMPLT in response to each REMOTE_NDIS_SET_MSG, after applying the parameter value. If the parameter setting is acceptable, it returns a status ofRNDIS_STATUS_SUCCESS in the response. If the parameter setting is not acceptable, and the device cannot apply a useful default value for this parameter, then the device returns an appropriate error status value (seeTable 2-2). If an error status is returned, then the host will initiate a Halt process (see Section 3) for the device.Device-specific parameters are expected to be configured in the Windows registry. The keys that define parameter values are typically created in the registry during the process of device installation; the list of keys, type information, default values and optional range of valid values are specified in the INF file for the device. For more information on using an INF to set up configuration parameters in the registry for network devices, please consult the Windows 2000 DDK.3.5REMOTE_NDIS_RESET_MSGA REMOTE_NDIS_RESET_MSG message is sent to a Remote NDIS device from a host via the control channel to soft-reset the device and return status. This message may be sent at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to aREMOTE_NDIS_RESET_MSG message with a status.3.5.1REMOTE_NDIS_RESET_MSG FormatTable 3-10: REMOTE_NDIS_RESET_MSG Message3.5.2Response to REMOTE_NDIS_RESET_MSGWhen the device receives REMOTE_NDIS_RESET_MSG, it performs a soft-reset and then sends REMOTE_NDIS_RESET_CMPLT to the host with the result status.Table 3-11: REMOTE_NDIS_RESET_CMPLT3.6REMOTE_NDIS_INDICATE_STATUS_MSGThe device may send REMOTE_NDIS_INDICATE_STATUS_MSG to the host via the control channel in an unsolicited fashion at any time that the device is in the rndis-initialized or rndis-data-initialized state. This message is used to indicate a change in the status of the device.REMOTE_NDIS_INDICATE_STATUS_MSG can also be used to indicate an error event, such as an unrecognized message.The most common use of REMOTE_NDIS_INDICATE_STATUS_MSG is to indicate the state of link for an 802.3 device. Status=RNDIS_STATUS_MEDIA_CONNECT indicates a transition from disconnected (e.g. no 802.3 link pulse) to connected state (802.3 link pulse detected); Status=RNDIS_STATUS_MEDIA_DISCONNECT indicates a transition from connected to disconnected state . The device must send REMOTE_NDIS_INDICATE_STATUS_MSG with one of these values every time that the 802.3 link state changes. No status buffer is required to return these two common indications.In the specific case where this is sent in response to a message that the device could not handle, the Status field must be set to RNDIS_STATUS_INVALID_DATA, and the status buffer is formatted as described in Table 3-12.If the error condition was caused by an Remote NDIS message, for example if the device didn’t understand a particular Remote NDIS message, then the device must append the original message at the end of the status message defined above. In this case, DiagStatus contains additional status about the error itself (e.g.RNDIS_STATUS_NOT_SUPPORTED) and ErrorOffset is the 0-based byte offset within the offending message at which the error was detected.Note that this message is used to report an error condition only in circumstances where the device is not able to generate a response message with appropriate status. Examples of appropriate usage are: (a) on receiving a message with unsupported message type (b) on receiving an REMOTE_NDIS_PACKET_MSG with unacceptable contents.3.6.1REMOTE_NDIS_INDICATE_STATUS_MSG FormatTable 3-12: REMOTE_NDIS_INDICATE_STATUS_MSG MessageTable 3-13: Rndis_Diagnostic_Info3.7REMOTE_NDIS_KEEPALIVE_MSGThe host sends REMOTE_NDIS_KEEPALIVE_MSG to the device via the control channel in order to check the health of the device. When the device is in the rndis-data-initialized state, the host sends this message periodically when there has been no other control or data traffic from the device to the host for the KeepAliveTimeoutPeriod. KeepAliveTimeoutPeriod is bus-dependent and is defined in the appropriate bus-mapping chapter.Upon receiving this message, the remote device must send back a response whose Status field indicates whether the device solicits a REMOTE_NDIS_RESET_MSG message from the host.The host will not send REMOTE_NDIS_KEEPALIVE_MSG until the KeepAliveTimeoutPeriod has elapsed since the last message received from the remote device. This avoids unnecessary exchange of REMOTE_NDIS_KEEPALIVE_MSG messages when the communication channel is active.The device may optionally send this message to the host as well. For example, the device may use this message to trigger a response from the host for the purpose of computing round-trip delay time. If implemented, the device must send REMOTE_NDIS_KEEPALIVE_MSG via the control channel and only when in the rndis-initialized or rndis-data-initialized state.NOTE: The device does not need to perform any specific action if it stops seeingREMOTE_NDIS_KEEPALIVE_MSG messages from the host.3.7.1REMOTE_NDIS_KEEPALIVE_MSG FormatTable 3-14: REMOTE_NDIS_KEEPALIVE_MSG Message3.7.2Response to REMOTE_NDIS_KEEPALIVE_MSGThe device sends REMOTE_NDIS_KEEPALIVE_CMPLT to the host in response to aREMOTE_NDIS_KEEPALIVE_MSG. If the returned Status is not RNDIS_STATUS_SUCCESS, then the host will send REMOTE_NDIS_RESET_MSG to reset the device.Table 3-15: REMOTE_NDIS_KEEPALIVE_CMPLTIf the device implements the option of sending REMOTE_NDIS_KEEPALIVE_MSG, then the host will respond with REMOTE_NDIS_KEEPALIVE_CMPLT via the control channel.3.8Example Connectionless (802.3) Initialization Sequence This section describes the general order of events that a device can expect upon startup as a Remote NDIS connectionless device. Because the basic operation of Remote NDIS is the same, regardless of the underlying bus, the require bus enumeration and start up process has been left out of the example.Table 3-16: Generic Connectionless Remote NDIS Initialization SequenceNote: real world operation will vary depending on version of Windows and NDIS.3.9Data Messages (REMOTE_NDIS_PACKET_MSG)A Remote NDIS device transfers NDIS packets, encapsulated as REMOTE_NDIS_PACKET_MSG across the data channel. REMOTE_NDIS_PACKET_MSG may contain out of band (OOB) data and/or per-packet information.3.9.1REMOTE_NDIS_PACKET_MSG FormatTable 3-17: REMOTE_NDIS_PACKET_MSG3.9.1.1Out-of-band dataEach REMOTE_NDIS_PACKET_MSG may contain one or more out-of-band data records. NumOOBDataElements indicates the number of out-of-band data records in this message. The out-of-band data records must appear in sequence. The OOBDataLength field indicates the byte length of the entire out-of-band data block. The OOBDataOffset field indicates the byte offset from the beginning of the DataOffset field to the beginning of the out-of-band data block. See the NDIS specification for more information about out-of-band packet data.Table 3-18defines the format of a single out-of-band data record.Table 3-18: Out of Band Data Record FormatNote: (N) is equal to the value of ClassInformationOffsetIf there are multiple out-of-band data blocks attached to a REMOTE_NDIS_PACKET_MSG, then each subsequent out-of-band data record must immediately follow the previous out-of-band record’s data. There is no out of band information currently defined for 802.3 devices.3.9.1.2Per-packet-info DataEach REMOTE_NDIS_PACKET_MSG may contain one or more per-packet-info data records. Per-packet-info is used to convey packet meta-data such as TCP checksum. See the NDIS specification for more information about per-packet info data.Table 3-19 defines the format of a per-packet-info data record.Table 3-19: Per-Packet Info Data Record FormatNOTE: (N) is equal to the value of PerPacketInformationOffsetIf there are multiple per-packet-info data blocks, then each subsequent per-packet-info data record must immediately follow the previous per-packet-info record’s data.3.9.2Multi-Packet TransfersMultiple REMOTE_NDIS_PACKET_MSG messages may be sent in a single transfer, in either direction. The maximum length of such a transfer is governed by the MaxTransferSize parameter passed in the REMOTE_NDIS_INITIALIZE_MSG and response messages. The host will also limit the number of REMOTE_NDIS_PACKET_MSGs it bundles into a single transfer to the value of the MaxPacketsPerTransfer parameter returned by the device in its response toREMOTE_NDIS_INITIALIZE_MSG.Concatenating multiple REMOTE_NDIS_PACKET_MSG elements forms a multi-packet message. Each individual REMOTE_NDIS_PACKET_MSG component is constructed as described above. The difference from the single-packet message case is that the MessageLength field in eachREMOTE_NDIS_PACKET_MSG header includes some additional padding bytes. These padding bytes are appended to all but the last REMOTE_NDIS_PACKET_MSG such that the succeedingREMOTE_NDIS_PACKET_MSG starts at an appropriate byte boundary. For messages sent from the device to the host, this padding should result in each REMOTE_NDIS_PACKET_MSG starting at a byte offset that is a multiple of 8 bytes starting from the beginning of the multi-packet message. When the host sends a multi-packet message to the device, it will adhere to the PacketAlignmentFactor specified by the device.Note that neither the combined length of a multi-packet message nor the number ofREMOTE_NDIS_PACKET_MSG elements in a combined message is given explicitly in any Remote NDIS –defined field. The combined length is implicit in the bus-specific transfer mechanism, and the host or device must walk the MessageLength fields of the combined message to determine the number of combined messages.Table 3-20 contains an example of a multi-packet message that is made up of twoREMOTE_NDIS_PACKET_MSGs, sent from the host to the device. During the。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议一、引言微软RNDIS(Remote Network Driver Interface Specification)协议是一种用于在计算机和设备之间进行网络通信的协议。
本协议旨在定义计算机操作系统和设备之间的通信接口,以便设备可以通过计算机网络进行远程管理和控制。
二、范围本协议适用于所有使用微软RNDIS协议进行通信的设备和计算机操作系统。
三、术语定义1. RNDIS设备:指支持微软RNDIS协议的设备。
2. 客户端:指连接到RNDIS设备的计算机或其他设备。
3. 主机:指运行计算机操作系统的设备。
四、协议规范1. RNDIS设备必须实现以下功能:a. 支持RNDIS设备与主机之间的数据传输。
b. 支持RNDIS设备与主机之间的命令和控制传输。
c. 支持RNDIS设备与主机之间的网络配置和管理。
2. RNDIS设备与主机之间的数据传输必须遵循以下规范:a. 数据传输必须使用TCP/IP协议。
b. 数据传输必须采用可靠的传输机制,确保数据的完整性和可靠性。
c. 数据传输的带宽和延迟必须满足应用需求。
3. RNDIS设备与主机之间的命令和控制传输必须遵循以下规范:a. 命令和控制传输必须使用USB协议。
b. 命令和控制传输必须支持设备的初始化、配置和状态查询等功能。
c. 命令和控制传输的可靠性和安全性必须得到保证。
4. RNDIS设备与主机之间的网络配置和管理必须遵循以下规范:a. 网络配置和管理必须支持动态IP地址分配和DHCP协议。
b. 网络配置和管理必须支持DNS解析和路由设置。
c. 网络配置和管理必须支持安全认证和加密传输。
五、协议实现1. RNDIS设备的实现必须符合微软RNDIS协议的规范和要求。
2. 主机的操作系统必须支持微软RNDIS协议,并提供相应的驱动程序和API 接口。
3. RNDIS设备和主机之间的通信必须通过USB接口进行。
六、安全性1. RNDIS设备和主机之间的通信必须采用安全的传输机制,确保数据的机密性和完整性。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议一、引言微软RNDIS(Remote Network Driver Interface Specification)协议是一种用于在计算机和外部设备之间进行网络通信的协议。
本协议旨在定义计算机和外部设备之间的通信规范,以实现数据传输和网络连接的稳定性和可靠性。
二、协议目的本协议的目的是确保微软RNDIS协议的正确实施和使用。
通过规范协议的格式和内容,可以提供一个标准的通信框架,使计算机和外部设备能够高效地进行数据传输和网络连接。
三、协议范围本协议适用于所有实施和使用微软RNDIS协议的计算机和外部设备。
无论是硬件还是软件,只要涉及到使用微软RNDIS协议进行网络通信的设备,都应遵守本协议。
四、协议内容1. 协议格式微软RNDIS协议的数据传输格式应符合以下规范:- 协议头部:包含协议版本号、数据包长度等信息。
- 数据包:包含实际的网络数据。
- 协议尾部:包含校验和、错误检测等信息。
2. 数据传输计算机和外部设备之间的数据传输应遵循以下规则:- 数据传输应使用可靠的传输协议,如TCP/IP。
- 数据传输过程中应进行错误检测和纠正,以确保数据的完整性和准确性。
- 数据传输速率应根据设备的性能和网络环境进行合理调整,以提高传输效率。
3. 网络连接计算机和外部设备之间的网络连接应遵循以下规定:- 网络连接的建立和关闭应采用标准的网络协议,如TCP/IP协议。
- 网络连接的稳定性和可靠性应得到保证,以确保数据传输的连续性和正常性。
- 网络连接的安全性应得到保护,以防止未经授权的访问和数据泄露。
五、协议实施1. 设备实施外部设备实施微软RNDIS协议时应满足以下要求:- 设备应符合微软RNDIS协议的格式和内容规范。
- 设备应具备与计算机进行网络通信所需的硬件和软件功能。
- 设备应通过相关认证和测试,以确保其与计算机的兼容性和稳定性。
2. 软件实施计算机实施微软RNDIS协议时应满足以下要求:- 操作系统应支持微软RNDIS协议的驱动程序安装和使用。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议一、引言微软RNDIS(Remote Network Driver Interface Specification)协议是一种用于在主机计算机与远程设备之间进行网络通信的协议。
该协议旨在提供一种标准化的接口,使主机计算机能够通过USB、以太网或其他物理介质与远程设备进行通信。
本协议的目的是确保通信的稳定性、可靠性和安全性。
二、协议范围本协议适用于所有使用微软RNDIS协议进行网络通信的主机计算机和远程设备。
三、术语定义1. RNDIS:Remote Network Driver Interface Specification,即远程网络驱动程序接口规范,是一种用于主机计算机与远程设备之间进行网络通信的接口规范。
2. 主机计算机:指运行操作系统的计算机,用于控制和管理远程设备。
3. 远程设备:指通过USB、以太网或其他物理介质与主机计算机进行通信的设备。
四、协议规定1. 连接建立主机计算机与远程设备之间的连接建立过程应符合以下规定:- 主机计算机通过识别远程设备的RNDIS功能来确认设备是否支持RNDIS协议。
- 主机计算机向远程设备发送连接请求,请求建立网络连接。
- 远程设备收到连接请求后,根据协议规定进行回应,确认连接建立。
2. 数据传输主机计算机与远程设备之间的数据传输过程应符合以下规定:- 数据传输应使用RNDIS协议规定的数据包格式。
- 数据包应包含必要的控制信息,以确保传输的完整性和准确性。
- 数据传输过程中,主机计算机应监测数据传输状态,及时处理传输错误或异常情况。
- 远程设备应接收并处理主机计算机发送的数据包,确保数据的正确接收和处理。
3. 错误处理在数据传输过程中,如出现错误或异常情况,应按照以下规定进行错误处理:- 主机计算机应根据错误类型和严重程度采取相应的措施,如重新发送数据、请求重传或中断连接。
- 远程设备应根据错误类型和严重程度采取相应的措施,如发送错误响应、请求重传或中断连接。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议1. 引言微软RNDIS(Remote Network Driver Interface Specification)协议是一种用于在计算机和远程设备之间进行网络通信的标准化协议。
该协议旨在提供一种简单而有效的方式,使远程设备能够通过USB接口与计算机进行通信,并实现网络连接。
2. 目的本协议的目的是定义微软RNDIS协议的规范和要求,以确保各个厂商在实现该协议时能够达到一致性和互操作性。
3. 术语和定义在本协议中,以下术语和定义适用:3.1 RNDIS设备:指符合微软RNDIS协议规范的远程设备。
3.2 主机:指连接RNDIS设备的计算机或其他主控设备。
3.3 RNDIS驱动程序:指在计算机上运行的软件,用于管理和控制RNDIS设备的数据传输和网络连接。
4. 协议规范4.1 RNDIS设备的基本要求4.1.1 RNDIS设备必须支持USB接口,并符合USB规范。
4.1.2 RNDIS设备必须能够通过USB接口与计算机进行通信,并能够被主机操作系统正确识别。
4.1.3 RNDIS设备必须支持RNDIS协议,并能够与主机进行RNDIS消息的交换。
4.2 RNDIS消息格式4.2.1 RNDIS消息由消息头和消息体组成。
4.2.2 消息头包括消息长度、消息类型等字段,用于描述消息的属性和内容。
4.2.3 消息体包含具体的消息数据,根据消息类型的不同而有所变化。
4.3 RNDIS设备与主机的通信流程4.3.1 主机通过USB接口向RNDIS设备发送初始化命令,以建立起与RNDIS 设备的通信连接。
4.3.2 RNDIS设备接收到初始化命令后,进行相应的初始化操作,并向主机发送初始化完成的响应。
4.3.3 主机与RNDIS设备之间进行数据传输时,采用RNDIS消息进行交换。
4.3.4 RNDIS设备根据接收到的RNDIS消息进行相应的处理,并向主机发送响应消息。
NDIS函数简明手册
NDIS函数简明手册函数描述无连接微端口的上层函数DriverEntry 由操作系统调用来激活和初始化微端口驱动程序MiniportAllocateComple 调用它来指示以前调用的 NdisMAllocateMemoryAsync 已经完成MiniportCheckForHang 检查NIC的内部状态MiniportDisableInterrupt 禁止NIC产生中断MiniportEnableInterrupt 允许NIC产生中断MiniportHalt 重新分配和重新注册NIC占用的资源并且终止 NIC以使它不再有用MiniportHandleInterrupt 延期用来完成 I/O中断函数的执行MiniportInitialize 出始化 NICMiniportISR 作为 NIC中断服务例程以高权值运行MiniportQueryInformation 查询微端口驱动程序的性能和当前状态MiniportReconfigure 未使用MiniportReset 对 NIC发出一个硬件重置MiniportReturnPacket 从上层接收一个包,这个包是在这之前通过调用NdisMIndicateReceivePacket 函数传上去的包MiniportSend 如果驱动程序没有 MiniportSendPadcets或 MiniportWanSend函数,它用来将一个包通过NIC传递到网络上MiniportSendPackets 通过 NIC传递一组包到网络上MiniportSetInformation 变换(设置)关于微端口驱动程序或它的 NIC的信息MiniportShutdown 当系统暂时关闭时,将 NIC恢复到初始状态MiniportSynchronizeISR 同步访问与 MiniportISR或 MiniportDisableInterrupt共享的资源。
如果有运行在 DIRQL下的NIC驱动程序函数与驱动程序的 MiniportISR或 MiniportDisableInterrupt函数共享资源,需要此函数MiniportTimer 如果微端口的 NIC不产生中断,用于轮询 NIC的状态MiniportTransferData 将由 NIC接收到的包的内容拷贝到一个给定的包缓存中MiniportWanSend 如果驱动程序控制着 WAN NIC,通过 NIC发送一个包到网络上-----------------------------------------------面向连接微端口的上层函数-----------------------------------------------DriverEntry 由操作系统调用来激活和初始化微端口驱动程序MiniportAllocateComplete 调用它来指示以前调用的 NdisMAllocateMemoryAsync已经完成MiniportChecKForHang 检查 NIC的内部状态MiniportCoActivateVc 激活一个虚连接(VC)MiniportCoCreateVc 为一个 VC建立 VC状态MiniportCoDeactivateVc 为一个 VC释放 VC的状态MiniportCoDeleteVc 删除一个 VCMiniportCoRequest 查询微端口驱动程序的能力和当前状态或改变 (设置)有关微端口驱动程序或它的 NIC的信息MiniportCoSendPackets 通过一个 NIC发送一组包到网络上MiniportDisableInterrupt 禁止一个 NIC产生中断MiniportEnableInterrupt 允许一个 NIC产生中断MiniporeHalt 收回和注销 NIC占用的资源并且终止 NIC以使它不再使用MiniportHandIeInterrupt 延期用来完成 I/O中断函数的执行MiniportInitialize 初始化 NICMiniportISR 作为 NIC中断服务例程以高权值运行MiniportReconfigure 未使用MiniporeReset 对 NIC发出一个硬件重置MiniportReturnPacket 从上层接收一个包,这个包是在这以前通过调用 NdisMCoIndicateReceivePacket传上去的MiniportShutdown 一个可选择函数,当系统关闭时,将 NIC恢复到它的初始状态MiniportSynchronizpISR 同步访问与 MiniportISR或 MiniportDisableInterrupt共享的资源,如果有运行在DIRQL下的 NIC驱动程序函数与驱动程序的 MiniportISR或 MiniportDisableInterrupt函数共享资源MiniportTimer 如果微端口 NIC不产生中断,轮询一个 NIC状态MiniportWanSend 如果驱动程序控制着 WAN NIC ,通过网络接口卡发送一个包到网络上-----------------------------------------------初始化和注册函数-----------------------------------------------NdisMInitializeWrapper 为微端口驱动程序初始化 NDIS库数据结构NdisMRegisterMiniport 向 NDIS提供有关微端口驱动程序的信息NdisMSetAttributes 向 NDIS库报告微端口驱动程序所支持的 NIC的类型并且传递指向微端口的环境区域的句柄。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议一、引言微软RNDIS协议(Remote Network Driver Interface Specification)是一种用于网络驱动程序的通信协议,旨在提供一种标准化的方式,使计算机和网络设备之间能够进行可靠的通信。
本协议的目的是定义RNDIS协议的标准格式,以确保各种设备和操作系统之间的互操作性和兼容性。
二、协议概述1. RNDIS协议的作用RNDIS协议旨在为计算机和网络设备之间的通信提供一种标准化的接口。
它允许计算机通过USB或其他物理接口连接到网络设备,并通过网络设备进行数据传输。
RNDIS协议定义了通信的数据格式、命令和状态,以及设备和驱动程序之间的交互方式。
2. RNDIS协议的基本原理RNDIS协议的基本原理是将网络设备模拟为一个虚拟网络适配器,使其能够与计算机的网络堆栈进行通信。
计算机将RNDIS设备视为一个网络接口,通过发送RNDIS命令和数据包来与设备进行通信。
RNDIS设备接收命令并执行相应的操作,然后将数据包传输给计算机。
三、协议内容1. RNDIS命令格式RNDIS协议定义了一系列命令,用于设备和驱动程序之间的通信。
每个命令由一个命令标识符、参数和数据组成。
命令标识符用于唯一标识每个命令,参数用于传递命令的附加信息,数据用于传输命令所需的数据。
2. RNDIS数据包格式RNDIS协议定义了数据包的格式,用于在计算机和设备之间传输数据。
数据包由一个包头和数据组成。
包头包含了数据包的长度、类型和其他相关信息,而数据则是实际传输的数据。
3. RNDIS状态和通知RNDIS协议定义了一系列状态和通知,用于设备和驱动程序之间的状态同步和事件通知。
设备可以向驱动程序发送状态和通知,以指示设备的状态变化或发生的事件。
四、协议实施1. RNDIS设备驱动程序接口RNDIS协议要求设备制造商提供符合RNDIS规范的设备驱动程序。
设备驱动程序需要实现RNDIS协议定义的接口,以便与计算机进行通信。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议1. 引言本协议旨在定义微软远程网络设备接口规范(Remote Network Device Interface Specification,简称RNDIS),以便实现在微软操作系统上与远程设备的通信。
本协议适合于任何支持RNDIS协议的远程网络设备。
2. 范围本协议适合于所有使用微软操作系统的设备,包括但不限于个人电脑、服务器、挪移设备等。
3. 术语定义在本协议中,以下术语的定义适合于所有相关条款和条件:- RNDIS:远程网络设备接口规范,用于实现微软操作系统与远程设备的通信。
- 远程设备:指支持RNDIS协议的任何外部设备,如网络适配器、无线网卡等。
- 主机:指运行微软操作系统的计算机或者设备。
- RNDIS驱动程序:指在主机上运行的软件模块,用于管理RNDIS设备与主机之间的通信。
4. 协议要求4.1 RNDIS设备的功能要求远程设备必须满足以下要求,以支持RNDIS协议:- 支持基于USB或者以太网的物理接口。
- 实现RNDIS设备类描述符和功能描述符。
- 支持RNDIS命令集,包括设备初始化、数据传输、状态通知等。
- 提供有效的设备识别信息,如供应商ID、产品ID等。
4.2 主机的功能要求主机必须满足以下要求,以支持RNDIS协议:- 安装RNDIS驱动程序,用于与RNDIS设备进行通信。
- 支持USB或者以太网的物理接口。
- 实现RNDIS主机类描述符和功能描述符。
- 支持RNDIS命令集,包括设备初始化、数据传输、状态通知等。
5. 协议流程5.1 设备初始化5.1.1 远程设备初始化远程设备在与主机建立连接后,应发送初始化请求给主机。
初始化请求应包括设备识别信息、设备能力等。
主机在接收到初始化请求后,应进行相应的设备初始化操作。
5.1.2 主机初始化主机在接收到远程设备的初始化请求后,应发送初始化响应给远程设备。
初始化响应应包括主机的能力信息、RNDIS驱动程序版本等。
NDIS 中间层驱动程序(IMD)开发人员指南ndis_devguide
目录1NDIS中间层驱动程序 (2)1.1NDIS中间层驱动程序(NDIS Intermediate Drivers)概述 (2)1.2NDIS中间层驱动程序的用途 (4)1.3NDIS中间层驱动程序的开发环境 (4)2NDIS中间层驱动程序的开发 (4)2.1可分页和可丢弃代码 (4)2.2共享资源的访问同步 (5)2.3中间层驱动程序的DriverEntry函数 (5)2.3.1注册NDIS中间层驱动程序 (6)2.3.1.1注册中间层驱动程序的Miniport (6)2.3.1.2注册中间层驱动程序的协议 (8)2.4中间层驱动程序的动态绑定 (11)2.4.1打开中间层驱动程序下层的适配器 (12)2.4.2微端口(Miniport)初始化 (12)2.4.3中间层驱动程序查询和设置操作 (13)2.4.3.1发布设置和查询请求 (14)2.4.3.2响应设置和查询请求 (15)2.4.4作为面向连接客户程序注册中间层驱动程序 (15)2.5中间层驱动程序数据包管理 (17)2.5.1.1重用数据包 (18)2.6中间层驱动程序的限制 (19)2.7中间层驱动程序接收数据 (19)2.7.1下边界面向无连接的中间层驱动程序接收数据 (19)2.7.1.1在中间层驱动程序中实现ProtocolReceivePacket处理程序 (20)2.7.1.2在中间层驱动程序中实现ProtocolReceive处理程序 (21)2.7.1.3下边界面向无连接中间层驱动程序接收OOB数据信息 (22)2.7.2下边界面向连接的中间层驱动程序接收数据 (22)2.7.2.1在中间层驱动程序中实现ProtocolCoReceivePacket处理程序 (23)2.7.2.2在下边界面向连接的中间层驱动程序中接收OOB数据信息 (23)2.7.3向高层驱动程序指示接收数据包 (23)2.8通过中间层驱动程序传输数据包 (23)2.8.1传递介质相关信息 (25)2.9处理中间层驱动程序的PnP事件和PM事件 (26)2.9.1处理OID_PNP_XXX查询和设置 (26)2.9.2中间层驱动程序ProtocolPnPEvent处理程序的实现 (27)2.9.3处理规定的电源请求 (28)2.9.3.1睡眠状态的电源设置请求 (28)2.9.3.2工作状态的电源设置请求 (29)2.10中间层驱动程序复位操作 (29)2.11中间层驱动程序拆除绑定操作 (30)2.12中间层驱动程序状态指示 (31)3负载平衡和失效替换 (31)3.1关于LBFO (31)3.2指定对LBFO的支持 (32)3.3在微端口驱动程序上实现LBFO (32)3.3.1初始化微端口束 (33)3.3.2平衡微端口驱动程序的工作量 (33)3.3.3在主微端口失效后提升一个次微端口 (34)4安装网络组件 (34)4.1用于安装网络组件的组件和文件 (34)4.2创建网络INF文件 (35)4.2.1网络INFS文件名的约定 (35)4.2.2网络INF文件的版本节 (35)4.2.3网络INF文件的模型节 (36)4.2.4INF文件的DDInstall节 (37)4.2.5删除节 (38)4.2.6ControlFlags节 (39)4.2.7网络INF文件的add-registry-sections (39)表格 1 缩略语表1NDIS中间层驱动程序1.1 NDIS中间层驱动程序(NDIS Intermediate Drivers)概述微软Windows网络驱动程序接口标准(NDIS 4.0)和Windows NT 4.0(SP3)引入了一种新的NDIS驱动程序,它可以嵌在NDIS 传输驱动程序TDI(如,TCP/IP)和底层的NDIS网络接口驱动程序的中间。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议1. 引言本协议旨在规范微软RNDIS(Remote Network Driver Interface Specification)协议的标准格式,以确保设备之间的网络驱动程序接口的互操作性和一致性。
本协议适用于使用微软RNDIS协议的设备和应用程序。
2. 范围本协议适用于以下情况:- 设备和应用程序使用微软RNDIS协议进行网络驱动程序的通信。
- 设备和应用程序需要遵循微软RNDIS协议的规范和要求。
3. 定义以下术语在本协议中具有以下定义:- 设备:指使用微软RNDIS协议的硬件设备。
- 应用程序:指使用微软RNDIS协议的软件应用程序。
- RNDIS:指Remote Network Driver Interface Specification,是微软定义的一种网络驱动程序接口规范。
4. 协议规范4.1 协议版本设备和应用程序应遵循最新版本的微软RNDIS协议规范,以确保互操作性和一致性。
4.2 协议支持设备和应用程序应支持微软RNDIS协议的所有必需功能和特性。
4.3 协议交互设备和应用程序之间的协议交互应遵循微软RNDIS协议规范中定义的消息格式和交互流程。
4.4 数据传输设备和应用程序之间的数据传输应遵循微软RNDIS协议规范中定义的数据包格式和传输机制。
4.5 错误处理设备和应用程序应实现适当的错误处理机制,以处理协议交互和数据传输过程中可能出现的错误情况。
4.6 安全性设备和应用程序应实现适当的安全措施,以保护协议交互和数据传输的安全性和机密性。
5. 实施指南5.1 设备实施指南设备实施者应遵循以下指南:- 实现微软RNDIS协议规范中定义的必需功能和特性。
- 遵循微软RNDIS协议规范中定义的消息格式和交互流程。
- 遵循微软RNDIS协议规范中定义的数据包格式和传输机制。
- 实现适当的错误处理机制。
- 实现适当的安全措施。
5.2 应用程序实施指南应用程序实施者应遵循以下指南:- 实现微软RNDIS协议规范中定义的必需功能和特性。
NDIS
NDIS协议驱动
面向无连接驱动程序必须和可能要求的导出协议函数如下所列:
BindAdapterHandler 这是一个必须提供的函数。NDIS调用该函数请求协议驱动程序绑定到低层网卡或虚拟 网卡上,网卡名作为该处理程序的参数传递。 UnbindAdapterHandler 这是一个必须提供的函数。NDIS 调用 ProtocolUnbindAdapter释放对低层网卡或虚拟网 卡的绑定,网卡名作为参数传递。当绑定成功解除时,ProtocolUnbindAdapter 函数调用 NdisCloseAdapter并释放资源。 OpenAdapterCompleteHandler 这是一个必须提供的函数。如果协议驱动程序对 NdisOpenAdapter 的调用返回 NDIS_STATUS_PENDING,则接着调用 ProtocolOpenAdapterComplete 来完成绑定操作。 CloseAdapterCompleteHandler 这是一个必须提供的函数。如果协议驱动程序对 NdisCloseAdapter 的调用返回 NDIS_STATUS_PENDING, 则接着调用ProtocolCloseAdapterComplete来完成解除绑定操作。 ReceiveHandler 这是一个必须提供的函数。ProtocolReceive 函数以前视缓冲区的指针为参数被调用执行。如果该缓冲 区包含的不是完整的接收到的网络数据包,ProtocolReceive 以协议分配的数据包描述符作为参数,调 用 NdisTransferData 指定协议分配缓冲区接收数据包的其余部分。 ReceiveCompleteHandler 这是一个必须提供的函数。ProtocolReceiveComplete 用来指出:以前指示给ProtocolReceive 的接收 数据包现在可以延期处理。
RNDIS原理分析
RNDIS原理分析--PDD部分---------------by nasiry转载请说明出处,并通知我1.初始化首先我们从PDD_Init开始。
所谓初始化的动作通常包含对硬件设备的初始化,一般说来就是通过设置设备寄存器来对设备进行必要的配置,另外一个方面就是软件的初始化,包括全局数据变量的空间申请初始化,中断函数的挂接,其他函数指针的挂接。
既然需要读写设备的状态寄存器设备的端口/地址就是必不可少的,首先PDD_init先检查有没有从MDD传过来的设备地址,如果没有,通过PciFind2890找一下我们需要的2980有没有在PCI以查卡的形式在某一个插槽上,如果继没有由MDD传递过来的设备地址,PCI 插槽上也没有我们需要的2890,怎么办?还能怎么办,既然没有的话,我也干不下去了,return False算了,88下次再见:P如果在PCI插口上发现2890的话,就比较麻烦一点,因为需要去计算PCI总线上的设备偏移才能得到设备地址,不仅如次还要去摆弄一个叫9054的片子来符合和PCI的规范,其实我们要的只是一个地址和一个中断源,没有必要再PCI设备上搞来搞去,最简单的办法就是假设这个2890是直接挂在系统总线上的,事实上现在用得很普遍的ARM体系下通常都是没有PCI总线的,这样子我们就只用分析MDD直接传递了设备地址的情况,简单还不乏实用性。
总之,我就是不分析PCI总线相关的部分,因为我不会。
下面废话少说进入正题。
PDD_init有两个参数第一个是一个结构指针原形如下:typedef struct _RNDIS_PDD_CHARACTERISTICS{ PFN_PDD_SEND_RNDIS_MESSAGE SendRndisMessageHandler;PFN_PDD_SEND_RNDIS_PACKET SendRndisPacketHandler;PFN_PDD_INDICATE_RNDIS_PACKET_COMPLETE IndicateRndisPacketCompleteHandler;PFN_PDD_SET SetHandler;PFN_PDD_GET GetHandler;PFN_PDD_ISR ISRHandler;DWORD dwIRQ;DWORD dwMaxRx;DWORD dwBaseAddr;// BUS specific information// If it is PCI then this driver will be loaded by PCI enumerator through// NDIS.BOOL bPCIDevice;// These are only needed for PCI type device AND if the driver chooses// to use GIISR.DLL as default ISR.BOOL CheckPort; // If true, check port to see if device is asserting IRQBOOL PortIsIO; // Port is IO port (possibly true only for x86)BOOL UseMaskReg; // If true, read from MaskAddr to obtain maskDWORD PortAddr; // Port AddressDWORD PortSize; // Port data width in bytesDWORD Mask; // Mask to use on data port to determine if device is asserting IRQ DWORD MaskAddr; // Address of register to use as mask} RNDIS_PDD_CHARACTERISTICS, *PRNDIS_PDD_CHARACTERISTICS;这个结构包含了一系列的函数指针和地址,中断,和最大接收数等信息,没有提到的这些个结构成员都是PCI设备所需的,这里我们仅仅需要把bPCIDevice设置为False也就是说我们并没有使用PCI设备就可以了。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议一、引言微软RNDIS(Remote Network Driver Interface Specification)协议是一种用于远程网络驱动程序接口的规范,旨在提供一种标准化的方式,使计算机和外部设备之间能够进行网络通信。
本协议旨在详细描述微软RNDIS协议的规范和要求,以确保各方在使用该协议时能够准确理解和遵守相关规定。
二、定义1. RNDIS设备:指符合微软RNDIS协议的外部设备,如网络适配器、移动设备等。
2. 主机:指计算机或其他支持RNDIS协议的主控设备。
3. 驱动程序:指用于控制和管理RNDIS设备的软件程序。
三、协议规范1. 设备连接与识别1.1 主机应支持自动检测和识别连接的RNDIS设备。
1.2 RNDIS设备应提供唯一的标识符,以便主机能够准确识别和区分不同的设备。
1.3 主机与RNDIS设备之间的通信应遵循标准的USB或其他通信协议。
2. 设备配置2.1 RNDIS设备应支持动态配置网络参数,如IP地址、子网掩码、网关等。
2.2 主机应提供用户界面或API,以便用户或其他程序能够配置RNDIS设备的网络参数。
2.3 RNDIS设备应能够保存和恢复已配置的网络参数,以便在重新连接时能够自动恢复配置。
3. 数据传输3.1 RNDIS设备应支持数据的双向传输,包括主机向设备发送数据和设备向主机发送数据。
3.2 数据传输应保证可靠性和稳定性,且具备一定的容错机制。
3.3 数据传输的速率应根据设备和主机的性能进行自适应调整,以提供最佳的传输效率。
3.4 RNDIS设备应能够处理和响应来自主机的控制命令,如连接、断开连接等。
4. 驱动程序支持4.1 主机应提供相应的驱动程序,以支持对RNDIS设备的控制和管理。
4.2 驱动程序应具备良好的兼容性,能够适配不同型号和版本的RNDIS设备。
4.3 驱动程序应提供友好的用户界面或API,以便用户能够方便地配置和管理RNDIS设备。
微软RNDIS协议书范本
Remote NDIS SpecificationRev 1.1August 9, 2002© 1998-2001 Microsoft Corporation. All rights reserved.1INTRODUCTION (4)1.1L ICENSE A GREEMENT (5)2CONCEPTS AND DEFINITIONS (6)2.1C ONTROL CHANNEL (6)2.2D ATA CHANNEL (6)2.3I NITIALIZATION AND T EARDOWN (6)2.4D EVICE S TATE D EFINITIONS (6)2.4.1Halt (7)2.4.2Reset (7)2.5F LOW C ONTROL (7)2.6B YTE O RDERING (7)2.7E NCAPSULATION (7)2.8R EMOTE NDIS V ERSION (7)2.9S TATUS V ALUES (8)3MESSAGE SET FOR CONNECTIONLESS (802.3) DEVICES (9)3.1REMOTE_NDIS_INITIALIZE_MSG (9)3.1.1REMOTE_NDIS_INITIALIZE_MSG Format (10)3.1.2Response to REMOTE_NDIS_INITIALIZE_MSG (10)3.2REMOTE_NDIS_HALT_MSG (12)3.3REMOTE_NDIS_QUERY_MSG (13)3.3.1REMOTE_NDIS_QUERY_MSG Format (13)3.3.2Response to REMOTE_NDIS_QUERY_MSG (14)3.4REMOTE_NDIS_SET_MSG (14)3.4.1REMOTE_NDIS_SET_MSG Format (15)3.4.2Response to REMOTE_NDIS_SET_MSG (15)3.4.3Setting Device-specific Parameters (16)3.5REMOTE_NDIS_RESET_MSG (17)3.5.1REMOTE_NDIS_RESET_MSG Format (17)3.5.2Response to REMOTE_NDIS_RESET_MSG (17)3.6REMOTE_NDIS_INDICATE_STATUS_MSG (18)3.6.1REMOTE_NDIS_INDICATE_STATUS_MSG Format (19)3.7REMOTE_NDIS_KEEPALIVE_MSG (19)3.7.1REMOTE_NDIS_KEEPALIVE_MSG Format (20)3.7.2Response to REMOTE_NDIS_KEEPALIVE_MSG (20)3.8E XAMPLE C ONNECTIONLESS (802.3)I NITIALIZATION S EQUENCE (21)3.9D ATA M ESSAGES (REMOTE_NDIS_PACKET_MSG) (22)3.9.1REMOTE_NDIS_PACKET_MSG Format (22)3.9.2Multi-Packet Transfers (24)4REQUIRED NDIS OIDS (27)4.1G ENERAL OID S (27)4.2802.3OID S (29)4.3O PTIONAL P OWER M ANAGEMENT OID S (30)4.3.1Network Wake-Up (31)5REMOTE NDIS TO USB MAPPING (32)5.1R ELATED S PECIFICATIONS (32)5.2O VERVIEW (32)5.3P N P AND USB-LEVEL INITIALIZATION (32)5.3.1USB Device Descriptor (32)5.3.2USB Configuration Descriptor (33)5.3.3Communication Class Interface (33)5.3.4Data Class Interface (33)5.4USB-LEVEL TERMINATION (34)5.5C ONTROL CHANNEL CHARACTERISTICS (34)5.6D ATA CHANNEL CHARACTERISTICS (35)5.6.1USB Short Packets (35)5.6.2Flow Control (36)5.7P OWER MANAGEMENT (36)5.8T IMER CONSTANTS (36)1IntroductionRemote NDIS is a bus-independent class specification for Ethernet (802.3) network devices on dynamic PnP busses such as USB, 1394, BlueTooth, and InfiniBand. This specification defines a bus-independent message protocol between a host PC and a Remote NDIS device over abstract control and data channels. Also included are bus-mapping chapters which define specific features of the specification on the respective busses.The “legacy-free” PC revolution is eliminating not only legacy connection ports (e.g. serial, parallel, PS/2) but also legacy expansion buses like ISA and PCI in mainstream PCs. The resulting “sealed case” PCs will require either built-in networking support on the motherboard or support for network adapters on external busses. This specification defines a message protocol for external bus attached network devices. It is precise enough to allow vendor-independent class driver support for Remote NDIS devices on the host PC. Remote NDIS is a fairly simple extension of the well-understood and time-tested NDIS architecture. NDIS defines a function-call interface for device-specific NDIS miniport drivers. This interface defines primitives to send and receive network data, and to query and set configuration parameters and statistics. Remote NDIS leverages NDIS by defining a message wrapping for the NDIS miniport interface, thus moving the NDIS-handling code from a miniport driver into the device itself. In this and other ways, the Remote NDIS specification allows for a wide range of device functionality and performance levels.1.1License AgreementThe Remote NDIS Specification and any accompanying materials (the “Specification”) provided by Microsoft is for your personal use only, and may be used solely for the purpose of implementing the Remote NDIS protocol message set to interface with (i) a Microsoft Windows operating system or (ii) a bus or network-connected communications device, such as a USB, 1394 or TCP/IP device. THE SPECIFICATION MAY NOT BE COPIED OR DISTRIBUTED.Microsoft may have copyrights, patents or pending patent applications covering subject matter in the Specification. To the extent Microsoft has such copyrights, patents or applications, Microsoft agrees to grant a nonexclusive, royalty-free, world-wide license under these copyrights, patents or applications solely to implement the Remote NDIS Specification to interface with (i) a Microsoft Windows operating system or (ii) a bus or network-connected communications device, such as a USB, 1394 or TCP/IP device, on condition that you agree not to assert any intellectual property rights against Microsoft or other companies for their implementation of the Specification. Microsoft reserves all other rights it may have in the Specification. The furnishing of this document does not give you any license to any other Microsoft patents, trademarks, copyrights, or other intellectual property rights. Specifically, neither this document nor the Specification give you any license to the NDIS Specification or to USB Communication Device Class technology.The Specification is provided "AS IS" without warranty of any kind. To the maximum extent permitted by applicable law, Microsoft further disclaims all warranties, including without limitation any implied warranties of merchantability and fitness for a particular purpose, as well as warranties of title and noninfringement. The entire risk arising out of the use or performance of the Specification remains with you.To the maximum extent permitted by applicable law, in no event shall Microsoft or its suppliers be liable for any consequential, incidental, direct, indirect, special, punitive, or other damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the Specification, even if Microsoft has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.2Concepts and DefinitionsThis section discusses requirements and characteristics of the channels used to communicate between the host and the remote device. Device state transitions and major operations such as initialization, halt and reset are also defined here.2.1Control channelThe specifics of the control channel are given in the appropriate bus-mapping chapter. The control channel must be reliable and ensure sequenced delivery. It is used for all communication except for the transmission of network data packets. All required control messages except REMOTE_NDIS_HALT and REMOTE_NDIS_INDICATE_STATUS_MSG are request/response exchanges initiated by the host. The device must respond within the ControlTimeoutPeriod as specified in the appropriate bus-mapping chapter.2.2Data channelThe specifics of the data channel are given in the appropriate bus-mapping chapter. The data channel is used exclusively for the transmission of network data packets. It may consist of multiple sub-channels (e.g. for varying quality of service) as defined in the appropriate bus-mapping chapter. The reliability and delivery specifics of the data channel are likewise defined in the respective bus-mapping chapter.2.3Initialization and TeardownThe control and data channels are initialized as specified in the respective bus-mapping chapter. The host and Remote NDIS device then exchange initialization messages. The host sendsREMOTE_NDIS_INITIALIZE_MSG to the device, and the device provides information about its type, supported medium and version in the response message REMOTE_NDIS_INITIALIZE_CMPLT.Either the host or the remote device can halt the network connection in an abortive fashion via the REMOTE_NDIS_HALT_MSG message. All outstanding requests and packets should be discarded on receipt of this message.2.4Device State DefinitionsFollowing bus-level initialization, the device is in the rndis-uninitialized state. Upon receiving REMOTE_NDIS_INITIALIZE_MSG and returning REMOTE_NDIS_INITIALIZE_CMPLT with status success, the device enters the rndis-initialized state.Upon receiving REMOTE_NDIS_SET_MSG for the OID_GEN_CURRENT_PACKET_FILTER parameter with a non-zero filter, the device enters the rndis-data-initialized state. When in the rndis-data-initialized state, receiving REMOTE_NDIS_SET_MSG for OID_GEN_CURRENT_PACKET_FILTER with a zero filter value forces the device back into the rndis-initialized state.Receiving REMOTE_NDIS_HALT_MSG or a bus-level disconnect or hard-reset at any time forces the device into the rndis-uninitialized state.2.4.1HaltAt any time that the device is in the rndis-initialized or rndis-data-initialized state, the host computer may terminate the Remote NDIS functionality of the device in an abortive fashion by sendingREMOTE_NDIS_HALT_MSG to the device.2.4.2ResetThe communication channel is “soft-reset” when an error such as message tim eout occurs. The host may initiate a soft-reset at any time when the device is in the rndis_initialized state by sendingREMOTE_NDIS_RESET_MSG to the device (see details below); and the device must send a response message when it has completed the reset. For example, the host may initiate a soft-reset when an error, such as a message timeout has occurred.Note that this is a soft reset in the sense that any handles (e.g. VCs for connection-oriented devices) continue to be valid after the reset. The Remote NDIS device, as part of the reset process, discards all outstanding requests and packets. The remote device may reset some of its hardware components, but keeps all communication channels to the host intact.2.4.2.1Hard ResetIf the Remote NDIS device performs a hard reset (i.e. reboot), this event is assumed to be equivalent of “Remove” followed by “Add” plug-and-play events. The host NDIS mini-port will be halted and removed, and a new instance will be added and started. All bus-level and Remote NDIS initialization will be re-executed. A Remote NDIS device may hard-reset itself in the event of a critical device failure.2.5Flow ControlThe Remote NDIS device may need to exercise flow control to prevent the host from overflowing its data buffers with packets. Any flow control provisions or requirements are given in the respective bus-mapping chapter.2.6Byte OrderingAll numeric values in message fields defined by this specification are assumed to be coded in little-endian format, i.e. least significant byte first.2.7EncapsulationThis section does not specify the way NDIS messages are encapsulated in native bus messages or primitives. Please refer to the appropriate bus-mapping chapter for more details.2.8Remote NDIS VersionTable 2-1 defines the Remote NDIS protocol version identifiers exchanged between host and device.Note that these are unrelated to the revision number of this specification.Table 2-1: Remote NDIS Protocol Version2.9Status ValuesThe Remote NDIS status values are generally equivalent to the 32-bit status values defined in the Windows 2000 DDK. Specifically, high bit set indicates an error state and the high bit clear indicates a success state. The specific Remote NDIS status values used in this specification are listed below, others can be inferred from the Windows 2000 DDK or MSDN. A device may return any semantically correct Remote NDIS status value in a Status field of a message that it generates.Table 2-2: Remote NDIS Status Values3Message Set for Connectionless (802.3) Devices The following Remote NDIS control messages that must be supported by an 802.3 connectionless device, seeTable 3-1 for an overview. In the more detailed descriptions below, some messages include a RequestId field. This is used to match sent messages with responses. With this mechanism, a host driver can send multiple Remote NDIS messages to a device without concern for the ordering of responses. A Remote NDIS device must maintain the RequestId field when returning a response.Table 3-1: Control Messages Set3.1REMOTE_NDIS_INITIALIZE_MSGThis message is sent by the host to a Remote NDIS device to initialize the network connection. It is sent via the control channel and only when the device is in the rndis-uninitialized state. SeeTable 3-2 for details of the message.The MaxTransferSize indicates the maximum size, in bytes, of any single bus data transfer that the host expects to receive from the device. Typically, each bus data transfer accommodates a single Remote NDIS message. However, as described below (seeMulti-Packet Transfers), the device may bundle several Remote NDIS messages containing Data packets into a single transfer.MajorVersion and MinorVersion indicate the highest Remote NDIS protocol version implemented by the host. There is no guarantee that the host supports any lower versions; specifics of Remote NDIS version(s) supported by various Windows operating system versions will be documented in appropriate product documentation, e.g. the DDK. SeeTable 2-1 for more details.3.1.1REMOTE_NDIS_INITIALIZE_MSG FormatTable 3-2: REMOTE_NDIS_INITIALIZE_MSG3.1.2Response to REMOTE_NDIS_INITIALIZE_MSGThe device should report its medium type, Remote NDIS version numbers, and its type (connection-less or connection-oriented) in its response to REMOTE_NDIS_INITIALIZE_MSG.The Status field should be set to RNDIS_STATUS_SUCCESS if the device initialized successfully; otherwise it is set to an error code indicating the failure.The device should return the highest Remote NDIS protocol version that it can support, in MajorVersion and MinorVersion– the combined version number should be less than or equal to the version number specified by the host in the REMOTE_NDIS_INITIALIZE_MSG message. This allows for the device to fall back to a compatibility mode when the host implements a Remote NDIS protocol version that is lower than that supported by the device.The DeviceFlags field specifies the device type. MaxPacketsPerTransfer is the maximum number of REMOTE_NDIS_PACKET_MSGs that the device can handle in a single transfer to it - this should be at least 1. MaxTransferSize is the maximum size, in bytes, of a single data transfer that the device expects to receive from the host. The device can specify the byte alignment it expects for each Remote NDIS message that is part of a multi-message transfer to it –PacketAlignmentFactor contains this value as an exponent of 2. For example, this is set to 3 to indicate 8-byte alignment.NOTE: The AFListSize and AFListOffset fields are only relevant for connection-oriented devices that include a call manager. Connectionless devices should set these fields to 0.Table 3-3: REMOTE_NDIS_INITIALIZE_CMPLT3.2REMOTE_NDIS_HALT_MSGThis message is sent by the host in order to terminate the network connection. Unlike the other host initiated control messages, there is no device response to REMOTE_NDIS_HALT_MSG. The message may be sent at any time that the device is in the rndis-initialized or rndis-data-initialized state.Table 3-4: REMOTE_NDIS_HALT_MSG MessageIt is optional for the device to implement sending the REMOTE_NDIS_HALT_MSG. If implemented, the device sends this message to the host via the control channel only when the device is in the rndis-initialized or rndis-data-initialized state. The device must terminate all communication immediately after sending this message. Sending this message causes the device to enter the rndis-uninitialized state.3.3REMOTE_NDIS_QUERY_MSGREMOTE_NDIS_QUERY_MSG is sent to a Remote NDIS device from a host when it needs to query the device for its characteristics or statistics information or status. The parameter or statistics being queried for is identified by means of an Object Identifier (OID). The host may send REMOTE_NDIS_QUERY_MSG to the device via the control channel at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to REMOTE_NDIS_QUERY_MSG with information about the desired capabilities or status.3.3.1REMOTE_NDIS_QUERY_MSG FormatTable 3-5: REMOTE_NDIS_QUERY_MSG Message3.3.2Response to REMOTE_NDIS_QUERY_MSGThe device sends REMOTE_NDIS_QUERY_CMPLT to the host in response toREMOTE_NDIS_QUERY_MSG. This message is used to relay the result of a query for a device parameter or statistics counter to the host.Table 3-6: REMOTE_NDIS_QUERY_CMPLT3.4REMOTE_NDIS_SET_MSGREMOTE_NDIS_SET_MSG is sent to a Remote NDIS device from a host, when it needs to set the value of some operational parameter on the device. The specific parameter being set is identified by means of an Object Identifier (OID), and the value it is to be set to is contained in an information buffer sent along with the message. (For a complete list of required and optional OIDs, please refer to Section 1.) The host may send REMOTE_NDIS_SET_MSG to the device via the control channel at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to aREMOTE_NDIS_SET_MSG message with a status.3.4.1REMOTE_NDIS_SET_MSG FormatTable 3-7: REMOTE_NDIS_SET_MSG Message3.4.2Response to REMOTE_NDIS_SET_MSGThe device sends the REMOTE_NDIS_SET_CMPLT message to the host in response toREMOTE_NDIS_SET_MSG. This message is used to relay the result of setting the value of a device operational parameter to the host.Table 3-8: REMOTE_NDIS_SET_CMPLT3.4.3Setting Device-specific ParametersIt is expected that most Remote NDIS devices will function well without the need to configure parameters on the host. However, there may be cases where proper network operation requires some configuration on the host. If the device supports configurable parameters, then it should include the following optional OID in the list of supported OIDs it reports in response to a query for OID_GEN_SUPPORTED_LIST:OID_GEN_RNDIS_CONFIG_PARAMETER (0x0001021B)If the device supports this OID, the host uses it to set device-specific parameters, soon after the device enters the rndis_initialized state from rndis_uninitialized. The host will send zero or moreREMOTE_NDIS_SET_MSGs to the device, with OID_GEN_RNDIS_CONFIG_PARAMETER as the OID value to set. Each such REMOTE_NDIS_SET_MSG corresponds to one device-specific parameter that is configured on the host.The InformationBuffer associated with each such REMOTE_NDIS_SET_MSG has the following format. Note that the Offset values are relative to the beginning of the information buffer.Table 3-9: InformationBuffer for OID_GEN_RNDIS_CONFIG_PARAMETERThe device sends a REMOTE_NDIS_SET_CMPLT in response to each REMOTE_NDIS_SET_MSG, after applying the parameter value. If the parameter setting is acceptable, it returns a status ofRNDIS_STATUS_SUCCESS in the response. If the parameter setting is not acceptable, and the device cannot apply a useful default value for this parameter, then the device returns an appropriate error status value (seeTable 2-2). If an error status is returned, then the host will initiate a Halt process (see Section 3) for the device.Device-specific parameters are expected to be configured in the Windows registry. The keys that define parameter values are typically created in the registry during the process of device installation; the list of keys, type information, default values and optional range of valid values are specified in the INF file for the device. For more information on using an INF to set up configuration parameters in the registry for network devices, please consult the Windows 2000 DDK.3.5REMOTE_NDIS_RESET_MSGA REMOTE_NDIS_RESET_MSG message is sent to a Remote NDIS device from a host via the control channel to soft-reset the device and return status. This message may be sent at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to aREMOTE_NDIS_RESET_MSG message with a status.3.5.1REMOTE_NDIS_RESET_MSG FormatTable 3-10: REMOTE_NDIS_RESET_MSG Message3.5.2Response to REMOTE_NDIS_RESET_MSGWhen the device receives REMOTE_NDIS_RESET_MSG, it performs a soft-reset and then sends REMOTE_NDIS_RESET_CMPLT to the host with the result status.Table 3-11: REMOTE_NDIS_RESET_CMPLT3.6REMOTE_NDIS_INDICATE_STATUS_MSGThe device may send REMOTE_NDIS_INDICATE_STATUS_MSG to the host via the control channel in an unsolicited fashion at any time that the device is in the rndis-initialized or rndis-data-initialized state. This message is used to indicate a change in the status of the device.REMOTE_NDIS_INDICATE_STATUS_MSG can also be used to indicate an error event, such as an unrecognized message.The most common use of REMOTE_NDIS_INDICATE_STATUS_MSG is to indicate the state of link for an 802.3 device. Status=RNDIS_STATUS_MEDIA_CONNECT indicates a transition from disconnected (e.g. no 802.3 link pulse) to connected state (802.3 link pulse detected); Status=RNDIS_STATUS_MEDIA_DISCONNECT indicates a transition from connected to disconnected state . The device must send REMOTE_NDIS_INDICATE_STATUS_MSG with one of these values every time that the 802.3 link state changes. No status buffer is required to return these two common indications.In the specific case where this is sent in response to a message that the device could not handle, the Status field must be set to RNDIS_STATUS_INVALID_DATA, and the status buffer is formatted as described in Table 3-12.If the error condition was caused by an Remote NDIS message, for example if the device didn’t understand a particular Remote NDIS message, then the device must append the original message at the end of the status message defined above. In this case, DiagStatus contains additional status about the error itself (e.g.RNDIS_STATUS_NOT_SUPPORTED) and ErrorOffset is the 0-based byte offset within the offending message at which the error was detected.Note that this message is used to report an error condition only in circumstances where the device is not able to generate a response message with appropriate status. Examples of appropriate usage are: (a) on receiving a message with unsupported message type (b) on receiving an REMOTE_NDIS_PACKET_MSG with unacceptable contents.3.6.1REMOTE_NDIS_INDICATE_STATUS_MSG FormatTable 3-12: REMOTE_NDIS_INDICATE_STATUS_MSG MessageTable 3-13: Rndis_Diagnostic_Info3.7REMOTE_NDIS_KEEPALIVE_MSGThe host sends REMOTE_NDIS_KEEPALIVE_MSG to the device via the control channel in order to check the health of the device. When the device is in the rndis-data-initialized state, the host sends this message periodically when there has been no other control or data traffic from the device to the host for the KeepAliveTimeoutPeriod. KeepAliveTimeoutPeriod is bus-dependent and is defined in the appropriate bus-mapping chapter.Upon receiving this message, the remote device must send back a response whose Status field indicates whether the device solicits a REMOTE_NDIS_RESET_MSG message from the host.The host will not send REMOTE_NDIS_KEEPALIVE_MSG until the KeepAliveTimeoutPeriod has elapsed since the last message received from the remote device. This avoids unnecessary exchange of REMOTE_NDIS_KEEPALIVE_MSG messages when the communication channel is active.The device may optionally send this message to the host as well. For example, the device may use this message to trigger a response from the host for the purpose of computing round-trip delay time. If implemented, the device must send REMOTE_NDIS_KEEPALIVE_MSG via the control channel and only when in the rndis-initialized or rndis-data-initialized state.NOTE: The device does not need to perform any specific action if it stops seeingREMOTE_NDIS_KEEPALIVE_MSG messages from the host.3.7.1REMOTE_NDIS_KEEPALIVE_MSG FormatTable 3-14: REMOTE_NDIS_KEEPALIVE_MSG Message3.7.2Response to REMOTE_NDIS_KEEPALIVE_MSGThe device sends REMOTE_NDIS_KEEPALIVE_CMPLT to the host in response to aREMOTE_NDIS_KEEPALIVE_MSG. If the returned Status is not RNDIS_STATUS_SUCCESS, then the host will send REMOTE_NDIS_RESET_MSG to reset the device.Table 3-15: REMOTE_NDIS_KEEPALIVE_CMPLTIf the device implements the option of sending REMOTE_NDIS_KEEPALIVE_MSG, then the host will respond with REMOTE_NDIS_KEEPALIVE_CMPLT via the control channel.3.8Example Connectionless (802.3) Initialization Sequence This section describes the general order of events that a device can expect upon startup as a Remote NDIS connectionless device. Because the basic operation of Remote NDIS is the same, regardless of the underlying bus, the require bus enumeration and start up process has been left out of the example.Table 3-16: Generic Connectionless Remote NDIS Initialization SequenceNote: real world operation will vary depending on version of Windows and NDIS.3.9Data Messages (REMOTE_NDIS_PACKET_MSG)A Remote NDIS device transfers NDIS packets, encapsulated as REMOTE_NDIS_PACKET_MSG across the data channel. REMOTE_NDIS_PACKET_MSG may contain out of band (OOB) data and/or per-packet information.3.9.1REMOTE_NDIS_PACKET_MSG FormatTable 3-17: REMOTE_NDIS_PACKET_MSG3.9.1.1Out-of-band dataEach REMOTE_NDIS_PACKET_MSG may contain one or more out-of-band data records. NumOOBDataElements indicates the number of out-of-band data records in this message. The out-of-band data records must appear in sequence. The OOBDataLength field indicates the byte length of the entire out-of-band data block. The OOBDataOffset field indicates the byte offset from the beginning of the DataOffset field to the beginning of the out-of-band data block. See the NDIS specification for more information about out-of-band packet data.Table 3-18defines the format of a single out-of-band data record.Table 3-18: Out of Band Data Record FormatNote: (N) is equal to the value of ClassInformationOffsetIf there are multiple out-of-band data blocks attached to a REMOTE_NDIS_PACKET_MSG, then each subsequent out-of-band data record must immediately follow the previous out-of-band record’s data. There is no out of band information currently defined for 802.3 devices.3.9.1.2Per-packet-info DataEach REMOTE_NDIS_PACKET_MSG may contain one or more per-packet-info data records. Per-packet-info is used to convey packet meta-data such as TCP checksum. See the NDIS specification for more information about per-packet info data.Table 3-19 defines the format of a per-packet-info data record.Table 3-19: Per-Packet Info Data Record FormatNOTE: (N) is equal to the value of PerPacketInformationOffsetIf there are multiple per-packet-info data blocks, then each subsequent per-packet-info data record must immediately follow the previous per-packet-info record’s data.3.9.2Multi-Packet TransfersMultiple REMOTE_NDIS_PACKET_MSG messages may be sent in a single transfer, in either direction. The maximum length of such a transfer is governed by the MaxTransferSize parameter passed in the REMOTE_NDIS_INITIALIZE_MSG and response messages. The host will also limit the number of REMOTE_NDIS_PACKET_MSGs it bundles into a single transfer to the value of the MaxPacketsPerTransfer parameter returned by the device in its response toREMOTE_NDIS_INITIALIZE_MSG.Concatenating multiple REMOTE_NDIS_PACKET_MSG elements forms a multi-packet message. Each individual REMOTE_NDIS_PACKET_MSG component is constructed as described above. The difference from the single-packet message case is that the MessageLength field in eachREMOTE_NDIS_PACKET_MSG header includes some additional padding bytes. These padding bytes are appended to all but the last REMOTE_NDIS_PACKET_MSG such that the succeedingREMOTE_NDIS_PACKET_MSG starts at an appropriate byte boundary. For messages sent from the device to the host, this padding should result in each REMOTE_NDIS_PACKET_MSG starting at a byte offset that is a multiple of 8 bytes starting from the beginning of the multi-packet message. When the host sends a multi-packet message to the device, it will adhere to the PacketAlignmentFactor specified by the device.Note that neither the combined length of a multi-packet message nor the number ofREMOTE_NDIS_PACKET_MSG elements in a combined message is given explicitly in any Remote NDIS –defined field. The combined length is implicit in the bus-specific transfer mechanism, and the host or device must walk the MessageLength fields of the combined message to determine the number of combined messages.Table 3-20 contains an example of a multi-packet message that is made up of twoREMOTE_NDIS_PACKET_MSGs, sent from the host to the device. During the。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议1. 引言本协议旨在定义微软远程网络驱动接口规范(Remote Network Driver Interface Specification,简称RNDIS协议),用于在计算机系统和外部设备之间进行网络通信。
本协议适用于基于微软操作系统的计算机和支持RNDIS协议的外部设备。
2. 范围本协议适用于以下情景:- 计算机操作系统与外部设备之间的网络通信。
- 外部设备通过USB接口连接到计算机。
3. 术语定义- RNDIS(Remote Network Driver Interface Specification):远程网络驱动接口规范,定义了计算机系统和外部设备之间的网络通信接口。
- 计算机系统:运行微软操作系统的计算机设备。
- 外部设备:通过USB接口连接到计算机系统的设备,支持RNDIS协议。
4. 协议规范4.1 协议描述RNDIS协议建立在USB协议之上,通过USB接口实现计算机系统与外部设备之间的网络通信。
协议规定了数据包的格式和传输方式,确保数据的可靠传输和解析。
4.2 数据包格式RNDIS协议中的数据包由以下字段组成:- 包头(Header):包含数据包的起始标识和长度信息。
- 控制信息(Control Information):包含数据包的控制命令和状态信息。
- 数据(Data):包含传输的数据内容。
4.3 数据传输4.3.1 初始化阶段在计算机系统与外部设备建立连接时,需要进行初始化阶段的握手过程。
计算机系统发送初始化命令给外部设备,外部设备返回初始化响应。
双方通过交换初始化命令和响应来确认协议支持和参数配置。
4.3.2 数据传输阶段在初始化阶段完成后,计算机系统和外部设备可以进行数据的传输。
计算机系统可以向外部设备发送数据包,外部设备收到后进行处理并返回响应。
数据包的传输可以使用批量传输方式,以提高传输效率。
4.4 错误处理在数据传输过程中,可能会出现错误情况,如数据包丢失、传输超时等。
微软RNDIS协议
微软RNDIS协议协议名称:微软RNDIS协议一、引言本协议旨在规范微软RNDIS(Remote Network Driver Interface Specification)协议的标准格式,以确保设备之间的网络驱动程序接口能够实现互操作性和兼容性。
二、背景微软RNDIS协议是一种用于在计算机和外部设备之间传输网络数据的驱动程序接口协议。
该协议旨在通过USB连接将计算机与外部设备(如移动电话、网络摄像头等)连接起来,使外部设备能够通过计算机访问网络。
三、定义在本协议中,以下术语的定义如下:1. RNDIS设备:符合微软RNDIS协议的外部设备。
2. 主机:指运行RNDIS驱动程序的计算机。
3. RNDIS驱动程序:在主机上运行的驱动程序,用于与RNDIS设备进行通信。
4. RNDIS消息:指在主机和RNDIS设备之间传输的消息,用于控制和传输网络数据。
四、协议要求1. RNDIS设备的实现必须符合微软RNDIS协议的规范,确保与主机之间的互操作性和兼容性。
2. RNDIS设备必须能够通过USB接口与主机进行连接,并能够被主机正确地识别和驱动。
3. RNDIS设备必须能够通过RNDIS消息进行与主机的通信,包括但不限于设备初始化、网络配置、数据传输等功能。
4. RNDIS设备必须支持主机对设备的控制命令,如启动、停止、重置等。
5. RNDIS设备必须能够在主机的网络适配器列表中正确显示,并能够通过主机的网络协议栈进行网络通信。
6. RNDIS设备必须能够支持主机对设备的状态查询和事件通知,以便主机能够及时获知设备的状态变化。
7. RNDIS设备必须能够支持主机对设备的性能查询和配置,以便主机能够根据需要对设备进行优化和配置。
8. RNDIS设备必须能够支持主机对设备的固件升级,以便主机能够通过固件升级来修复和改进设备的功能和性能。
五、协议实施1. RNDIS设备的制造商应根据微软RNDIS协议的规范进行设备的设计和开发,并确保设备的实现符合协议要求。
微软RNDIS协议
Remote NDIS SpecificationRevAugust 9, 2002© 1998-2001 Microsoft Corporation. All rights reserved.1INTRODUCTION ...................................................错误!未定义书签。
L ICENSE A GREEMENT.............................................. 错误!未定义书签。
2CONCEPTS AND DEFINITIONS .......................................错误!未定义书签。
C ONTROL CHANNEL ............................................... 错误!未定义书签。
D ATA CHANNEL.................................................. 错误!未定义书签。
I NITIALIZATION AND T EARDOWN ..................................... 错误!未定义书签。
D EVICE S TATE D EFINITIONS........................................ 错误!未定义书签。
Halt .................................................... 错误!未定义书签。
Reset ................................................... 错误!未定义书签。
F LOW C ONTROL.................................................. 错误!未定义书签。
RNDIS,ECM及MBIM报文简述
RNDIS/ECM/MBIM报文简述本文对USB CDC中三种较常见的Communication Class报文内容进行了简单的描述。
1.RNDIS相关资料为《Remote NDIS Specification, V1.1》August 9, 2002。
其报头格式如表1所示。
表1 Remote-NDIS 报头其报文示例如图1所示。
红色标记部分为其包头部分,余下为MAC包。
图1 RNDIS示例报文利用wireshark,分析其MAC包,如图2所示。
由此可知,该包为IPv4,UDP。
图2 MAC包示例2. ECM相关资料为《Universal Serial Bus Communications Class Subclass Specification for Ethernet Control Model Devices, v1.2》February 9, 2007。
目前为MacOS采用。
用Lecroy USB Analyzer抓包的结果看,没有报头,仅是MAC包。
用wireshark分析该包,如图3所示。
图3 ECM报文格式示例由此可见,该虚拟网卡地址为0x00:0x0C:0x29:0xA3:0x9B:0x6D。
3. MBIM相关资料为《Universal Serial Bus Communications Class Subclass Specification for Mobile Broadband Interface Model, v1.0》November 14, 2011。
目前为win8采用。
其报文结构如图4所示。
图4 MBIM报文格式其中Header具体结构如表2所示。
表2 NTP16结构其中NDP16具体结构如表3所示。
其中Datagram为IP包内容,其结构如图5所示。
用Busfound抓包,如图6所示。
综上可知,该IP报文为IPv4的IGMP包。
因wireshark无法识别该网口,所以无法使用该工具。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Remote NDIS SpecificationRev 1.1August 9, 2002© 1998-2001 Microsoft Corporation. All rights reserved.1INTRODUCTION (4)1.1L ICENSE A GREEMENT (5)2CONCEPTS AND DEFINITIONS (6)2.1C ONTROL CHANNEL (6)2.2D ATA CHANNEL (6)2.3I NITIALIZATION AND T EARDOWN (6)2.4D EVICE S TATE D EFINITIONS (6)2.4.1Halt (7)2.4.2Reset (7)2.5F LOW C ONTROL (7)2.6B YTE O RDERING (7)2.7E NCAPSULATION (8)2.8R EMOTE NDIS V ERSION (8)2.9S TATUS V ALUES (8)3MESSAGE SET FOR CONNECTIONLESS (802.3) DEVICES (10)3.1REMOTE_NDIS_INITIALIZE_MSG (11)3.1.1REMOTE_NDIS_INITIALIZE_MSG Format (11)3.1.2Response to REMOTE_NDIS_INITIALIZE_MSG (12)3.2REMOTE_NDIS_HALT_MSG (14)3.3REMOTE_NDIS_QUERY_MSG (14)3.3.1REMOTE_NDIS_QUERY_MSG Format (15)3.3.2Response to REMOTE_NDIS_QUERY_MSG (15)3.4REMOTE_NDIS_SET_MSG (16)3.4.1REMOTE_NDIS_SET_MSG Format (16)3.4.2Response to REMOTE_NDIS_SET_MSG (17)3.4.3Setting Device-specific Parameters (18)3.5REMOTE_NDIS_RESET_MSG (19)3.5.1REMOTE_NDIS_RESET_MSG Format (19)3.5.2Response to REMOTE_NDIS_RESET_MSG (19)3.6REMOTE_NDIS_INDICATE_STATUS_MSG (20)3.6.1REMOTE_NDIS_INDICATE_STATUS_MSG Format (21)3.7REMOTE_NDIS_KEEPALIVE_MSG (21)3.7.1REMOTE_NDIS_KEEPALIVE_MSG Format (22)3.7.2Response to REMOTE_NDIS_KEEPALIVE_MSG (22)3.8E XAMPLE C ONNECTIONLESS (802.3)I NITIALIZATION S EQUENCE (23)3.9D ATA M ESSAGES (REMOTE_NDIS_PACKET_MSG) (25)3.9.1REMOTE_NDIS_PACKET_MSG Format (25)3.9.2Multi-Packet Transfers (27)4REQUIRED NDIS OIDS (30)4.1G ENERAL OID S (30)4.2802.3OID S (32)4.3O PTIONAL P OWER M ANAGEMENT OID S (33)4.3.1Network Wake-Up (34)5REMOTE NDIS TO USB MAPPING (35)5.1R ELATED S PECIFICATIONS (35)5.2O VERVIEW (35)5.3P N P AND USB-LEVEL INITIALIZATION (35)5.3.1USB Device Descriptor (35)5.3.2USB Configuration Descriptor (36)5.3.3Communication Class Interface (36)5.3.4Data Class Interface (36)5.4USB-LEVEL TERMINATION (37)5.5C ONTROL CHANNEL CHARACTERISTICS (37)5.6D ATA CHANNEL CHARACTERISTICS (38)5.6.1USB Short Packets (39)5.6.2Flow Control (39)5.7P OWER MANAGEMENT (39)5.8T IMER CONSTANTS (39)1IntroductionRemote NDIS is a bus-independent class specification for Ethernet (802.3) network devices on dynamic PnP busses such as USB, 1394, BlueTooth, and InfiniBand. This specification defines a bus-independent message protocol between a host PC and a Remote NDIS device over abstract control and data channels. Also included are bus-mapping chapters which define specific features of the specification on the respective busses.The “legacy-free” PC revolution is eliminating not only legacy connection ports (e.g. serial, parallel, PS/2) but also legacy expansion buses like ISA and PCI in mainstream PCs. The resulting “sealed case” PCs will require either built-in networking support on the motherboard or support for network adapters on external busses. This specification defines a message protocol for external bus attached network devices. It is precise enough to allow vendor-independent class driver support for Remote NDIS devices on the host PC. Remote NDIS is a fairly simple extension of the well-understood and time-tested NDIS architecture. NDIS defines a function-call interface for device-specific NDIS miniport drivers. This interface defines primitives to send and receive network data, and to query and set configuration parameters and statistics. Remote NDIS leverages NDIS by defining a message wrapping for the NDIS miniport interface, thus moving the NDIS-handling code from a miniport driver into the device itself. In this and other ways, the Remote NDIS specification allows for a wide range of device functionality and performance levels.1.1License AgreementThe Remote NDIS Specification and any accompanying materials (the “Specification”) provided by Microsoft is for your personal use only, and may be used solely for the purpose of implementing the Remote NDIS protocol message set to interface with (i) a Microsoft Windows operating system or (ii) a bus or network-connected communications device, such as a USB, 1394 or TCP/IP device. THE SPECIFICATION MAY NOT BE COPIED OR DISTRIBUTED.Microsoft may have copyrights, patents or pending patent applications covering subject matter in the Specification. To the extent Microsoft has such copyrights, patents or applications, Microsoft agrees to grant a nonexclusive, royalty-free, world-wide license under these copyrights, patents or applications solely to implement the Remote NDIS Specification to interface with (i) a Microsoft Windows operating system or (ii) a bus or network-connected communications device, such as a USB, 1394 or TCP/IP device, on condition that you agree not to assert any intellectual property rights against Microsoft or other companies for their implementation of the Specification. Microsoft reserves all other rights it may have in the Specification. The furnishing of this document does not give you any license to any other Microsoft patents, trademarks, copyrights, or other intellectual property rights. Specifically, neither this document nor the Specification give you any license to the NDIS Specification or to USB Communication Device Class technology.The Specification is provided "AS IS" without warranty of any kind. To the maximum extent permitted by applicable law, Microsoft further disclaims all warranties, including without limitation any implied warranties of merchantability and fitness for a particular purpose, as well as warranties of title and noninfringement. The entire risk arising out of the use or performance of the Specification remains with you.To the maximum extent permitted by applicable law, in no event shall Microsoft or its suppliers be liable for any consequential, incidental, direct, indirect, special, punitive, or other damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the Specification, even if Microsoft has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.2Concepts and DefinitionsThis section discusses requirements and characteristics of the channels used to communicate between the host and the remote device. Device state transitions and major operations such as initialization, halt and reset are also defined here.2.1Control channelThe specifics of the control channel are given in the appropriate bus-mapping chapter. The control channel must be reliable and ensure sequenced delivery. It is used for all communication except for the transmission of network data packets. All required control messages except REMOTE_NDIS_HALT andREMOTE_NDIS_INDICATE_STATUS_MSG are request/response exchanges initiated by the host. The device must respond within the ControlTimeoutPeriod as specified in the appropriate bus-mapping chapter. 2.2Data channelThe specifics of the data channel are given in the appropriate bus-mapping chapter. The data channel is used exclusively for the transmission of network data packets. It may consist of multiple sub-channels (e.g. for varying quality of service) as defined in the appropriate bus-mapping chapter. The reliability and delivery specifics of the data channel are likewise defined in the respective bus-mapping chapter.2.3Initialization and TeardownThe control and data channels are initialized as specified in the respective bus-mapping chapter. The host and Remote NDIS device then exchange initialization messages. The host sendsREMOTE_NDIS_INITIALIZE_MSG to the device, and the device provides information about its type, supported medium and version in the response message REMOTE_NDIS_INITIALIZE_CMPLT.Either the host or the remote device can halt the network connection in an abortive fashion via the REMOTE_NDIS_HALT_MSG message. All outstanding requests and packets should be discarded on receipt of this message.2.4Device State DefinitionsFollowing bus-level initialization, the device is in the rndis-uninitialized state. Upon receivingREMOTE_NDIS_INITIALIZE_MSG and returning REMOTE_NDIS_INITIALIZE_CMPLT with status success, the device enters the rndis-initialized state.Upon receiving REMOTE_NDIS_SET_MSG for the OID_GEN_CURRENT_PACKET_FILTER parameter with a non-zero filter, the device enters the rndis-data-initialized state. When in the rndis-data-initialized state, receiving REMOTE_NDIS_SET_MSG for OID_GEN_CURRENT_PACKET_FILTER with a zero filter value forces the device back into the rndis-initialized state.Receiving REMOTE_NDIS_HALT_MSG or a bus-level disconnect or hard-reset at any time forces the device into the rndis-uninitialized state.2.4.1HaltAt any time that the device is in the rndis-initialized or rndis-data-initialized state, the host computer may terminate the Remote NDIS functionality of the device in an abortive fashion by sendingREMOTE_NDIS_HALT_MSG to the device.2.4.2ResetThe communication channel is “soft-reset” when an error such as message tim eout occurs. The host may initiate a soft-reset at any time when the device is in the rndis_initialized state by sendingREMOTE_NDIS_RESET_MSG to the device (see details below); and the device must send a response message when it has completed the reset. For example, the host may initiate a soft-reset when an error, such as a message timeout has occurred.Note that this is a soft reset in the sense that any handles (e.g. VCs for connection-oriented devices) continue to be valid after the reset. The Remote NDIS device, as part of the reset process, discards all outstanding requests and packets. The remote device may reset some of its hardware components, but keeps all communication channels to the host intact.2.4.2.1Hard ResetIf the Remote NDIS device performs a hard reset (i.e. reboot), this event is assumed to be equivalent of “Remove” followed by “Add” plug-and-play events. The host NDIS mini-port will be halted and removed, and a new instance will be added and started. All bus-level and Remote NDIS initialization will be re-executed. A Remote NDIS device may hard-reset itself in the event of a critical device failure.2.5Flow ControlThe Remote NDIS device may need to exercise flow control to prevent the host from overflowing its data buffers with packets. Any flow control provisions or requirements are given in the respective bus-mapping chapter.2.6Byte OrderingAll numeric values in message fields defined by this specification are assumed to be coded in little-endian format, i.e. least significant byte first.2.7EncapsulationThis section does not specify the way NDIS messages are encapsulated in native bus messages or primitives. Please refer to the appropriate bus-mapping chapter for more details.2.8Remote NDIS VersionTable 2-1 defines the Remote NDIS protocol version identifiers exchanged between host and device.Note that these are unrelated to the revision number of this specification.Table 2-1: Remote NDIS Protocol Version2.9Status ValuesThe Remote NDIS status values are generally equivalent to the 32-bit status values defined in the Windows 2000 DDK. Specifically, high bit set indicates an error state and the high bit clear indicates a success state. The specific Remote NDIS status values used in this specification are listed below, others can be inferred from the Windows 2000 DDK or MSDN. A device may return any semantically correct Remote NDIS status value in a Status field of a message that it generates.Table 2-2: Remote NDIS Status Values3Message Set for Connectionless (802.3) DevicesThe following Remote NDIS control messages that must be supported by an 802.3 connectionless device, seeTable 3-1 for an overview. In the more detailed descriptions below, some messages include a RequestId field. This is used to match sent messages with responses. With this mechanism, a host driver can send multiple Remote NDIS messages to a device without concern for the ordering of responses. A Remote NDIS device must maintain the RequestId field when returning a response.Table 3-1: Control Messages Set3.1REMOTE_NDIS_INITIALIZE_MSGThis message is sent by the host to a Remote NDIS device to initialize the network connection. It is sent via the control channel and only when the device is in the rndis-uninitialized state. SeeTable 3-2 for details of the message.The MaxTransferSize indicates the maximum size, in bytes, of any single bus data transfer that the host expects to receive from the device. Typically, each bus data transfer accommodates a single Remote NDIS message. However, as described below (seeMulti-Packet Transfers), the device may bundle several Remote NDIS messages containing Data packets into a single transfer.MajorVersion and MinorVersion indicate the highest Remote NDIS protocol version implemented by the host. There is no guarantee that the host supports any lower versions; specifics of Remote NDIS version(s) supported by various Windows operating system versions will be documented in appropriate product documentation, e.g. the DDK. SeeTable 2-1 for more details.3.1.1REMOTE_NDIS_INITIALIZE_MSG FormatTable 3-2: REMOTE_NDIS_INITIALIZE_MSG3.1.2Response to REMOTE_NDIS_INITIALIZE_MSGThe device should report its medium type, Remote NDIS version numbers, and its type (connection-less or connection-oriented) in its response to REMOTE_NDIS_INITIALIZE_MSG.The Status field should be set to RNDIS_STATUS_SUCCESS if the device initialized successfully; otherwise it is set to an error code indicating the failure.The device should return the highest Remote NDIS protocol version that it can support, in MajorVersion and MinorVersion– the combined version number should be less than or equal to the version number specified by the host in the REMOTE_NDIS_INITIALIZE_MSG message. This allows for the device to fall back to a compatibility mode when the host implements a Remote NDIS protocol version that is lower than that supported by the device.The DeviceFlags field specifies the device type. MaxPacketsPerTransfer is the maximum number of REMOTE_NDIS_PACKET_MSGs that the device can handle in a single transfer to it - this should be at least 1. MaxTransferSize is the maximum size, in bytes, of a single data transfer that the device expects to receive from the host. The device can specify the byte alignment it expects for each Remote NDIS message that is part of a multi-message transfer to it –PacketAlignmentFactor contains this value as an exponent of 2. For example, this is set to 3 to indicate 8-byte alignment.NOTE: The AFListSize and AFListOffset fields are only relevant for connection-oriented devices that include a call manager. Connectionless devices should set these fields to 0.Table 3-3: REMOTE_NDIS_INITIALIZE_CMPLT3.2REMOTE_NDIS_HALT_MSGThis message is sent by the host in order to terminate the network connection. Unlike the other host initiated control messages, there is no device response to REMOTE_NDIS_HALT_MSG. The message may be sent at any time that the device is in the rndis-initialized or rndis-data-initialized state.Table 3-4: REMOTE_NDIS_HALT_MSG MessageIt is optional for the device to implement sending the REMOTE_NDIS_HALT_MSG. If implemented, the device sends this message to the host via the control channel only when the device is in the rndis-initialized or rndis-data-initialized state. The device must terminate all communication immediately after sending this message. Sending this message causes the device to enter the rndis-uninitialized state.3.3REMOTE_NDIS_QUERY_MSGREMOTE_NDIS_QUERY_MSG is sent to a Remote NDIS device from a host when it needs to query the device for its characteristics or statistics information or status. The parameter or statistics being queried for isidentified by means of an Object Identifier (OID). The host may send REMOTE_NDIS_QUERY_MSG to the device via the control channel at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to REMOTE_NDIS_QUERY_MSG with information about the desired capabilities or status.3.3.1REMOTE_NDIS_QUERY_MSG FormatTable 3-5: REMOTE_NDIS_QUERY_MSG Message3.3.2Response to REMOTE_NDIS_QUERY_MSGThe device sends REMOTE_NDIS_QUERY_CMPLT to the host in response toREMOTE_NDIS_QUERY_MSG. This message is used to relay the result of a query for a device parameter or statistics counter to the host.Table 3-6: REMOTE_NDIS_QUERY_CMPLT3.4REMOTE_NDIS_SET_MSGREMOTE_NDIS_SET_MSG is sent to a Remote NDIS device from a host, when it needs to set the value of some operational parameter on the device. The specific parameter being set is identified by means of an Object Identifier (OID), and the value it is to be set to is contained in an information buffer sent along with the message. (For a complete list of required and optional OIDs, please refer to Section 1.) The host may send REMOTE_NDIS_SET_MSG to the device via the control channel at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to aREMOTE_NDIS_SET_MSG message with a status.3.4.1REMOTE_NDIS_SET_MSG FormatTable 3-7: REMOTE_NDIS_SET_MSG Message3.4.2Response to REMOTE_NDIS_SET_MSGThe device sends the REMOTE_NDIS_SET_CMPLT message to the host in response to REMOTE_NDIS_SET_MSG. This message is used to relay the result of setting the value of a device operational parameter to the host.Table 3-8: REMOTE_NDIS_SET_CMPLT3.4.3Setting Device-specific ParametersIt is expected that most Remote NDIS devices will function well without the need to configure parameters on the host. However, there may be cases where proper network operation requires some configuration on the host. If the device supports configurable parameters, then it should include the following optional OID in the list of supported OIDs it reports in response to a query for OID_GEN_SUPPORTED_LIST:OID_GEN_RNDIS_CONFIG_PARAMETER (0x0001021B)If the device supports this OID, the host uses it to set device-specific parameters, soon after the device enters the rndis_initialized state from rndis_uninitialized. The host will send zero or moreREMOTE_NDIS_SET_MSGs to the device, with OID_GEN_RNDIS_CONFIG_PARAMETER as the OID value to set. Each such REMOTE_NDIS_SET_MSG corresponds to one device-specific parameter that is configured on the host.The InformationBuffer associated with each such REMOTE_NDIS_SET_MSG has the following format. Note that the Offset values are relative to the beginning of the information buffer.Table 3-9: InformationBuffer for OID_GEN_RNDIS_CONFIG_PARAMETERThe device sends a REMOTE_NDIS_SET_CMPLT in response to each REMOTE_NDIS_SET_MSG, after applying the parameter value. If the parameter setting is acceptable, it returns a status ofRNDIS_STATUS_SUCCESS in the response. If the parameter setting is not acceptable, and the device cannot apply a useful default value for this parameter, then the device returns an appropriate error status value (see Table 2-2). If an error status is returned, then the host will initiate a Halt process (see Section 3) for the device.Device-specific parameters are expected to be configured in the Windows registry. The keys that define parameter values are typically created in the registry during the process of device installation; the list of keys, type information, default values and optional range of valid values are specified in the INF file for the device. For more information on using an INF to set up configuration parameters in the registry for network devices, please consult the Windows 2000 DDK.3.5REMOTE_NDIS_RESET_MSGA REMOTE_NDIS_RESET_MSG message is sent to a Remote NDIS device from a host via the control channel to soft-reset the device and return status. This message may be sent at any time that the device is in the rndis-initialized or rndis-data-initialized state. A Remote NDIS device will respond to aREMOTE_NDIS_RESET_MSG message with a status.3.5.1REMOTE_NDIS_RESET_MSG FormatTable 3-10: REMOTE_NDIS_RESET_MSG Message3.5.2Response to REMOTE_NDIS_RESET_MSGWhen the device receives REMOTE_NDIS_RESET_MSG, it performs a soft-reset and then sends REMOTE_NDIS_RESET_CMPLT to the host with the result status.Table 3-11: REMOTE_NDIS_RESET_CMPLT3.6REMOTE_NDIS_INDICATE_STATUS_MSGThe device may send REMOTE_NDIS_INDICATE_STATUS_MSG to the host via the control channel in an unsolicited fashion at any time that the device is in the rndis-initialized or rndis-data-initialized state. This message is used to indicate a change in the status of the device.REMOTE_NDIS_INDICATE_STATUS_MSG can also be used to indicate an error event, such as an unrecognized message.The most common use of REMOTE_NDIS_INDICATE_STATUS_MSG is to indicate the state of link for an 802.3 device. Status=RNDIS_STATUS_MEDIA_CONNECT indicates a transition from disconnected (e.g. no 802.3 link pulse) to connected state (802.3 link pulse detected); Status=RNDIS_STATUS_MEDIA_DISCONNECT indicates a transition from connected to disconnected state . The device must send REMOTE_NDIS_INDICATE_STATUS_MSG with one of these values every time that the 802.3 link state changes. No status buffer is required to return these two common indications.In the specific case where this is sent in response to a message that the device could not handle, the Status field must be set to RNDIS_STATUS_INVALID_DATA, and the status buffer is formatted as described in Table 3-12.If the error condition was caused by an Remote NDIS message, for example if the device didn’t understand a particular Remote NDIS message, then the device must append the original message at the end of the status message defined above. In this case, DiagStatus contains additional status about the error itself (e.g.RNDIS_STATUS_NOT_SUPPORTED) and ErrorOffset is the 0-based byte offset within the offending message at which the error was detected.Note that this message is used to report an error condition only in circumstances where the device is not able to generate a response message with appropriate status. Examples of appropriate usage are: (a) on receiving a message with unsupported message type (b) on receiving an REMOTE_NDIS_PACKET_MSG with unacceptable contents.3.6.1REMOTE_NDIS_INDICATE_STATUS_MSG FormatTable 3-12: REMOTE_NDIS_INDICATE_STATUS_MSG MessageTable 3-13: Rndis_Diagnostic_Info3.7REMOTE_NDIS_KEEPALIVE_MSGThe host sends REMOTE_NDIS_KEEPALIVE_MSG to the device via the control channel in order to check the health of the device. When the device is in the rndis-data-initialized state, the host sends this message periodically when there has been no other control or data traffic from the device to the host for the KeepAliveTimeoutPeriod. KeepAliveTimeoutPeriod is bus-dependent and is defined in the appropriate bus-mapping chapter.Upon receiving this message, the remote device must send back a response whose Status field indicates whether the device solicits a REMOTE_NDIS_RESET_MSG message from the host.The host will not send REMOTE_NDIS_KEEPALIVE_MSG until the KeepAliveTimeoutPeriod has elapsed since the last message received from the remote device. This avoids unnecessary exchange ofREMOTE_NDIS_KEEPALIVE_MSG messages when the communication channel is active.The device may optionally send this message to the host as well. For example, the device may use this message to trigger a response from the host for the purpose of computing round-trip delay time. If implemented, the device must send REMOTE_NDIS_KEEPALIVE_MSG via the control channel and only when in the rndis-initialized or rndis-data-initialized state.NOTE: The device does not need to perform any specific action if it stops seeingREMOTE_NDIS_KEEPALIVE_MSG messages from the host.3.7.1REMOTE_NDIS_KEEPALIVE_MSG FormatTable 3-14: REMOTE_NDIS_KEEPALIVE_MSG Message3.7.2Response to REMOTE_NDIS_KEEPALIVE_MSGThe device sends REMOTE_NDIS_KEEPALIVE_CMPLT to the host in response to aREMOTE_NDIS_KEEPALIVE_MSG. If the returned Status is not RNDIS_STATUS_SUCCESS, then the host will send REMOTE_NDIS_RESET_MSG to reset the device.Table 3-15: REMOTE_NDIS_KEEPALIVE_CMPLTIf the device implements the option of sending REMOTE_NDIS_KEEPALIVE_MSG, then the host will respond with REMOTE_NDIS_KEEPALIVE_CMPLT via the control channel.3.8Example Connectionless (802.3) Initialization SequenceThis section describes the general order of events that a device can expect upon startup as a Remote NDIS connectionless device. Because the basic operation of Remote NDIS is the same, regardless of the underlying bus, the require bus enumeration and start up process has been left out of the example.Table 3-16: Generic Connectionless Remote NDIS Initialization SequenceNote: real world operation will vary depending on version of Windows and NDIS.3.9Data Messages (REMOTE_NDIS_PACKET_MSG)A Remote NDIS device transfers NDIS packets, encapsulated as REMOTE_NDIS_PACKET_MSG across the data channel. REMOTE_NDIS_PACKET_MSG may contain out of band (OOB) data and/or per-packet information.3.9.1REMOTE_NDIS_PACKET_MSG FormatTable 3-17: REMOTE_NDIS_PACKET_MSG3.9.1.1Out-of-band dataEach REMOTE_NDIS_PACKET_MSG may contain one or more out-of-band data records. NumOOBDataElements indicates the number of out-of-band data records in this message. The out-of-band data records must appear in sequence. The OOBDataLength field indicates the byte length of the entire out-of-band data block. The OOBDataOffset field indicates the byte offset from the beginning of the DataOffset field to the beginning of the out-of-band data block. See the NDIS specification for more information about out-of-band packet data.Table 3-18defines the format of a single out-of-band data record.Table 3-18: Out of Band Data Record FormatNote: (N) is equal to the value of ClassInformationOffsetIf there are multiple out-of-band data blocks attached to a REMOTE_NDIS_PACKET_MSG, then each subsequent out-of-band data record must immediately follow the previous out-of-band record’s data. There is no out of band information currently defined for 802.3 devices.3.9.1.2Per-packet-info DataEach REMOTE_NDIS_PACKET_MSG may contain one or more per-packet-info data records. Per-packet-info is used to convey packet meta-data such as TCP checksum. See the NDIS specification for more information about per-packet info data.Table 3-19 defines the format of a per-packet-info data record.Table 3-19: Per-Packet Info Data Record FormatNOTE: (N) is equal to the value of PerPacketInformationOffsetIf there are multiple per-packet-info data blocks, then each subsequent per-packet-info data record must immediately follow the previous per-packet-info record’s data.3.9.2Multi-Packet TransfersMultiple REMOTE_NDIS_PACKET_MSG messages may be sent in a single transfer, in either direction. The maximum length of such a transfer is governed by the MaxTransferSize parameter passed in the REMOTE_NDIS_INITIALIZE_MSG and response messages. The host will also limit the number of REMOTE_NDIS_PACKET_MSGs it bundles into a single transfer to the value of the MaxPacketsPerTransfer parameter returned by the device in its response toREMOTE_NDIS_INITIALIZE_MSG.Concatenating multiple REMOTE_NDIS_PACKET_MSG elements forms a multi-packet message. Each individual REMOTE_NDIS_PACKET_MSG component is constructed as described above. The difference from the single-packet message case is that the MessageLength field in eachREMOTE_NDIS_PACKET_MSG header includes some additional padding bytes. These padding bytes are appended to all but the last REMOTE_NDIS_PACKET_MSG such that the succeedingREMOTE_NDIS_PACKET_MSG starts at an appropriate byte boundary. For messages sent from the device。