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