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