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 /**   Internet Control Message Protocol (ICMP)                            */
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_icmp.h"
31 
32 /* Bring in externs for caller checking code.  */
33 
34 
35 NX_CALLER_CHECKING_EXTERNS
36 
37 
38 
39 /**************************************************************************/
40 /*                                                                        */
41 /*  FUNCTION                                               RELEASE        */
42 /*                                                                        */
43 /*    _nxe_icmp_info_get                                  PORTABLE C      */
44 /*                                                           6.1          */
45 /*  AUTHOR                                                                */
46 /*                                                                        */
47 /*    Yuxin Zhou, Microsoft Corporation                                   */
48 /*                                                                        */
49 /*  DESCRIPTION                                                           */
50 /*                                                                        */
51 /*    This function checks for errors in the ICMP information get         */
52 /*    function call.                                                      */
53 /*                                                                        */
54 /*  INPUT                                                                 */
55 /*                                                                        */
56 /*    ip_ptr                                Pointer to IP instance        */
57 /*    pings_sent                            Destination for number of     */
58 /*                                            pings sent                  */
59 /*    ping_timeouts                         Destination for number of     */
60 /*                                            ping timeouts               */
61 /*    ping_threads_suspended                Destination for number of     */
62 /*                                            threads suspended on pings  */
63 /*    ping_responses_received               Destination for number of     */
64 /*                                            ping responses received     */
65 /*    icmp_checksum_errors                  Destination for number of     */
66 /*                                            ICMP checksum errors        */
67 /*    icmp_unhandled_messages               Destination for number of     */
68 /*                                            unhandled ICMP messages     */
69 /*                                                                        */
70 /*  OUTPUT                                                                */
71 /*                                                                        */
72 /*    None                                                                */
73 /*                                                                        */
74 /*  CALLS                                                                 */
75 /*                                                                        */
76 /*    _nx_icmp_info_get                     Actual ICMP information get   */
77 /*                                            function                    */
78 /*                                                                        */
79 /*  CALLED BY                                                             */
80 /*                                                                        */
81 /*    Application Code                                                    */
82 /*                                                                        */
83 /*  RELEASE HISTORY                                                       */
84 /*                                                                        */
85 /*    DATE              NAME                      DESCRIPTION             */
86 /*                                                                        */
87 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
88 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
89 /*                                            resulting in version 6.1    */
90 /*                                                                        */
91 /**************************************************************************/
_nxe_icmp_info_get(NX_IP * ip_ptr,ULONG * pings_sent,ULONG * ping_timeouts,ULONG * ping_threads_suspended,ULONG * ping_responses_received,ULONG * icmp_checksum_errors,ULONG * icmp_unhandled_messages)92 UINT  _nxe_icmp_info_get(NX_IP *ip_ptr, ULONG *pings_sent, ULONG *ping_timeouts,
93                          ULONG *ping_threads_suspended, ULONG *ping_responses_received,
94                          ULONG *icmp_checksum_errors, ULONG *icmp_unhandled_messages)
95 {
96 
97 UINT status;
98 
99 
100     /* Check for invalid input pointers.  */
101     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
102     {
103         return(NX_PTR_ERROR);
104     }
105 
106     /* Check to see if ICMP is enabled.  */
107     if (!ip_ptr -> nx_ip_icmp_packet_receive)
108     {
109         return(NX_NOT_ENABLED);
110     }
111 
112     /* Check for appropriate caller.  */
113     NX_INIT_AND_THREADS_CALLER_CHECKING
114 
115     /* Call actual ICMP information get function.  */
116     status =  _nx_icmp_info_get(ip_ptr, pings_sent, ping_timeouts, ping_threads_suspended,
117                                 ping_responses_received, icmp_checksum_errors, icmp_unhandled_messages);
118 
119     /* Return completion status.  */
120     return(status);
121 }
122 
123