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 /** Internet Protocol (IP) */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 #define NX_SOURCE_CODE
24
25
26 /* Include necessary system files. */
27
28
29 #include "nx_api.h"
30 #include "nx_ipv6.h"
31
32 #ifdef FEATURE_NX_IPV6
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _nxd_ipv6_raw_packet_send_internal PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Yuxin Zhou, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This is the internal function NetX Duo uses to send a raw IP packet */
46 /* through the specified IPv6 interface. */
47 /* */
48 /* INPUT */
49 /* */
50 /* ip_ptr Pointer to IP control block */
51 /* packet_ptr Pointer to packet to send */
52 /* destination_ip Destination IP address */
53 /* protocol Information that goes into */
54 /* the next header field. */
55 /* */
56 /* OUTPUT */
57 /* */
58 /* status Completion status */
59 /* */
60 /* CALLS */
61 /* */
62 /* _nx_ipv6_packet_send Core IPv6 packet send service */
63 /* _nxd_ipv6_interface_find Determines a valid interface */
64 /* tx_mutex_get Get protection mutex */
65 /* tx_mutex_put Put protection mutex */
66 /* COPY_IPV6_ADDRESS Copy IPv6 address */
67 /* */
68 /* CALLED BY */
69 /* */
70 /* Application */
71 /* */
72 /* RELEASE HISTORY */
73 /* */
74 /* DATE NAME DESCRIPTION */
75 /* */
76 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
77 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
78 /* resulting in version 6.1 */
79 /* */
80 /**************************************************************************/
_nxd_ipv6_raw_packet_send_internal(NX_IP * ip_ptr,NX_PACKET * packet_ptr,NXD_ADDRESS * destination_ip,ULONG protocol)81 UINT _nxd_ipv6_raw_packet_send_internal(NX_IP *ip_ptr, NX_PACKET *packet_ptr,
82 NXD_ADDRESS *destination_ip,
83 ULONG protocol)
84 {
85
86 #ifdef TX_ENABLE_EVENT_TRACE
87 ULONG ip_address_lsw;
88 #endif /* TX_ENABLE_EVENT_TRACE */
89
90
91 #ifdef TX_ENABLE_EVENT_TRACE
92
93 ip_address_lsw = destination_ip -> nxd_ip_address.v6[3];
94
95 /* If trace is enabled, insert this event into the trace buffer. */
96 NX_TRACE_IN_LINE_INSERT(NXD_TRACE_IPV6_RAW_PACKET_SEND, ip_ptr, ip_address_lsw, protocol, packet_ptr, NX_TRACE_IP_EVENTS, 0, 0);
97 #endif /* TX_ENABLE_EVENT_TRACE */
98
99 NX_ASSERT(packet_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr != NX_NULL);
100
101 /* Tag the IP version for this packet. */
102 packet_ptr -> nx_packet_ip_version = NX_IP_VERSION_V6;
103
104 /* Get mutex protection. */
105 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
106
107 /* Ok to send the packet! */
108 _nx_ipv6_packet_send(ip_ptr, packet_ptr, protocol, packet_ptr -> nx_packet_length, ip_ptr -> nx_ipv6_hop_limit,
109 packet_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr -> nxd_ipv6_address,
110 destination_ip -> nxd_ip_address.v6);
111
112 /* Release mutex protection. */
113 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
114
115 /* Return a successful status! */
116 return(NX_SUCCESS);
117 }
118 #endif /* FEATURE_NX_IPV6 */
119
120