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 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _nx_tcp_info_get PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Yuxin Zhou, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function retrieves TCP information for the specified IP */
45 /* instance. */
46 /* */
47 /* INPUT */
48 /* */
49 /* ip_ptr Pointer to the IP instance */
50 /* tcp_packets_sent Destination for number of */
51 /* packets sent */
52 /* tcp_bytes_sent Destination for number of */
53 /* bytes sent */
54 /* tcp_packets_received Destination for number of */
55 /* packets received */
56 /* tcp_bytes_received Destination for number of */
57 /* bytes received */
58 /* tcp_invalid_packets Destination for number of */
59 /* invalid packets */
60 /* tcp_receive_packets_dropped Destination for number of */
61 /* receive packets dropped */
62 /* tcp_checksum_errors Destination for number of */
63 /* checksum errors */
64 /* tcp_connections Destination for number of */
65 /* connections */
66 /* tcp_disconnections Destination for number of */
67 /* disconnections */
68 /* tcp_connections_dropped Destination for number of */
69 /* connections dropped */
70 /* tcp_retransmit_packets Destination for number of */
71 /* retransmit packets */
72 /* */
73 /* OUTPUT */
74 /* */
75 /* status Completion status */
76 /* */
77 /* CALLS */
78 /* */
79 /* tx_mutex_get Obtain protection */
80 /* tx_mutex_put Release protection */
81 /* */
82 /* CALLED BY */
83 /* */
84 /* Application Code */
85 /* */
86 /* RELEASE HISTORY */
87 /* */
88 /* DATE NAME DESCRIPTION */
89 /* */
90 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
91 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
92 /* resulting in version 6.1 */
93 /* */
94 /**************************************************************************/
_nx_tcp_info_get(NX_IP * ip_ptr,ULONG * tcp_packets_sent,ULONG * tcp_bytes_sent,ULONG * tcp_packets_received,ULONG * tcp_bytes_received,ULONG * tcp_invalid_packets,ULONG * tcp_receive_packets_dropped,ULONG * tcp_checksum_errors,ULONG * tcp_connections,ULONG * tcp_disconnections,ULONG * tcp_connections_dropped,ULONG * tcp_retransmit_packets)95 UINT _nx_tcp_info_get(NX_IP *ip_ptr, ULONG *tcp_packets_sent, ULONG *tcp_bytes_sent,
96 ULONG *tcp_packets_received, ULONG *tcp_bytes_received,
97 ULONG *tcp_invalid_packets, ULONG *tcp_receive_packets_dropped,
98 ULONG *tcp_checksum_errors, ULONG *tcp_connections,
99 ULONG *tcp_disconnections, ULONG *tcp_connections_dropped,
100 ULONG *tcp_retransmit_packets)
101 {
102
103 /* Obtain the IP mutex so we can examine the bound port. */
104 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
105
106 /* Determine if packets sent is wanted. */
107 if (tcp_packets_sent)
108 {
109
110 /* Return the number of packets sent by this IP instance. */
111 *tcp_packets_sent = ip_ptr -> nx_ip_tcp_packets_sent;
112 }
113
114 /* Determine if bytes sent is wanted. */
115 if (tcp_bytes_sent)
116 {
117
118 /* Return the number of bytes sent by this IP instance. */
119 *tcp_bytes_sent = ip_ptr -> nx_ip_tcp_bytes_sent;
120 }
121
122 /* Determine if packets received is wanted. */
123 if (tcp_packets_received)
124 {
125
126 /* Return the number of packets received by this IP instance. */
127 *tcp_packets_received = ip_ptr -> nx_ip_tcp_packets_received;
128 }
129
130 /* Determine if bytes received is wanted. */
131 if (tcp_bytes_received)
132 {
133
134 /* Return the number of bytes received by this IP instance. */
135 *tcp_bytes_received = ip_ptr -> nx_ip_tcp_bytes_received;
136 }
137
138 /* Determine if invalid packets is wanted. */
139 if (tcp_invalid_packets)
140 {
141
142 /* Return the number of invalid packets by this IP instance. */
143 *tcp_invalid_packets = ip_ptr -> nx_ip_tcp_invalid_packets;
144 }
145
146 /* Determine if receive packets dropped is wanted. */
147 if (tcp_receive_packets_dropped)
148 {
149
150 /* Return the number of receive packets dropped by this IP instance. */
151 *tcp_receive_packets_dropped = ip_ptr -> nx_ip_tcp_receive_packets_dropped;
152 }
153
154 /* Determine if checksum errors is wanted. */
155 if (tcp_checksum_errors)
156 {
157
158 /* Return the number of checksum errors by this IP instance. */
159 *tcp_checksum_errors = ip_ptr -> nx_ip_tcp_checksum_errors;
160 }
161
162 /* Determine if connections is wanted. */
163 if (tcp_connections)
164 {
165
166 /* Return the number of connections by this IP instance. */
167 *tcp_connections = ip_ptr -> nx_ip_tcp_connections;
168 }
169
170 /* Determine if disconnections is wanted. */
171 if (tcp_disconnections)
172 {
173
174 /* Return the number of disconnections by this IP instance. */
175 *tcp_disconnections = ip_ptr -> nx_ip_tcp_disconnections;
176 }
177
178 /* Determine if connections dropped is wanted. */
179 if (tcp_connections_dropped)
180 {
181
182 /* Return the number of connections dropped by this IP instance. */
183 *tcp_connections_dropped = ip_ptr -> nx_ip_tcp_connections_dropped;
184 }
185
186 /* Determine if retransmit packets is wanted. */
187 if (tcp_retransmit_packets)
188 {
189
190 /* Return the number of retransmit packets by this IP instance. */
191 *tcp_retransmit_packets = ip_ptr -> nx_ip_tcp_retransmit_packets;
192 }
193
194 /* Release protection. */
195 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
196
197 /* Return successful completion status. */
198 return(NX_SUCCESS);
199 }
200
201