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