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 #include "nx_ip.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _nx_udp_socket_send PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Yuxin Zhou, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function sends the supplied UDP packet through the supplied */
45 /* socket to the supplied IP address and port. */
46 /* */
47 /* INPUT */
48 /* */
49 /* socket_ptr Pointer to UDP socket */
50 /* packet_ptr Pointer to UDP packet */
51 /* ip_address IP address */
52 /* port 16-bit UDP port number */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* status Completion status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _nxd_udp_socket_send Send the UDP packet over IP */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* Application Code */
65 /* */
66 /* RELEASE HISTORY */
67 /* */
68 /* DATE NAME DESCRIPTION */
69 /* */
70 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
71 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
72 /* resulting in version 6.1 */
73 /* */
74 /**************************************************************************/
_nx_udp_socket_send(NX_UDP_SOCKET * socket_ptr,NX_PACKET * packet_ptr,ULONG ip_address,UINT port)75 UINT _nx_udp_socket_send(NX_UDP_SOCKET *socket_ptr, NX_PACKET *packet_ptr,
76 ULONG ip_address, UINT port)
77 {
78 #ifndef NX_DISABLE_IPV4
79 UINT status;
80
81 NXD_ADDRESS dual_ip_address;
82
83 /* build up the IP Address structure. */
84 dual_ip_address.nxd_ip_version = NX_IP_VERSION_V4;
85 dual_ip_address.nxd_ip_address.v4 = ip_address;
86
87 /* Call the actual udp socket send routine. */
88 status = _nxd_udp_socket_send(socket_ptr, packet_ptr, &dual_ip_address, port);
89
90 return(status);
91 #else
92 NX_PARAMETER_NOT_USED(socket_ptr);
93 NX_PARAMETER_NOT_USED(packet_ptr);
94 NX_PARAMETER_NOT_USED(ip_address);
95 NX_PARAMETER_NOT_USED(port);
96
97 return(NX_NOT_SUPPORTED);
98 #endif /* NX_DISABLE_IPV4 */
99 }
100
101