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 /* Bring in externs for caller checking code. */
33
34 NX_CALLER_CHECKING_EXTERNS
35
36
37 /**************************************************************************/
38 /* */
39 /* FUNCTION RELEASE */
40 /* */
41 /* _nxe_udp_socket_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 UDP socket information get */
50 /* function call. */
51 /* */
52 /* INPUT */
53 /* */
54 /* ip_ptr Pointer to IP control block */
55 /* udp_packets_sent Destination to the number of */
56 /* packets sent */
57 /* udp_bytes_sent Destination to the number of */
58 /* bytes sent */
59 /* udp_packets_received Destination to the number of */
60 /* packets received */
61 /* udp_bytes_received Destination to the number of */
62 /* bytes received */
63 /* udp_packets_queued Destination to the number of */
64 /* receive packets queued */
65 /* udp_receive_packets_dropped Destination to the number of */
66 /* receive packets dropped */
67 /* udp_checksum_errors Destination to the number of */
68 /* checksum errors */
69 /* */
70 /* OUTPUT */
71 /* */
72 /* status Completion status */
73 /* */
74 /* CALLS */
75 /* */
76 /* _nx_udp_socket_info_get Actual UDP socket information */
77 /* get function */
78 /* */
79 /* CALLED BY */
80 /* */
81 /* Application */
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_udp_socket_info_get(NX_UDP_SOCKET * socket_ptr,ULONG * udp_packets_sent,ULONG * udp_bytes_sent,ULONG * udp_packets_received,ULONG * udp_bytes_received,ULONG * udp_packets_queued,ULONG * udp_receive_packets_dropped,ULONG * udp_checksum_errors)92 UINT _nxe_udp_socket_info_get(NX_UDP_SOCKET *socket_ptr, ULONG *udp_packets_sent, ULONG *udp_bytes_sent,
93 ULONG *udp_packets_received, ULONG *udp_bytes_received, ULONG *udp_packets_queued,
94 ULONG *udp_receive_packets_dropped, ULONG *udp_checksum_errors)
95 {
96
97 UINT status;
98
99
100 /* Check for invalid input pointers. */
101 if ((socket_ptr == NX_NULL) || (socket_ptr -> nx_udp_socket_id != NX_UDP_ID))
102 {
103 return(NX_PTR_ERROR);
104 }
105
106 /* Check to see if UDP is enabled. */
107 if (!(socket_ptr -> nx_udp_socket_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 socket information get function. */
116 status = _nx_udp_socket_info_get(socket_ptr, udp_packets_sent, udp_bytes_sent, udp_packets_received,
117 udp_bytes_received, udp_packets_queued, udp_receive_packets_dropped,
118 udp_checksum_errors);
119
120 /* Return completion status. */
121 return(status);
122 }
123
124