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
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _nx_tcp_socket_transmit_configure PORTABLE C */
36 /* 6.4.0 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function sets up various parameters associated with the */
44 /* socket's transmit operation. */
45 /* */
46 /* INPUT */
47 /* */
48 /* socket_ptr Pointer to TCP socket */
49 /* max_queue_depth Maximum number of transmit */
50 /* packets that can be queued */
51 /* for the socket */
52 /* timeout Number of timer ticks for the */
53 /* initial transmit timeout */
54 /* max_retries Maximum number of retries */
55 /* timeout_shift Factor to be applied to */
56 /* subsequent timeouts, a */
57 /* value of 0 causes identical */
58 /* subsequent timeouts */
59 /* */
60 /* OUTPUT */
61 /* */
62 /* status Completion status */
63 /* */
64 /* CALLS */
65 /* */
66 /* tx_mutex_get Obtain a protection mutex */
67 /* tx_mutex_put Release a protection mutex */
68 /* */
69 /* CALLED BY */
70 /* */
71 /* Application Code */
72 /* */
73 /* RELEASE HISTORY */
74 /* */
75 /* DATE NAME DESCRIPTION */
76 /* */
77 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
78 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
79 /* resulting in version 6.1 */
80 /* 12-31-2023 Yajun Xia Modified comment(s), */
81 /* fixed compiler warning, */
82 /* resulting in version 6.4.0 */
83 /* */
84 /**************************************************************************/
_nx_tcp_socket_transmit_configure(NX_TCP_SOCKET * socket_ptr,ULONG max_queue_depth,ULONG timeout,ULONG max_retries,ULONG timeout_shift)85 UINT _nx_tcp_socket_transmit_configure(NX_TCP_SOCKET *socket_ptr, ULONG max_queue_depth,
86 ULONG timeout, ULONG max_retries, ULONG timeout_shift)
87 {
88
89 NX_IP *ip_ptr;
90
91
92 /* Pickup the associated IP structure. */
93 ip_ptr = socket_ptr -> nx_tcp_socket_ip_ptr;
94
95 /* If trace is enabled, insert this event into the trace buffer. */
96 NX_TRACE_IN_LINE_INSERT(NX_TRACE_TCP_SOCKET_TRANSMIT_CONFIGURE, ip_ptr, socket_ptr, max_queue_depth, timeout, NX_TRACE_TCP_EVENTS, 0, 0);
97
98 /* Obtain the IP mutex so we can initiate accept processing for this socket. */
99 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
100
101 /* Setup the socket with the new transmit parameters. */
102 socket_ptr -> nx_tcp_socket_timeout_rate = timeout;
103 socket_ptr -> nx_tcp_socket_timeout_max_retries = max_retries;
104 socket_ptr -> nx_tcp_socket_timeout_shift = (UCHAR)timeout_shift;
105 socket_ptr -> nx_tcp_socket_transmit_queue_maximum_default = max_queue_depth;
106 socket_ptr -> nx_tcp_socket_transmit_queue_maximum = max_queue_depth;
107
108 /* Release the IP protection. */
109 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
110
111 /* Return completion status. */
112 return(NX_SUCCESS);
113 }
114
115