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 /* Bring in externs for caller checking code. */
32
33 NX_CALLER_CHECKING_EXTERNS
34
35
36 /**************************************************************************/
37 /* */
38 /* FUNCTION RELEASE */
39 /* */
40 /* _nxe_udp_socket_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 socket 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_packets_queued Destination to the number of */
63 /* receive packets queued */
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_socket_info_get Actual UDP socket information */
76 /* get 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_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)91 UINT _nxe_udp_socket_info_get(NX_UDP_SOCKET *socket_ptr, ULONG *udp_packets_sent, ULONG *udp_bytes_sent,
92 ULONG *udp_packets_received, ULONG *udp_bytes_received, ULONG *udp_packets_queued,
93 ULONG *udp_receive_packets_dropped, ULONG *udp_checksum_errors)
94 {
95
96 UINT status;
97
98
99 /* Check for invalid input pointers. */
100 if ((socket_ptr == NX_NULL) || (socket_ptr -> nx_udp_socket_id != NX_UDP_ID))
101 {
102 return(NX_PTR_ERROR);
103 }
104
105 /* Check to see if UDP is enabled. */
106 if (!(socket_ptr -> nx_udp_socket_ip_ptr) -> nx_ip_udp_packet_receive)
107 {
108 return(NX_NOT_ENABLED);
109 }
110
111 /* Check for appropriate caller. */
112 NX_NOT_ISR_CALLER_CHECKING
113
114 /* Call actual UDP socket information get function. */
115 status = _nx_udp_socket_info_get(socket_ptr, udp_packets_sent, udp_bytes_sent, udp_packets_received,
116 udp_bytes_received, udp_packets_queued, udp_receive_packets_dropped,
117 udp_checksum_errors);
118
119 /* Return completion status. */
120 return(status);
121 }
122
123