1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** USBX Component */
16 /** */
17 /** Device RNDIS Class */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define UX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "ux_api.h"
28 #include "ux_device_class_rndis.h"
29 #include "ux_device_stack.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _ux_device_class_rndis_msg_keep_alive PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function analyzes and replies to the MSG KEEP_ALIVE */
45 /* */
46 /* INPUT */
47 /* */
48 /* rndis Pointer to rndis class */
49 /* transfer_request Pointer to the transfer request */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* None */
54 /* */
55 /* CALLS */
56 /* */
57 /* _ux_utility_long_get Get 32-bit value */
58 /* _ux_utility_long_put Put 32-bit value */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* RNDIS Class */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
69 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
70 /* resulting in version 6.1 */
71 /* */
72 /**************************************************************************/
_ux_device_class_rndis_msg_keep_alive(UX_SLAVE_CLASS_RNDIS * rndis,UX_SLAVE_TRANSFER * transfer_request)73 UINT _ux_device_class_rndis_msg_keep_alive(UX_SLAVE_CLASS_RNDIS *rndis, UX_SLAVE_TRANSFER *transfer_request)
74 {
75
76 UCHAR *rndis_msg;
77 UCHAR *rndis_response;
78
79 /* If trace is enabled, insert this event into the trace buffer. */
80 UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_RNDIS_MSG_KEEP_ALIVE, rndis, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
81
82 /* Get the pointer to the RNDIS message. */
83 rndis_msg = transfer_request -> ux_slave_transfer_request_data_pointer;
84
85 /* Get the request ID and keep it for the response. */
86 rndis -> ux_slave_class_rndis_request_id = _ux_utility_long_get(rndis_msg + UX_DEVICE_CLASS_RNDIS_MSG_KEEP_ALIVE_REQUEST_ID);
87
88 /* Now prepare the response. */
89 rndis_response = rndis -> ux_slave_class_rndis_response;
90
91 /* First store the command. */
92 _ux_utility_long_put(rndis_response + UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_MESSAGE_TYPE, UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE);
93
94 /* Then the length of the response. */
95 _ux_utility_long_put(rndis_response + UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_MESSAGE_LENGTH, UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_RESPONSE_LENGTH);
96
97 /* Store the request ID. */
98 _ux_utility_long_put(rndis_response + UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_REQUEST_ID, rndis -> ux_slave_class_rndis_request_id);
99
100 /* Force the status to SUCCESS. */
101 _ux_utility_long_put(rndis_response + UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_STATUS, UX_DEVICE_CLASS_RNDIS_STATUS_SUCCESS);
102
103 /* Set the response length. */
104 rndis -> ux_slave_class_rndis_response_length = UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_RESPONSE_LENGTH;
105
106 /* We are done. Return UX_SUCCESS. */
107 return(UX_SUCCESS);
108 }
109
110