Select one of the symbols to view example projects that use it.
 
Outline
...
...
#define NX_SOURCE_CODE
#include "tx_api.h"
#include "nx_api.h"
#include "nx_ipv6.h"
#define PACKET_MORE_TO_COPY
#define PACKET_ADD_BUFFER
#define PACKET_COPY_DONE
...
Files
loading...
SourceVuSTM32 Libraries and Samplesnetxduocommon/src/nx_ipv6_packet_copy.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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* 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 Protocol version 6 (IPv6) */ /** */... /**************************************************************************/ /**************************************************************************/ #define NX_SOURCE_CODE /* Include necessary system files. */ #include "tx_api.h" #include "nx_api.h" #include "nx_ipv6.h" #if defined(FEATURE_NX_IPV6) && !defined(NX_DISABLE_FRAGMENTATION) /* Define the status 'bits' of the copy flag field. */ #define PACKET_MORE_TO_COPY 1 #define PACKET_ADD_BUFFER 2 #define PACKET_COPY_DONE 4 /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_ipv6_packet_copy PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This internal function copies packet data between packets. */ /* */ /* INPUT */ /* */ /* source_pkt_head Pointer to source packet chain. */ /* dest_pkt_head Pointer to destination packet chain. */ /* size Number of bytes to copy. */ /* */ /* OUTPUT */ /* */ /* NX_SUCCESS Successful completion */ /* NX_NOT_SUCCESSFUL Error with packet copy */ /* */ /* CALLS */ /* */ /* None */ /* */ /* CALLED BY */ /* */ /* _nx_ipv6_fragment_process */ /* */ /* */ /* NOTE */ /* */ /* None */ /* */ /* 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 */ /* */... /**************************************************************************/ UINT _nx_ipv6_packet_copy(NX_PACKET *source_pkt_head, NX_PACKET *dest_pkt_head, UINT size) { UINT bytes_remaining; NX_PACKET *source_pkt, *dest_pkt; UINT bytes_to_copy; ULONG *source_ptr, *dest_ptr; UCHAR *source_byte, *dest_byte; UINT flag; /* Number of bytes to be copied. */ bytes_remaining = size; /* Obtain points to the source and destination packets. */ source_pkt = source_pkt_head -> nx_packet_last; dest_pkt = dest_pkt_head -> nx_packet_last; while (bytes_remaining > 0) { /* Make sure source or destination packets are valid. */ if ((source_pkt == NX_NULL) || (dest_pkt == NX_NULL)) { return(NX_NOT_SUCCESSFUL); }if ((source_pkt == NX_NULL) || (dest_pkt == NX_NULL)) { ... } /* figure out the amount of bytes we can copy in this iteration. At the end of the interation, we shall be able to "close" either the source packet or the destination packet. *//* ... */ bytes_to_copy = bytes_remaining; flag = PACKET_COPY_DONE; /* Check if the source packet is running out of data. */ /*lint -e{946} -e{947} suppress pointer subtraction, since it is necessary. */ if (bytes_to_copy > (UINT)(source_pkt -> nx_packet_append_ptr - source_pkt -> nx_packet_prepend_ptr)) { /* It is. Set flag to PACKET_MORE_TO_COPY, indicating that there is more to be copied from the following buffer. *//* ... */ /*lint -e{946} -e{947} suppress pointer subtraction, since it is necessary. */ bytes_to_copy = (UINT)(source_pkt -> nx_packet_append_ptr - source_pkt -> nx_packet_prepend_ptr); flag = PACKET_MORE_TO_COPY; }if (bytes_to_copy > (UINT)(source_pkt -> nx_packet_append_ptr - source_pkt -> nx_packet_prepend_ptr)) { ... } /* Check if the destination packet is running ouf of space. */ /*lint -e{946} -e{947} suppress pointer subtraction, since it is necessary. */ if (bytes_to_copy > (UINT)(dest_pkt -> nx_packet_data_end - dest_pkt -> nx_packet_append_ptr)) { /* It is. Set the 2nd bit in the flag to indicate that at the the end of the iteration we will need to chain another buffer on the destination packet.*//* ... */ /*lint -e{946} -e{947} suppress pointer subtraction, since it is necessary. */ bytes_to_copy = (UINT)(dest_pkt -> nx_packet_data_end - dest_pkt -> nx_packet_append_ptr); flag = PACKET_ADD_BUFFER; }if (bytes_to_copy > (UINT)(dest_pkt -> nx_packet_data_end - dest_pkt -> nx_packet_append_ptr)) { ... } /* Adjust packet pointers. */ /*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */ dest_ptr = (ULONG *)dest_pkt -> nx_packet_append_ptr; dest_pkt -> nx_packet_append_ptr += bytes_to_copy; dest_pkt -> nx_packet_length -= bytes_to_copy; /*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */ source_ptr = (ULONG *)source_pkt -> nx_packet_prepend_ptr; source_pkt -> nx_packet_prepend_ptr += bytes_to_copy; while (bytes_to_copy) { /* Loop unrolling: copy 32 bytes in one iteration. */ switch (bytes_to_copy >> 2) { default: *dest_ptr++ = *source_ptr++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */default case 7: *dest_ptr++ = *source_ptr++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */case 7: case 6: *dest_ptr++ = *source_ptr++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */case 6: case 5: *dest_ptr++ = *source_ptr++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */case 5: case 4: *dest_ptr++ = *source_ptr++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */case 4: case 3: *dest_ptr++ = *source_ptr++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */case 3: case 2: *dest_ptr++ = *source_ptr++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */case 2: case 1: *dest_ptr++ = *source_ptr++;case 1: }switch (bytes_to_copy >> 2) { ... } if (bytes_to_copy >= 32) { bytes_to_copy -= 32; bytes_remaining -= 32; }if (bytes_to_copy >= 32) { ... } else { /* Copy bytes less than 4. */ /*lint --e{928} suppress cast from pointer to pointer, since it is necessary */ source_byte = (UCHAR *)source_ptr; dest_byte = (UCHAR *)dest_ptr; switch (bytes_to_copy & 3) { case 3: *dest_byte++ = *source_byte++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */case 3: case 2: *dest_byte++ = *source_byte++; /*lint -e{825} suppress fallthrough, since it is necessary. */ /* fallthrough */case 2: case 1: *dest_byte++ = *source_byte++; break;case 1: default: break;default }switch (bytes_to_copy & 3) { ... } bytes_remaining -= bytes_to_copy; bytes_to_copy = 0; }else { ... } }while (bytes_to_copy) { ... } /* Check if the flag has been set to more data to copy. */ if (flag & PACKET_MORE_TO_COPY) { source_pkt_head -> nx_packet_last = source_pkt -> nx_packet_next; source_pkt = source_pkt_head -> nx_packet_last; }if (flag & PACKET_MORE_TO_COPY) { ... } /* Check if we need to chain another buffer to the packet chain for more data copy. */ if (flag & PACKET_ADD_BUFFER) { dest_pkt_head -> nx_packet_last = dest_pkt -> nx_packet_next; dest_pkt = dest_pkt -> nx_packet_next; }if (flag & PACKET_ADD_BUFFER) { ... } /* Check if we are done. */ if (flag & PACKET_COPY_DONE) { /* We are. */ break; }if (flag & PACKET_COPY_DONE) { ... } }while (bytes_remaining > 0) { ... } return(NX_SUCCESS); }_nx_ipv6_packet_copy (NX_PACKET *source_pkt_head, NX_PACKET *dest_pkt_head, UINT size) { ... } /* ... */ #endif /* FEATURE_NX_IPV6 && NX_DISABLE_FRAGMENTATION*/
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.