30#if ( CFG_TUD_ENABLED && CFG_TUD_ECM_RNDIS )
36#include "rndis_protocol.h"
61#define CFG_TUD_NET_PACKET_PREFIX_LEN sizeof(rndis_data_packet_t)
62#define CFG_TUD_NET_PACKET_SUFFIX_LEN 0
64CFG_TUD_MEM_SECTION CFG_TUSB_MEM_ALIGN tu_static
65uint8_t
received[CFG_TUD_NET_PACKET_PREFIX_LEN + CFG_TUD_NET_MTU + CFG_TUD_NET_PACKET_PREFIX_LEN];
67CFG_TUD_MEM_SECTION CFG_TUSB_MEM_ALIGN tu_static
68uint8_t
transmitted[CFG_TUD_NET_PACKET_PREFIX_LEN + CFG_TUD_NET_MTU + CFG_TUD_NET_PACKET_PREFIX_LEN];
98CFG_TUD_MEM_SECTION CFG_TUSB_MEM_ALIGN tu_static
union
125 uint8_t
const rhport = 0;
152 bool const is_rndis = (TUD_RNDIS_ITF_CLASS == itf_desc->
bInterfaceClass &&
160 TU_VERIFY(is_rndis || is_ecm, 0);
304 default:
return false;
324 rndis_generic_msg_t *rndis_msg = (rndis_generic_msg_t *) ((
void*)
notify.rndis_buf);
325 uint32_t msglen = tu_le32toh(rndis_msg->MessageLength);
326 TU_ASSERT(msglen <=
sizeof(
notify.rndis_buf));
337 default:
return false;
368 rndis_data_packet_t *r = (rndis_data_packet_t *) ((
void*) pnt);
369 if (len >=
sizeof(rndis_data_packet_t))
370 if ( (r->MessageType == REMOTE_NDIS_PACKET_MSG) && (r->MessageLength <= len))
371 if ( (r->DataOffset + offsetof(rndis_data_packet_t, DataOffset) + r->DataLength) <= len)
373 pnt = &
received[r->DataOffset + offsetof(rndis_data_packet_t, DataOffset)];
374 size = r->DataLength;
401 if ( xferred_bytes && (0 == (xferred_bytes % CFG_TUD_NET_ENDPOINT_SIZE)) )
442 rndis_data_packet_t *hdr = (rndis_data_packet_t *) ((
void*)
transmitted);
443 memset(hdr, 0,
sizeof(rndis_data_packet_t));
444 hdr->MessageType = REMOTE_NDIS_PACKET_MSG;
445 hdr->MessageLength = len;
446 hdr->DataOffset =
sizeof(rndis_data_packet_t) - offsetof(rndis_data_packet_t, DataOffset);
447 hdr->DataLength = len -
sizeof(rndis_data_packet_t);
void netd_reset(uint8_t rhport)
CFG_TUD_MEM_SECTION CFG_TUSB_MEM_ALIGN tu_static uint8_t transmitted[CFG_TUD_NET_PACKET_PREFIX_LEN+CFG_TUD_NET_MTU+CFG_TUD_NET_PACKET_PREFIX_LEN]
void netd_report(uint8_t *buf, uint16_t len)
CFG_TUD_MEM_SECTION tu_static netd_interface_t _netd_itf
uint16_t netd_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len)
bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
static void ecm_report(bool nc)
CFG_TUD_MEM_SECTION CFG_TUSB_MEM_ALIGN tu_static union @45 notify
tu_static const struct ecm_notify_struct ecm_notify_csc
void tud_network_xmit(void *ref, uint16_t arg)
void rndis_class_set_handler(uint8_t *data, int size)
static void handle_incoming_packet(uint32_t len)
void tud_network_recv_renew(void)
bool netd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const *request)
struct ecm_notify_struct ecm_buf
static void do_in_xfer(uint8_t *buf, uint16_t len)
CFG_TUD_MEM_SECTION CFG_TUSB_MEM_ALIGN tu_static uint8_t received[CFG_TUD_NET_PACKET_PREFIX_LEN+CFG_TUD_NET_MTU+CFG_TUD_NET_PACKET_PREFIX_LEN]
tu_static const struct ecm_notify_struct ecm_notify_nc
bool tud_network_can_xmit(uint16_t size)
bool tud_network_recv_cb(const uint8_t *src, uint16_t size)
void tud_network_init_cb(void)
uint16_t tud_network_xmit_cb(uint8_t *dst, void *ref, uint16_t arg)
AUDIO Channel Cluster Descriptor (4.1)
struct TU_ATTR_PACKED::@16::TU_ATTR_PACKED bmRequestType_bit
uint8_t bInterfaceClass
Class code (assigned by the USB-IF).
uint8_t bInterfaceSubClass
Subclass code (assigned by the USB-IF). These codes are qualified by the value of the bInterfaceCla...
uint8_t bRequest
Request type audio_cs_req_t.
uint8_t bInterfaceProtocol
Protocol code (assigned by the USB). These codes are qualified by the value of the bInterfaceClass ...
uint8_t bInterfaceNumber
Number of this interface. Zero-based value identifying the index in the array of concurrent interface...
tusb_control_request_t header
uint8_t const * ecm_desc_epdata
static TU_ATTR_ALWAYS_INLINE uint8_t tu_desc_len(void const *desc)
struct TU_ATTR_PACKED tusb_desc_endpoint_t
USB Endpoint Descriptor.
static TU_ATTR_ALWAYS_INLINE uint8_t tu_desc_type(void const *desc)
struct TU_ATTR_PACKED tusb_desc_interface_t
USB Interface Descriptor.
static TU_ATTR_ALWAYS_INLINE uint8_t const * tu_desc_next(void const *desc)
bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *desc_ep)
bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr)
bool usbd_open_edpt_pair(uint8_t rhport, uint8_t const *p_desc, uint8_t ep_count, uint8_t xfer_type, uint8_t *ep_out, uint8_t *ep_in)
bool tud_control_xfer(uint8_t rhport, tusb_control_request_t const *request, void *buffer, uint16_t len)
bool tud_control_status(uint8_t rhport, tusb_control_request_t const *request)
CFG_TUH_MEM_ALIGN tusb_control_request_t request