Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ipv6.h"
#include "nx_icmpv6.h"
#include "nx_packet.h"
...
Files
loading...
SourceVuSTM32 Libraries and Samplesnetxduocommon/src/nx_icmpv6_send_queued_packets.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Component */ /** */ /** Internet Control Message Protocol (ICMP) */ /** */... /**************************************************************************/ /**************************************************************************/ #define NX_SOURCE_CODE #include "nx_api.h" #include "nx_ipv6.h" #include "nx_icmpv6.h" #include "nx_packet.h" #ifdef FEATURE_NX_IPV6 /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_icmpv6_send_queued_packets PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function sends out queued packets after their destination */ /* link layer address becomes known, i.e, after receiving a */ /* neighbor advertisement message from the destination host. */ /* */ /* INPUT */ /* */ /* ip_ptr Pointer to IP control block */ /* nd_entry Destination host ND entry */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _nx_ipv6_fragment_process IPv6 fragmentation routine */ /* [_nx_ip_link_driver_entry] Ethernet Device Driver Entry */ /* */ /* CALLED BY */ /* */ /* _nx_icmp_packet_process Main ICMP packet pocess */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ VOID _nx_icmpv6_send_queued_packets(NX_IP *ip_ptr, ND_CACHE_ENTRY *nd_entry) { NX_IP_DRIVER driver_request; UCHAR *mac_addr; NX_PACKET *queued_list_head, *ip_packet_ptr; UINT next_hop_mtu; #ifndef NX_DISABLE_FRAGMENTATION #ifdef NX_ENABLE_IPV6_PATH_MTU_DISCOVERY NX_IPV6_DESTINATION_ENTRY *dest_entry_ptr; NX_IPV6_HEADER *ip_header_ptr; ULONG status;/* ... */ #endif /* NX_ENABLE_IPV6_PATH_MTU_DISCOVERY *//* ... */ #endif /* NX_DISABLE_FRAGMENTATION */ TX_INTERRUPT_SAVE_AREA /* nd_entry must not be NX_NULL. */ NX_ASSERT(nd_entry != NX_NULL); /* The packet waiting head must not be NX_NULL. */ NX_ASSERT(nd_entry -> nx_nd_cache_packet_waiting_head != NX_NULL); /*lint --e{613} suppress possible use of null pointer, since "nd_entry" must not be null. */ queued_list_head = nd_entry -> nx_nd_cache_packet_waiting_head; mac_addr = nd_entry -> nx_nd_cache_mac_addr; /* Build the driver request packet. */ driver_request.nx_ip_driver_physical_address_msw = ((ULONG)(mac_addr[0]) << 8) | mac_addr[1]; driver_request.nx_ip_driver_physical_address_lsw = ((ULONG)(mac_addr[2]) << 24) | ((ULONG)(mac_addr[3]) << 16) | ((ULONG)(mac_addr[4]) << 8) | mac_addr[5]; driver_request.nx_ip_driver_ptr = ip_ptr; driver_request.nx_ip_driver_command = NX_LINK_PACKET_SEND; driver_request.nx_ip_driver_interface = nd_entry -> nx_nd_cache_interface_ptr; driver_request.nx_ip_driver_status = NX_SUCCESS; /* Loop through all the queued packets. */ while (queued_list_head) { /* Set a pointer to the start of the queue. */ ip_packet_ptr = queued_list_head; queued_list_head = queued_list_head -> nx_packet_queue_next; /* Clear the packet's queue next pointer */ ip_packet_ptr -> nx_packet_queue_next = NX_NULL; /* Add this packet to the driver request (to send). */ driver_request.nx_ip_driver_packet = ip_packet_ptr; /* Set the next hop MTU. */ next_hop_mtu = driver_request.nx_ip_driver_interface -> nx_interface_ip_mtu_size; /* Check if path MTU Discovery is enabled first. */ #ifdef NX_ENABLE_IPV6_PATH_MTU_DISCOVERY /* It is. To know if we need to fragment this packet we need the path MTU for the packet destination. *//* ... */ /*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */ ip_header_ptr = (NX_IPV6_HEADER *)ip_packet_ptr -> nx_packet_prepend_ptr; /* Convert destination address to host byte order. */ NX_IPV6_ADDRESS_CHANGE_ENDIAN(ip_header_ptr -> nx_ip_header_destination_ip); /* Find the entry in the cache table for packet's destination. */ status = _nx_icmpv6_dest_table_find(ip_ptr, ip_header_ptr -> nx_ip_header_destination_ip, &dest_entry_ptr, 0, 0); /* Convert destination address back to net byte order. */ NX_IPV6_ADDRESS_CHANGE_ENDIAN(ip_header_ptr -> nx_ip_header_destination_ip); /* Check for successful search and location of packet destination data. */ if (status == NX_SUCCESS) { ULONG next_hop_address[4]; NX_IPV6_DESTINATION_ENTRY *next_hop_dest_entry_ptr; /* If this destination has a non null next hop, we need to ascertain the next hop MTU. */ /* Get the path MTU for the actual destination. */ next_hop_mtu = dest_entry_ptr -> nx_ipv6_destination_entry_path_mtu; /* Set the next hop address. */ COPY_IPV6_ADDRESS(dest_entry_ptr -> nx_ipv6_destination_entry_next_hop, next_hop_address); /* Check the next hop address. */ if (!CHECK_UNSPECIFIED_ADDRESS(&(next_hop_address[0]))) { /* Find the next hop in the destination table. */ status = _nx_icmpv6_dest_table_find(ip_ptr, next_hop_address, &next_hop_dest_entry_ptr, 0, 0); if (status == NX_SUCCESS) { /* Now compare the destination path MTU with the next hop path MTU*/ if ((next_hop_dest_entry_ptr -> nx_ipv6_destination_entry_path_mtu > 0) && (next_hop_mtu > next_hop_dest_entry_ptr -> nx_ipv6_destination_entry_path_mtu)) { /* Update the path mtu to reflect the next hop route. */ next_hop_mtu = next_hop_dest_entry_ptr -> nx_ipv6_destination_entry_path_mtu; }if ((next_hop_dest_entry_ptr -> nx_ipv6_destination_entry_path_mtu > 0) && (next_hop_mtu > next_hop_dest_entry_ptr -> nx_ipv6_destination_entry_path_mtu)) { ... } }if (status == NX_SUCCESS) { ... } }if (!CHECK_UNSPECIFIED_ADDRESS(&(next_hop_address[0]))) { ... } }if (status == NX_SUCCESS) { ... } /* ... */#endif /* NX_ENABLE_IPV6_PATH_MTU_DISCOVERY */ /* Does the packet payload exceed next hop MTU? */ if (ip_packet_ptr -> nx_packet_length > next_hop_mtu) { #ifndef NX_DISABLE_FRAGMENTATION /* Yes; ok to fragment the packet payload. */ _nx_ipv6_fragment_process(&driver_request, next_hop_mtu); /* ... */ #else /* NX_DISABLE_FRAGMENTATION */ #ifndef NX_DISABLE_IP_INFO /* Increment the IP send packets dropped count. */ ip_ptr -> nx_ip_send_packets_dropped++;/* ... */ #endif /* Just release the packet. */ _nx_packet_transmit_release(ip_packet_ptr);/* ... */ #endif /* NX_DISABLE_FRAGMENTATION */ }if (ip_packet_ptr -> nx_packet_length > next_hop_mtu) { ... } else { /* The packet requires no fragmentation. Proceed with sending the packet. */ #ifndef NX_DISABLE_IP_INFO /* Increment the IP packet sent count. */ ip_ptr -> nx_ip_total_packets_sent++; /* Increment the IP bytes sent count. */ ip_ptr -> nx_ip_total_bytes_sent += ip_packet_ptr -> nx_packet_length - (ULONG)sizeof(NX_IPV6_HEADER);/* ... */ #endif /* !NX_DISABLE_IP_INFO */ /* Add debug information. */ NX_PACKET_DEBUG(__FILE__, __LINE__, ip_packet_ptr); /* Send the queued IP packet out on the network via the attached driver. */ (ip_packet_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr -> nxd_ipv6_address_attached -> nx_interface_link_driver_entry)(&driver_request); }else { ... } }while (queued_list_head) { ... } TX_DISABLE /* If the ND Cache is in STALE state, move it to DELAY state. This situation happens when we receive the LLA (link local address) through unsoliciated RA (router advertisement message. In this situation, the entry is in STALE state, and a packet has been transmitted, so the entry needs to be in DELAY state. *//* ... */ if (nd_entry -> nx_nd_cache_nd_status == ND_CACHE_STATE_STALE) { nd_entry -> nx_nd_cache_nd_status = ND_CACHE_STATE_DELAY; /* Start the Delay first probe timer */ nd_entry -> nx_nd_cache_timer_tick = NX_DELAY_FIRST_PROBE_TIME; }if (nd_entry -> nx_nd_cache_nd_status == ND_CACHE_STATE_STALE) { ... } TX_RESTORE /* Clean up the nd_entry */ nd_entry -> nx_nd_cache_packet_waiting_head = NX_NULL; nd_entry -> nx_nd_cache_packet_waiting_tail = NX_NULL; /* Clean up the queue length variable. */ nd_entry -> nx_nd_cache_packet_waiting_queue_length = 0; }_nx_icmpv6_send_queued_packets (NX_IP *ip_ptr, ND_CACHE_ENTRY *nd_entry) { ... } /* ... */#endif /* FEATURE_NX_IPV6 */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.