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
32 /* Bring in externs for caller checking code. */
33 NX_CALLER_CHECKING_EXTERNS
34
35
36 /**************************************************************************/
37 /* */
38 /* FUNCTION RELEASE */
39 /* */
40 /* _nxe_tcp_socket_info_get 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 socket information get */
49 /* function call. */
50 /* */
51 /* INPUT */
52 /* */
53 /* socket_ptr Pointer to the TCP socket */
54 /* tcp_packets_sent Destination for number of */
55 /* packets sent */
56 /* tcp_bytes_sent Destination for number of */
57 /* bytes sent */
58 /* tcp_packets_received Destination for number of */
59 /* packets received */
60 /* tcp_bytes_received Destination for number of */
61 /* bytes received */
62 /* tcp_retransmit_packets Destination for number of */
63 /* retransmit packets */
64 /* tcp_packets_queued Destination for number of */
65 /* receive packets queued */
66 /* tcp_checksum_errors Destination for number of */
67 /* checksum errors */
68 /* tcp_socket_state Destination for the current */
69 /* socket state */
70 /* tcp_transmit_queue_depth Destination for number of */
71 /* sockets still in transmit */
72 /* queue */
73 /* tcp_transmit_window Destination for number of */
74 /* bytes in transmit window */
75 /* tcp_receive_window Destination for number of */
76 /* bytes in receive window */
77 /* */
78 /* OUTPUT */
79 /* */
80 /* status Completion status */
81 /* */
82 /* CALLS */
83 /* */
84 /* _nx_tcp_socket_info_get Actual socket information get */
85 /* function */
86 /* */
87 /* CALLED BY */
88 /* */
89 /* Application Code */
90 /* */
91 /* RELEASE HISTORY */
92 /* */
93 /* DATE NAME DESCRIPTION */
94 /* */
95 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
96 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
97 /* resulting in version 6.1 */
98 /* */
99 /**************************************************************************/
_nxe_tcp_socket_info_get(NX_TCP_SOCKET * socket_ptr,ULONG * tcp_packets_sent,ULONG * tcp_bytes_sent,ULONG * tcp_packets_received,ULONG * tcp_bytes_received,ULONG * tcp_retransmit_packets,ULONG * tcp_packets_queued,ULONG * tcp_checksum_errors,ULONG * tcp_socket_state,ULONG * tcp_transmit_queue_depth,ULONG * tcp_transmit_window,ULONG * tcp_receive_window)100 UINT _nxe_tcp_socket_info_get(NX_TCP_SOCKET *socket_ptr, ULONG *tcp_packets_sent, ULONG *tcp_bytes_sent,
101 ULONG *tcp_packets_received, ULONG *tcp_bytes_received,
102 ULONG *tcp_retransmit_packets, ULONG *tcp_packets_queued,
103 ULONG *tcp_checksum_errors, ULONG *tcp_socket_state,
104 ULONG *tcp_transmit_queue_depth, ULONG *tcp_transmit_window,
105 ULONG *tcp_receive_window)
106 {
107
108 UINT status;
109
110
111 /* Check for invalid input pointers. */
112 if ((socket_ptr == NX_NULL) || (socket_ptr -> nx_tcp_socket_id != NX_TCP_ID))
113 {
114 return(NX_PTR_ERROR);
115 }
116
117 /* Check to see if TCP is enabled. */
118 if (!(socket_ptr -> nx_tcp_socket_ip_ptr) -> nx_ip_tcp_packet_receive)
119 {
120 return(NX_NOT_ENABLED);
121 }
122
123 /* Check for appropriate caller. */
124 NX_INIT_AND_THREADS_CALLER_CHECKING
125
126 /* Call actual TCP socket information get function. */
127 status = _nx_tcp_socket_info_get(socket_ptr, tcp_packets_sent, tcp_bytes_sent, tcp_packets_received,
128 tcp_bytes_received, tcp_retransmit_packets, tcp_packets_queued,
129 tcp_checksum_errors, tcp_socket_state, tcp_transmit_queue_depth,
130 tcp_transmit_window, tcp_receive_window);
131
132 /* Return completion status. */
133 return(status);
134 }
135
136