1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 /**************************************************************************/ 12 /**************************************************************************/ 13 /** */ 14 /** USBX Component */ 15 /** */ 16 /** Device CDC_ECM Class */ 17 /** */ 18 /**************************************************************************/ 19 /**************************************************************************/ 20 21 #define UX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "ux_api.h" 27 #include "ux_device_class_cdc_ecm.h" 28 #include "ux_device_stack.h" 29 30 /**************************************************************************/ 31 /* */ 32 /* FUNCTION RELEASE */ 33 /* */ 34 /* _ux_device_class_cdc_ecm_control_request PORTABLE C */ 35 /* 6.1.12 */ 36 /* AUTHOR */ 37 /* */ 38 /* Chaoqiong Xiao, Microsoft Corporation */ 39 /* */ 40 /* DESCRIPTION */ 41 /* */ 42 /* This function manages the based sent by the host on the control */ 43 /* endpoints with a CLASS or VENDOR SPECIFIC type. */ 44 /* */ 45 /* INPUT */ 46 /* */ 47 /* cdc_ecm Pointer to cdc_ecm class */ 48 /* */ 49 /* OUTPUT */ 50 /* */ 51 /* None */ 52 /* */ 53 /* CALLS */ 54 /* */ 55 /* _ux_utility_short_get Get 16-bit value */ 56 /* */ 57 /* CALLED BY */ 58 /* */ 59 /* CDC_ECM Class */ 60 /* */ 61 /* RELEASE HISTORY */ 62 /* */ 63 /* DATE NAME DESCRIPTION */ 64 /* */ 65 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 66 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 67 /* resulting in version 6.1 */ 68 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */ 69 /* fixed parameter/variable */ 70 /* names conflict C++ keyword, */ 71 /* resulting in version 6.1.12 */ 72 /* */ 73 /**************************************************************************/ _ux_device_class_cdc_ecm_control_request(UX_SLAVE_CLASS_COMMAND * command)74UINT _ux_device_class_cdc_ecm_control_request(UX_SLAVE_CLASS_COMMAND *command) 75 { 76 77 UX_SLAVE_TRANSFER *transfer_request; 78 UX_SLAVE_DEVICE *device; 79 ULONG request; 80 ULONG request_value; 81 UX_SLAVE_CLASS *class_ptr; 82 UX_SLAVE_CLASS_CDC_ECM *cdc_ecm; 83 84 /* Get the pointer to the device. */ 85 device = &_ux_system_slave -> ux_system_slave_device; 86 87 /* Get the pointer to the transfer request associated with the control endpoint. */ 88 transfer_request = &device -> ux_slave_device_control_endpoint.ux_slave_endpoint_transfer_request; 89 90 /* Extract all necessary fields of the request. */ 91 request = *(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_REQUEST); 92 request_value = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_VALUE); 93 94 /* Get the class container. */ 95 class_ptr = command -> ux_slave_class_command_class_ptr; 96 97 /* Get the cdc_ecm instance from this class container. */ 98 cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance; 99 100 /* Here we proceed only the standard request we know of at the device level. */ 101 switch (request) 102 { 103 104 case UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_MULTICAST_FILTER : 105 106 /* Save the multicast filter. */ 107 cdc_ecm -> ux_slave_class_cdc_ecm_ethernet_multicast_filter = request_value; 108 break ; 109 110 case UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_POWER_MANAGEMENT_FILTER : 111 112 /* Save the power management filter. */ 113 cdc_ecm -> ux_slave_class_cdc_ecm_ethernet_power_management_filter = request_value; 114 break ; 115 116 case UX_DEVICE_CLASS_CDC_ECM_SET_ETHERNET_PACKET_FILTER : 117 118 /* Save the packet filter. */ 119 cdc_ecm -> ux_slave_class_cdc_ecm_ethernet_packet_filter = request_value; 120 break ; 121 122 case UX_DEVICE_CLASS_CDC_ECM_GET_ETHERNET_POWER_MANAGEMENT_FILTER : 123 default: 124 125 /* Unknown function. It's not handled. */ 126 return(UX_ERROR); 127 } 128 129 /* It's handled. */ 130 return(UX_SUCCESS); 131 } 132 133