rndis document

This commit is contained in:
hathach 2013-10-27 15:42:31 +07:00
parent f941f88549
commit eb39d88360
3 changed files with 63 additions and 60 deletions

View File

@ -136,7 +136,7 @@ static rndis_msg_query_t msg_query_permanent_addr =
.type = RNDIS_MSG_QUERY, .type = RNDIS_MSG_QUERY,
.length = sizeof(rndis_msg_query_t)+6, .length = sizeof(rndis_msg_query_t)+6,
.request_id = 1, .request_id = 1,
.oid = OID_802_3_PERMANENT_ADDRESS, .oid = RNDIS_OID_802_3_PERMANENT_ADDRESS,
.buffer_length = 6, .buffer_length = 6,
.buffer_offset = 20, .buffer_offset = 20,
.oid_buffer = {0, 0, 0, 0, 0, 0} .oid_buffer = {0, 0, 0, 0, 0, 0}
@ -158,10 +158,10 @@ static rndis_msg_set_t msg_set_packet_filter =
.type = RNDIS_MSG_SET, .type = RNDIS_MSG_SET,
.length = sizeof(rndis_msg_set_t)+4, .length = sizeof(rndis_msg_set_t)+4,
.request_id = 1, .request_id = 1,
.oid = OID_GEN_CURRENT_PACKET_FILTER, .oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER,
.buffer_length = 4, .buffer_length = 4,
.buffer_offset = 20, .buffer_offset = 20,
.oid_buffer = {NDIS_PACKET_TYPE_DIRECTED | NDIS_PACKET_TYPE_MULTICAST | NDIS_PACKET_TYPE_BROADCAST, 0, 0, 0} .oid_buffer = {RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_MULTICAST | RNDIS_PACKET_TYPE_BROADCAST, 0, 0, 0}
}; };
static rndis_msg_set_cmplt_t msg_set_packet_filter_cmplt = static rndis_msg_set_cmplt_t msg_set_packet_filter_cmplt =
@ -249,7 +249,7 @@ tusb_error_t stub_control_xfer(uint8_t addr, uint8_t bmRequestType, uint8_t bReq
memcpy(data, &msg_init_cmplt, sizeof(rndis_msg_initialize_cmplt_t)); memcpy(data, &msg_init_cmplt, sizeof(rndis_msg_initialize_cmplt_t));
break; break;
// query for OID_802_3_PERMANENT_ADDRESS // query for RNDIS_OID_802_3_PERMANENT_ADDRESS
case 1*2+0: case 1*2+0:
TEST_ASSERT_EQUAL(bmrequest_send, bmRequestType); TEST_ASSERT_EQUAL(bmrequest_send, bmRequestType);
TEST_ASSERT_EQUAL(SEND_ENCAPSULATED_COMMAND, bRequest); TEST_ASSERT_EQUAL(SEND_ENCAPSULATED_COMMAND, bRequest);
@ -257,14 +257,14 @@ tusb_error_t stub_control_xfer(uint8_t addr, uint8_t bmRequestType, uint8_t bReq
TEST_ASSERT_EQUAL_HEX8_ARRAY(&msg_query_permanent_addr, data, wLength); TEST_ASSERT_EQUAL_HEX8_ARRAY(&msg_query_permanent_addr, data, wLength);
break; break;
case 1*2+1: // query complete for OID_802_3_PERMANENT_ADDRESS case 1*2+1: // query complete for RNDIS_OID_802_3_PERMANENT_ADDRESS
TEST_ASSERT_EQUAL(bmrequest_get, bmRequestType); TEST_ASSERT_EQUAL(bmrequest_get, bmRequestType);
TEST_ASSERT_EQUAL(GET_ENCAPSULATED_RESPONSE, bRequest); TEST_ASSERT_EQUAL(GET_ENCAPSULATED_RESPONSE, bRequest);
TEST_ASSERT( wLength >= 0x0400 ); // Microsoft Specs TEST_ASSERT( wLength >= 0x0400 ); // Microsoft Specs
memcpy(data, &msg_query_permanent_addr_cmplt, sizeof(rndis_msg_query_cmplt_t) + 6); memcpy(data, &msg_query_permanent_addr_cmplt, sizeof(rndis_msg_query_cmplt_t) + 6);
break; break;
// set OID_GEN_CURRENT_PACKET_FILTER to DIRECTED | MULTICAST | BROADCAST // set RNDIS_OID_GEN_CURRENT_PACKET_FILTER to DIRECTED | MULTICAST | BROADCAST
case 2*2+0: case 2*2+0:
TEST_ASSERT_EQUAL(bmrequest_send, bmRequestType); TEST_ASSERT_EQUAL(bmrequest_send, bmRequestType);
TEST_ASSERT_EQUAL(SEND_ENCAPSULATED_COMMAND, bRequest); TEST_ASSERT_EQUAL(SEND_ENCAPSULATED_COMMAND, bRequest);
@ -272,7 +272,7 @@ tusb_error_t stub_control_xfer(uint8_t addr, uint8_t bmRequestType, uint8_t bReq
TEST_ASSERT_EQUAL_HEX8_ARRAY(&msg_set_packet_filter, data, wLength); TEST_ASSERT_EQUAL_HEX8_ARRAY(&msg_set_packet_filter, data, wLength);
break; break;
case 2*2+1: // query complete for OID_802_3_PERMANENT_ADDRESS case 2*2+1: // query complete for RNDIS_OID_802_3_PERMANENT_ADDRESS
TEST_ASSERT_EQUAL(bmrequest_get, bmRequestType); TEST_ASSERT_EQUAL(bmrequest_get, bmRequestType);
TEST_ASSERT_EQUAL(GET_ENCAPSULATED_RESPONSE, bRequest); TEST_ASSERT_EQUAL(GET_ENCAPSULATED_RESPONSE, bRequest);
TEST_ASSERT( wLength >= 0x0400 ); // Microsoft Specs TEST_ASSERT( wLength >= 0x0400 ); // Microsoft Specs

View File

@ -234,59 +234,62 @@ typedef struct {
// NDIS Object ID // NDIS Object ID
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
//------------- General Required OIDs -------------// /// NDIS Object ID
#define OID_GEN_SUPPORTED_LIST 0x00010101 typedef enum {
#define OID_GEN_HARDWARE_STATUS 0x00010102 //------------- General Required OIDs -------------//
#define OID_GEN_MEDIA_SUPPORTED 0x00010103 RNDIS_OID_GEN_SUPPORTED_LIST = 0x00010101, ///< List of supported OIDs
#define OID_GEN_MEDIA_IN_USE 0x00010104 RNDIS_OID_GEN_HARDWARE_STATUS = 0x00010102, ///< Hardware status
#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 RNDIS_OID_GEN_MEDIA_SUPPORTED = 0x00010103, ///< Media types supported (encoded)
#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 RNDIS_OID_GEN_MEDIA_IN_USE = 0x00010104, ///< Media types in use (encoded)
#define OID_GEN_LINK_SPEED 0x00010107 RNDIS_OID_GEN_MAXIMUM_LOOKAHEAD = 0x00010105, ///<
#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE = 0x00010106, ///< Maximum frame size in bytes
#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 RNDIS_OID_GEN_LINK_SPEED = 0x00010107, ///< Link speed in units of 100 bps
#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A RNDIS_OID_GEN_TRANSMIT_BUFFER_SPACE = 0x00010108, ///< Transmit buffer space
#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B RNDIS_OID_GEN_RECEIVE_BUFFER_SPACE = 0x00010109, ///< Receive buffer space
#define OID_GEN_VENDOR_ID 0x0001010C RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE = 0x0001010A, ///< Minimum amount of storage, in bytes, that a single packet occupies in the transmit buffer space of the NIC
#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE = 0x0001010B, ///< Amount of storage, in bytes, that a single packet occupies in the receive buffer space of the NIC
#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E RNDIS_OID_GEN_VENDOR_ID = 0x0001010C, ///< Vendor NIC code
#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F RNDIS_OID_GEN_VENDOR_DESCRIPTION = 0x0001010D, ///< Vendor network card description
#define OID_GEN_DRIVER_VERSION 0x00010110 RNDIS_OID_GEN_CURRENT_PACKET_FILTER = 0x0001010E, ///< Current packet filter (encoded)
#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 RNDIS_OID_GEN_CURRENT_LOOKAHEAD = 0x0001010F, ///< Current lookahead size in bytes
#define OID_GEN_PROTOCOL_OPTIONS 0x00010112 RNDIS_OID_GEN_DRIVER_VERSION = 0x00010110, ///< NDIS version number used by the driver
#define OID_GEN_MAC_OPTIONS 0x00010113 RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE = 0x00010111, ///< Maximum total packet length in bytes
#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 RNDIS_OID_GEN_PROTOCOL_OPTIONS = 0x00010112, ///< Optional protocol flags (encoded)
#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 RNDIS_OID_GEN_MAC_OPTIONS = 0x00010113, ///< Optional NIC flags (encoded)
RNDIS_OID_GEN_MEDIA_CONNECT_STATUS = 0x00010114, ///< Whether the NIC is connected to the network
RNDIS_OID_GEN_MAXIMUM_SEND_PACKETS = 0x00010115, ///< The maximum number of send packets the driver can accept per call to its MiniportSendPacketsfunction
//------------- General Optional OIDs -------------// //------------- General Optional OIDs -------------//
#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 RNDIS_OID_GEN_VENDOR_DRIVER_VERSION = 0x00010116, ///< Vendor-assigned version number of the driver
#define OID_GEN_SUPPORTED_GUIDS 0x00010117 RNDIS_OID_GEN_SUPPORTED_GUIDS = 0x00010117, ///< The custom GUIDs (Globally Unique Identifier) supported by the miniport driver
#define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118 // Set only RNDIS_OID_GEN_NETWORK_LAYER_ADDRESSES = 0x00010118, ///< List of network-layer addresses associated with the binding between a transport and the driver
#define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119 // Set only RNDIS_OID_GEN_TRANSPORT_HEADER_OFFSET = 0x00010119, ///< Size of packets' additional headers
#define OID_GEN_MEDIA_CAPABILITIES 0x00010201 RNDIS_OID_GEN_MEDIA_CAPABILITIES = 0x00010201, ///<
#define OID_GEN_PHYSICAL_MEDIUM 0x00010202 RNDIS_OID_GEN_PHYSICAL_MEDIUM = 0x00010202, ///< Physical media supported by the miniport driver (encoded)
//------------- 802.3 Objects (Ethernet) -------------// //------------- 802.3 Objects (Ethernet) -------------//
#define OID_802_3_PERMANENT_ADDRESS 0x01010101 RNDIS_OID_802_3_PERMANENT_ADDRESS = 0x01010101, ///< Permanent station address
#define OID_802_3_CURRENT_ADDRESS 0x01010102 RNDIS_OID_802_3_CURRENT_ADDRESS = 0x01010102, ///< Current station address
#define OID_802_3_MULTICAST_LIST 0x01010103 RNDIS_OID_802_3_MULTICAST_LIST = 0x01010103, ///< Current multicast address list
#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 RNDIS_OID_802_3_MAXIMUM_LIST_SIZE = 0x01010104, ///< Maximum size of multicast address list
} rndis_oid_type_t;
// /// RNDIS Packet Filter Bits \ref RNDIS_OID_GEN_CURRENT_PACKET_FILTER.
// Ndis Packet Filter Bits (OID_GEN_CURRENT_PACKET_FILTER). typedef enum {
// RNDIS_PACKET_TYPE_DIRECTED = 0x00000001, ///< Directed packets. Directed packets contain a destination address equal to the station address of the NIC.
#define NDIS_PACKET_TYPE_DIRECTED 0x00000001 RNDIS_PACKET_TYPE_MULTICAST = 0x00000002, ///< Multicast address packets sent to addresses in the multicast address list.
#define NDIS_PACKET_TYPE_MULTICAST 0x00000002 RNDIS_PACKET_TYPE_ALL_MULTICAST = 0x00000004, ///< All multicast address packets, not just the ones enumerated in the multicast address list.
#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 RNDIS_PACKET_TYPE_BROADCAST = 0x00000008, ///< Broadcast packets.
#define NDIS_PACKET_TYPE_BROADCAST 0x00000008 RNDIS_PACKET_TYPE_SOURCE_ROUTING = 0x00000010, ///< All source routing packets. If the protocol driver sets this bit, the NDIS library attempts to act as a source routing bridge.
#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 RNDIS_PACKET_TYPE_PROMISCUOUS = 0x00000020, ///< Specifies all packets regardless of whether VLAN filtering is enabled or not and whether the VLAN identifier matches or not.
#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 RNDIS_PACKET_TYPE_SMT = 0x00000040, ///< SMT packets that an FDDI NIC receives.
#define NDIS_PACKET_TYPE_SMT 0x00000040 RNDIS_PACKET_TYPE_ALL_LOCAL = 0x00000080, ///< All packets sent by installed protocols and all packets indicated by the NIC that is identified by a given NdisBindingHandle.
#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 RNDIS_PACKET_TYPE_GROUP = 0x00001000, ///< Packets sent to the current group address.
#define NDIS_PACKET_TYPE_GROUP 0x00001000 RNDIS_PACKET_TYPE_ALL_FUNCTIONAL = 0x00002000, ///< All functional address packets, not just the ones in the current functional address.
#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000 RNDIS_PACKET_TYPE_FUNCTIONAL = 0x00004000, ///< Functional address packets sent to addresses included in the current functional address.
#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00004000 RNDIS_PACKET_TYPE_MAC_FRAME = 0x00008000, ///< NIC driver frames that a Token Ring NIC receives.
#define NDIS_PACKET_TYPE_MAC_FRAME 0x00008000 RNDIS_PACKET_TYPE_NO_LOCAL = 0x00010000,
#define NDIS_PACKET_TYPE_NO_LOCAL 0x00010000 } rndis_packet_filter_type_t;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -152,7 +152,7 @@ static rndis_msg_query_t const msg_query_permanent_addr =
.type = RNDIS_MSG_QUERY, .type = RNDIS_MSG_QUERY,
.length = sizeof(rndis_msg_query_t)+6, .length = sizeof(rndis_msg_query_t)+6,
.request_id = 1, .request_id = 1,
.oid = OID_802_3_PERMANENT_ADDRESS, .oid = RNDIS_OID_802_3_PERMANENT_ADDRESS,
.buffer_length = 6, .buffer_length = 6,
.buffer_offset = 20, .buffer_offset = 20,
}; };
@ -162,7 +162,7 @@ static rndis_msg_set_t const msg_set_packet_filter =
.type = RNDIS_MSG_SET, .type = RNDIS_MSG_SET,
.length = sizeof(rndis_msg_set_t)+4, .length = sizeof(rndis_msg_set_t)+4,
.request_id = 1, .request_id = 1,
.oid = OID_GEN_CURRENT_PACKET_FILTER, .oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER,
.buffer_length = 4, .buffer_length = 4,
.buffer_offset = 20, .buffer_offset = 20,
}; };
@ -208,7 +208,7 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
//------------- Set OID_GEN_CURRENT_PACKET_FILTER to (DIRECTED | MULTICAST | BROADCAST) -------------// //------------- Set OID_GEN_CURRENT_PACKET_FILTER to (DIRECTED | MULTICAST | BROADCAST) -------------//
memcpy(msg_payload, &msg_set_packet_filter, sizeof(rndis_msg_set_t)); memcpy(msg_payload, &msg_set_packet_filter, sizeof(rndis_msg_set_t));
memclr_(msg_payload + sizeof(rndis_msg_set_t), 4); // 4 bytes for filter flags memclr_(msg_payload + sizeof(rndis_msg_set_t), 4); // 4 bytes for filter flags
((rndis_msg_set_t*) msg_payload)->oid_buffer[0] = (NDIS_PACKET_TYPE_DIRECTED | NDIS_PACKET_TYPE_MULTICAST | NDIS_PACKET_TYPE_BROADCAST); ((rndis_msg_set_t*) msg_payload)->oid_buffer[0] = (RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_MULTICAST | RNDIS_PACKET_TYPE_BROADCAST);
OSAL_SUBTASK_INVOKED_AND_WAIT( OSAL_SUBTASK_INVOKED_AND_WAIT(
send_message_get_response_subtask( dev_addr, p_cdc, send_message_get_response_subtask( dev_addr, p_cdc,