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_ip.h"
30 #include "nx_tcp.h"
31 
32 
33 /* Bring in externs for caller checking code.  */
34 NX_CALLER_CHECKING_EXTERNS
35 
36 
37 /**************************************************************************/
38 /*                                                                        */
39 /*  FUNCTION                                               RELEASE        */
40 /*                                                                        */
41 /*    _nxe_tcp_info_get                                   PORTABLE C      */
42 /*                                                           6.1          */
43 /*  AUTHOR                                                                */
44 /*                                                                        */
45 /*    Yuxin Zhou, Microsoft Corporation                                   */
46 /*                                                                        */
47 /*  DESCRIPTION                                                           */
48 /*                                                                        */
49 /*    This function checks for errors in the TCP information get          */
50 /*    function call.                                                      */
51 /*                                                                        */
52 /*  INPUT                                                                 */
53 /*                                                                        */
54 /*    ip_ptr                                Pointer to the IP instance    */
55 /*    tcp_packets_sent                      Destination for number of     */
56 /*                                            packets sent                */
57 /*    tcp_bytes_sent                        Destination for number of     */
58 /*                                            bytes sent                  */
59 /*    tcp_packets_received                  Destination for number of     */
60 /*                                            packets received            */
61 /*    tcp_bytes_received                    Destination for number of     */
62 /*                                            bytes received              */
63 /*    tcp_invalid_packets                   Destination for number of     */
64 /*                                            invalid packets             */
65 /*    tcp_receive_packets_dropped           Destination for number of     */
66 /*                                            receive packets dropped     */
67 /*    tcp_checksum_errors                   Destination for number of     */
68 /*                                            checksum errors             */
69 /*    tcp_connections                       Destination for number of     */
70 /*                                            connections                 */
71 /*    tcp_disconnections                    Destination for number of     */
72 /*                                            disconnections              */
73 /*    tcp_connections_dropped               Destination for number of     */
74 /*                                            connections dropped         */
75 /*    tcp_retransmit_packets                Destination for number of     */
76 /*                                            retransmit packets          */
77 /*                                                                        */
78 /*  OUTPUT                                                                */
79 /*                                                                        */
80 /*    status                                Completion status             */
81 /*                                                                        */
82 /*  CALLS                                                                 */
83 /*                                                                        */
84 /*    _nx_tcp_info_get                      Actual TCP 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_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)100 UINT  _nxe_tcp_info_get(NX_IP *ip_ptr, ULONG *tcp_packets_sent, ULONG *tcp_bytes_sent,
101                         ULONG *tcp_packets_received, ULONG *tcp_bytes_received,
102                         ULONG *tcp_invalid_packets, ULONG *tcp_receive_packets_dropped,
103                         ULONG *tcp_checksum_errors, ULONG *tcp_connections,
104                         ULONG *tcp_disconnections, ULONG *tcp_connections_dropped,
105                         ULONG *tcp_retransmit_packets)
106 {
107 
108 UINT status;
109 
110 
111     /* Check for invalid input pointers.  */
112     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
113     {
114         return(NX_PTR_ERROR);
115     }
116 
117     /* Check to see if TCP is enabled.  */
118     if (!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 information get function.  */
127     status =  _nx_tcp_info_get(ip_ptr, tcp_packets_sent, tcp_bytes_sent, tcp_packets_received,
128                                tcp_bytes_received, tcp_invalid_packets, tcp_receive_packets_dropped,
129                                tcp_checksum_errors, tcp_connections, tcp_disconnections,
130                                tcp_connections_dropped, tcp_retransmit_packets);
131 
132     /* Return completion status.  */
133     return(status);
134 }
135 
136