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 /**                                                                       */
16 /** NetX Component                                                        */
17 /**                                                                       */
18 /**   Transmission Control Protocol (TCP)                                 */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "nx_api.h"
29 #include "nx_tcp.h"
30 
31 /* Bring in externs for caller checking code.  */
32 
33 NX_CALLER_CHECKING_EXTERNS
34 
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _nxe_tcp_socket_transmit_configure                  PORTABLE C      */
41 /*                                                           6.1          */
42 /*  AUTHOR                                                                */
43 /*                                                                        */
44 /*    Yuxin Zhou, Microsoft Corporation                                   */
45 /*                                                                        */
46 /*  DESCRIPTION                                                           */
47 /*                                                                        */
48 /*    This function checks for errors in the TCP socket transmit          */
49 /*    configure function call.                                            */
50 /*                                                                        */
51 /*  INPUT                                                                 */
52 /*                                                                        */
53 /*    socket_ptr                            Pointer to TCP socket         */
54 /*    max_queue_depth                       Maximum number of transmit    */
55 /*                                            packets that can be queued  */
56 /*                                            for the socket              */
57 /*    timeout                               Number of timer ticks for the */
58 /*                                            initial transmit timeout    */
59 /*    max_retries                           Maximum number of retries     */
60 /*    timeout_shift                         Factor to be applied to       */
61 /*                                            subsequent timeouts, a      */
62 /*                                            value of 0 causes identical */
63 /*                                            subsequent timeouts         */
64 /*                                                                        */
65 /*  OUTPUT                                                                */
66 /*                                                                        */
67 /*    status                                Completion status             */
68 /*                                                                        */
69 /*  CALLS                                                                 */
70 /*                                                                        */
71 /*    _nx_tcp_socket_transmit_configure     Actual transmit configure     */
72 /*                                            service                     */
73 /*                                                                        */
74 /*  CALLED BY                                                             */
75 /*                                                                        */
76 /*    Application Code                                                    */
77 /*                                                                        */
78 /*  RELEASE HISTORY                                                       */
79 /*                                                                        */
80 /*    DATE              NAME                      DESCRIPTION             */
81 /*                                                                        */
82 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
83 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
84 /*                                            resulting in version 6.1    */
85 /*                                                                        */
86 /**************************************************************************/
_nxe_tcp_socket_transmit_configure(NX_TCP_SOCKET * socket_ptr,ULONG max_queue_depth,ULONG timeout,ULONG max_retries,ULONG timeout_shift)87 UINT  _nxe_tcp_socket_transmit_configure(NX_TCP_SOCKET *socket_ptr, ULONG max_queue_depth,
88                                          ULONG timeout, ULONG max_retries, ULONG timeout_shift)
89 {
90 
91 UINT status;
92 
93 
94     /* Check for invalid input pointer.  */
95     if ((socket_ptr == NX_NULL) || (socket_ptr -> nx_tcp_socket_id != NX_TCP_ID))
96     {
97         return(NX_PTR_ERROR);
98     }
99 
100     /* Check for valid options.  */
101     if (!max_queue_depth)
102     {
103         return(NX_OPTION_ERROR);
104     }
105 
106     /* Check to see if TCP is enabled.  */
107     if (!(socket_ptr -> nx_tcp_socket_ip_ptr) -> nx_ip_tcp_packet_receive)
108     {
109         return(NX_NOT_ENABLED);
110     }
111 
112     /* Check for appropriate caller.  */
113     NX_INIT_AND_THREADS_CALLER_CHECKING
114 
115     /* Call actual socket transmit configure service.  */
116     status =  _nx_tcp_socket_transmit_configure(socket_ptr, max_queue_depth,
117                                                 timeout, max_retries, timeout_shift);
118 
119     /* Return completion status.  */
120     return(status);
121 }
122 
123