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_udp.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _nx_udp_info_get PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function retrieves UDP information from the specified IP */
44 /* instance. */
45 /* */
46 /* INPUT */
47 /* */
48 /* ip_ptr Pointer to IP control block */
49 /* udp_packets_sent Destination to the number of */
50 /* packets sent */
51 /* udp_bytes_sent Destination to the number of */
52 /* bytes sent */
53 /* udp_packets_received Destination to the number of */
54 /* packets received */
55 /* udp_bytes_received Destination to the number of */
56 /* bytes received */
57 /* udp_invalid_packets Destination to the number of */
58 /* invalid packets */
59 /* udp_receive_packets_dropped Destination to the number of */
60 /* receive packets dropped */
61 /* udp_checksum_errors Destination to the number of */
62 /* checksum errors */
63 /* */
64 /* OUTPUT */
65 /* */
66 /* status Completion status */
67 /* */
68 /* CALLS */
69 /* */
70 /* None */
71 /* */
72 /* CALLED BY */
73 /* */
74 /* Application */
75 /* */
76 /* RELEASE HISTORY */
77 /* */
78 /* DATE NAME DESCRIPTION */
79 /* */
80 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
81 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
82 /* resulting in version 6.1 */
83 /* */
84 /**************************************************************************/
_nx_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)85 UINT _nx_udp_info_get(NX_IP *ip_ptr, ULONG *udp_packets_sent, ULONG *udp_bytes_sent,
86 ULONG *udp_packets_received, ULONG *udp_bytes_received,
87 ULONG *udp_invalid_packets, ULONG *udp_receive_packets_dropped,
88 ULONG *udp_checksum_errors)
89 {
90
91 TX_INTERRUPT_SAVE_AREA
92
93
94 /* If trace is enabled, insert this event into the trace buffer. */
95 NX_TRACE_IN_LINE_INSERT(NX_TRACE_UDP_INFO_GET, ip_ptr, ip_ptr -> nx_ip_udp_bytes_sent, ip_ptr -> nx_ip_udp_bytes_received, ip_ptr -> nx_ip_udp_invalid_packets, NX_TRACE_UDP_EVENTS, 0, 0);
96
97 /* Disable interrupts. */
98 TX_DISABLE
99
100 /* Determine if packets sent is wanted. */
101 if (udp_packets_sent)
102 {
103
104 /* Return the number of packets sent by this IP instance. */
105 *udp_packets_sent = ip_ptr -> nx_ip_udp_packets_sent;
106 }
107
108 /* Determine if bytes sent is wanted. */
109 if (udp_bytes_sent)
110 {
111
112 /* Return the number of bytes sent by this IP instance. */
113 *udp_bytes_sent = ip_ptr -> nx_ip_udp_bytes_sent;
114 }
115
116 /* Determine if packets received is wanted. */
117 if (udp_packets_received)
118 {
119
120 /* Return the number of packets received by this IP instance. */
121 *udp_packets_received = ip_ptr -> nx_ip_udp_packets_received;
122 }
123
124 /* Determine if bytes received is wanted. */
125 if (udp_bytes_received)
126 {
127
128 /* Return the number of bytes received by this IP instance. */
129 *udp_bytes_received = ip_ptr -> nx_ip_udp_bytes_received;
130 }
131
132 /* Determine if invalid packets is wanted. */
133 if (udp_invalid_packets)
134 {
135
136 /* Return the number of invalid packets by this IP instance. */
137 *udp_invalid_packets = ip_ptr -> nx_ip_udp_invalid_packets;
138 }
139
140 /* Determine if receive packets dropped is wanted. */
141 if (udp_receive_packets_dropped)
142 {
143
144 /* Return the number of receive packets dropped by this IP instance. */
145 *udp_receive_packets_dropped = ip_ptr -> nx_ip_udp_receive_packets_dropped;
146 }
147
148 /* Determine if checksum errors is wanted. */
149 if (udp_checksum_errors)
150 {
151
152 /* Return the number of checksum errors by this IP instance. */
153 *udp_checksum_errors = ip_ptr -> nx_ip_udp_checksum_errors;
154 }
155
156 /* Restore interrupts. */
157 TX_RESTORE
158
159 /* Return successful completion. */
160 return(NX_SUCCESS);
161 }
162
163