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_source_send PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Yuxin Zhou, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function sends UDP packet using specified local interface */
46 /* IPv4 address as source. */
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 /* address_index Index of IPv4 address to */
55 /* use as the source address */
56 /* */
57 /* OUTPUT */
58 /* */
59 /* status Completion status */
60 /* */
61 /* CALLS */
62 /* */
63 /* _nx_udp_socket_send Send the UDP packet */
64 /* */
65 /* CALLED BY */
66 /* */
67 /* Application Code */
68 /* */
69 /* RELEASE HISTORY */
70 /* */
71 /* DATE NAME DESCRIPTION */
72 /* */
73 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
74 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
75 /* resulting in version 6.1 */
76 /* */
77 /**************************************************************************/
_nx_udp_socket_source_send(NX_UDP_SOCKET * socket_ptr,NX_PACKET * packet_ptr,ULONG ip_address,UINT port,UINT address_index)78 UINT _nx_udp_socket_source_send(NX_UDP_SOCKET *socket_ptr, NX_PACKET *packet_ptr,
79 ULONG ip_address, UINT port, UINT address_index)
80 {
81 UINT status;
82 NX_IP *ip_ptr;
83
84
85 /* Setup the pointer to the associated IP instance. */
86 ip_ptr = socket_ptr -> nx_udp_socket_ip_ptr;
87
88 /* Store interface information into the packet structure. */
89 packet_ptr -> nx_packet_address.nx_packet_interface_ptr = &(ip_ptr -> nx_ip_interface[address_index]);
90
91 /* Call udp_socket_send service */
92 status = _nx_udp_socket_send(socket_ptr, packet_ptr, ip_address, port);
93
94 return(status);
95 }
96
97