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 /**   User Datagram Protocol (UDP)                                        */
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_ip.h"
29 #include "nx_udp.h"
30 
31 
32 /* Bring in externs for caller checking code.  */
33 
34 NX_CALLER_CHECKING_EXTERNS
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _nxe_udp_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 UDP information get          */
49 /*    function call.                                                      */
50 /*                                                                        */
51 /*  INPUT                                                                 */
52 /*                                                                        */
53 /*    ip_ptr                                Pointer to IP control block   */
54 /*    udp_packets_sent                      Destination to the number of  */
55 /*                                            packets sent                */
56 /*    udp_bytes_sent                        Destination to the number of  */
57 /*                                            bytes sent                  */
58 /*    udp_packets_received                  Destination to the number of  */
59 /*                                            packets received            */
60 /*    udp_bytes_received                    Destination to the number of  */
61 /*                                            bytes received              */
62 /*    udp_invalid_packets                   Destination to the number of  */
63 /*                                            invalid packets             */
64 /*    udp_receive_packets_dropped           Destination to the number of  */
65 /*                                            receive packets dropped     */
66 /*    udp_checksum_errors                   Destination to the number of  */
67 /*                                            checksum errors             */
68 /*                                                                        */
69 /*  OUTPUT                                                                */
70 /*                                                                        */
71 /*    status                                Completion status             */
72 /*                                                                        */
73 /*  CALLS                                                                 */
74 /*                                                                        */
75 /*    _nx_udp_info_get                      Actual UDP information get    */
76 /*                                            function                    */
77 /*                                                                        */
78 /*  CALLED BY                                                             */
79 /*                                                                        */
80 /*    Application                                                         */
81 /*                                                                        */
82 /*  RELEASE HISTORY                                                       */
83 /*                                                                        */
84 /*    DATE              NAME                      DESCRIPTION             */
85 /*                                                                        */
86 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
87 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
88 /*                                            resulting in version 6.1    */
89 /*                                                                        */
90 /**************************************************************************/
_nxe_udp_info_get(NX_IP * ip_ptr,ULONG * udp_packets_sent,ULONG * udp_bytes_sent,ULONG * udp_packets_received,ULONG * udp_bytes_received,ULONG * udp_invalid_packets,ULONG * udp_receive_packets_dropped,ULONG * udp_checksum_errors)91 UINT  _nxe_udp_info_get(NX_IP *ip_ptr, ULONG *udp_packets_sent, ULONG *udp_bytes_sent,
92                         ULONG *udp_packets_received, ULONG *udp_bytes_received,
93                         ULONG *udp_invalid_packets, ULONG *udp_receive_packets_dropped,
94                         ULONG *udp_checksum_errors)
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 UDP is enabled.  */
107     if (!ip_ptr -> nx_ip_udp_packet_receive)
108     {
109         return(NX_NOT_ENABLED);
110     }
111 
112     /* Check for appropriate caller.  */
113     NX_NOT_ISR_CALLER_CHECKING
114 
115     /* Call actual UDP information get function.  */
116     status =  _nx_udp_info_get(ip_ptr, udp_packets_sent, udp_bytes_sent, udp_packets_received,
117                                udp_bytes_received, udp_invalid_packets, udp_receive_packets_dropped,
118                                udp_checksum_errors);
119 
120     /* Return completion status.  */
121     return(status);
122 }
123 
124