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