]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
1. Update EFI_IP4_MODE_DATA: add MaxPacketSize to this structure to comply with UEFI...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Input.c
CommitLineData
772db4bb 1/** @file\r
3e8c18da 2 IP4 input process.\r
3 \r
894d038a 4Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
772db4bb 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
772db4bb 13**/\r
14\r
15#include "Ip4Impl.h"\r
16\r
17\r
18/**\r
96e1079f 19 Create an empty assemble entry for the packet identified by\r
772db4bb 20 (Dst, Src, Id, Protocol). The default life for the packet is\r
21 120 seconds.\r
22\r
3e8c18da 23 @param[in] Dst The destination address\r
24 @param[in] Src The source address\r
25 @param[in] Id The ID field in IP header\r
26 @param[in] Protocol The protocol field in IP header\r
772db4bb 27\r
28 @return NULL if failed to allocate memory for the entry, otherwise\r
3e8c18da 29 the point to just created reassemble entry.\r
772db4bb 30\r
31**/\r
772db4bb 32IP4_ASSEMBLE_ENTRY *\r
33Ip4CreateAssembleEntry (\r
34 IN IP4_ADDR Dst,\r
35 IN IP4_ADDR Src,\r
36 IN UINT16 Id,\r
37 IN UINT8 Protocol\r
38 )\r
39{\r
40\r
41 IP4_ASSEMBLE_ENTRY *Assemble;\r
42\r
e48e37fc 43 Assemble = AllocatePool (sizeof (IP4_ASSEMBLE_ENTRY));\r
772db4bb 44\r
45 if (Assemble == NULL) {\r
46 return NULL;\r
47 }\r
48\r
e48e37fc 49 InitializeListHead (&Assemble->Link);\r
50 InitializeListHead (&Assemble->Fragments);\r
772db4bb 51\r
52 Assemble->Dst = Dst;\r
53 Assemble->Src = Src;\r
54 Assemble->Id = Id;\r
55 Assemble->Protocol = Protocol;\r
56 Assemble->TotalLen = 0;\r
57 Assemble->CurLen = 0;\r
58 Assemble->Head = NULL;\r
59 Assemble->Info = NULL;\r
60 Assemble->Life = IP4_FRAGMENT_LIFE;\r
61\r
62 return Assemble;\r
63}\r
64\r
65\r
66/**\r
96e1079f 67 Release all the fragments of a packet, then free the assemble entry.\r
772db4bb 68\r
3e8c18da 69 @param[in] Assemble The assemble entry to free\r
772db4bb 70\r
71**/\r
772db4bb 72VOID\r
73Ip4FreeAssembleEntry (\r
74 IN IP4_ASSEMBLE_ENTRY *Assemble\r
75 )\r
76{\r
e48e37fc 77 LIST_ENTRY *Entry;\r
78 LIST_ENTRY *Next;\r
772db4bb 79 NET_BUF *Fragment;\r
80\r
81 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Assemble->Fragments) {\r
82 Fragment = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);\r
83\r
e48e37fc 84 RemoveEntryList (Entry);\r
772db4bb 85 NetbufFree (Fragment);\r
86 }\r
87\r
e48e37fc 88 gBS->FreePool (Assemble);\r
772db4bb 89}\r
90\r
91\r
92/**\r
93 Initialize an already allocated assemble table. This is generally\r
94 the assemble table embedded in the IP4 service instance.\r
95\r
3e8c18da 96 @param[in, out] Table The assemble table to initialize.\r
772db4bb 97\r
98**/\r
99VOID\r
100Ip4InitAssembleTable (\r
96e1079f 101 IN OUT IP4_ASSEMBLE_TABLE *Table\r
772db4bb 102 )\r
103{\r
104 UINT32 Index;\r
105\r
106 for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {\r
e48e37fc 107 InitializeListHead (&Table->Bucket[Index]);\r
772db4bb 108 }\r
109}\r
110\r
111\r
112/**\r
113 Clean up the assemble table: remove all the fragments\r
114 and assemble entries.\r
115\r
3e8c18da 116 @param[in] Table The assemble table to clean up\r
772db4bb 117\r
118**/\r
119VOID\r
120Ip4CleanAssembleTable (\r
121 IN IP4_ASSEMBLE_TABLE *Table\r
122 )\r
123{\r
e48e37fc 124 LIST_ENTRY *Entry;\r
125 LIST_ENTRY *Next;\r
772db4bb 126 IP4_ASSEMBLE_ENTRY *Assemble;\r
127 UINT32 Index;\r
128\r
129 for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {\r
130 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Table->Bucket[Index]) {\r
131 Assemble = NET_LIST_USER_STRUCT (Entry, IP4_ASSEMBLE_ENTRY, Link);\r
132\r
e48e37fc 133 RemoveEntryList (Entry);\r
772db4bb 134 Ip4FreeAssembleEntry (Assemble);\r
135 }\r
136 }\r
137}\r
138\r
139\r
140/**\r
141 Trim the packet to fit in [Start, End), and update the per\r
142 packet information.\r
143\r
144 @param Packet Packet to trim\r
145 @param Start The sequence of the first byte to fit in\r
146 @param End One beyond the sequence of last byte to fit in.\r
147\r
772db4bb 148**/\r
772db4bb 149VOID\r
150Ip4TrimPacket (\r
96e1079f 151 IN OUT NET_BUF *Packet,\r
152 IN INTN Start,\r
153 IN INTN End\r
772db4bb 154 )\r
155{\r
156 IP4_CLIP_INFO *Info;\r
157 INTN Len;\r
158\r
159 Info = IP4_GET_CLIP_INFO (Packet);\r
160\r
161 ASSERT (Info->Start + Info->Length == Info->End);\r
162 ASSERT ((Info->Start < End) && (Start < Info->End));\r
163\r
164 if (Info->Start < Start) {\r
165 Len = Start - Info->Start;\r
166\r
167 NetbufTrim (Packet, (UINT32) Len, NET_BUF_HEAD);\r
168 Info->Start = Start;\r
169 Info->Length -= Len;\r
170 }\r
171\r
172 if (End < Info->End) {\r
173 Len = End - Info->End;\r
174\r
175 NetbufTrim (Packet, (UINT32) Len, NET_BUF_TAIL);\r
176 Info->End = End;\r
177 Info->Length -= Len;\r
178 }\r
179}\r
180\r
181\r
182/**\r
183 Release all the fragments of the packet. This is the callback for\r
184 the assembled packet's OnFree. It will free the assemble entry,\r
185 which in turn will free all the fragments of the packet.\r
186\r
3e8c18da 187 @param[in] Arg The assemble entry to free\r
772db4bb 188\r
189**/\r
772db4bb 190VOID\r
191Ip4OnFreeFragments (\r
192 IN VOID *Arg\r
193 )\r
194{\r
195 Ip4FreeAssembleEntry ((IP4_ASSEMBLE_ENTRY *) Arg);\r
196}\r
197\r
198\r
199/**\r
200 Reassemble the IP fragments. If all the fragments of the packet\r
201 have been received, it will wrap the packet in a net buffer then\r
202 return it to caller. If the packet can't be assembled, NULL is\r
203 return.\r
204\r
96e1079f 205 @param Table The assemble table used. New assemble entry will be created\r
206 if the Packet is from a new chain of fragments.\r
207 @param Packet The fragment to assemble. It might be freed if the fragment\r
208 can't be re-assembled.\r
772db4bb 209\r
210 @return NULL if the packet can't be reassemble. The point to just assembled\r
96e1079f 211 packet if all the fragments of the packet have arrived.\r
772db4bb 212\r
213**/\r
772db4bb 214NET_BUF *\r
215Ip4Reassemble (\r
96e1079f 216 IN OUT IP4_ASSEMBLE_TABLE *Table,\r
217 IN OUT NET_BUF *Packet\r
772db4bb 218 )\r
219{\r
220 IP4_HEAD *IpHead;\r
221 IP4_CLIP_INFO *This;\r
222 IP4_CLIP_INFO *Node;\r
223 IP4_ASSEMBLE_ENTRY *Assemble;\r
e48e37fc 224 LIST_ENTRY *Head;\r
225 LIST_ENTRY *Prev;\r
226 LIST_ENTRY *Cur;\r
772db4bb 227 NET_BUF *Fragment;\r
228 NET_BUF *NewPacket;\r
229 INTN Index;\r
230\r
f6b7393c 231 IpHead = Packet->Ip.Ip4;\r
772db4bb 232 This = IP4_GET_CLIP_INFO (Packet);\r
233\r
234 ASSERT (IpHead != NULL);\r
235\r
236 //\r
237 // First: find the related assemble entry\r
238 //\r
239 Assemble = NULL;\r
240 Index = IP4_ASSEMBLE_HASH (IpHead->Dst, IpHead->Src, IpHead->Id, IpHead->Protocol);\r
241\r
242 NET_LIST_FOR_EACH (Cur, &Table->Bucket[Index]) {\r
243 Assemble = NET_LIST_USER_STRUCT (Cur, IP4_ASSEMBLE_ENTRY, Link);\r
244\r
245 if ((Assemble->Dst == IpHead->Dst) && (Assemble->Src == IpHead->Src) &&\r
246 (Assemble->Id == IpHead->Id) && (Assemble->Protocol == IpHead->Protocol)) {\r
247 break;\r
248 }\r
249 }\r
250\r
251 //\r
252 // Create a new assemble entry if no assemble entry is related to this packet\r
253 //\r
254 if (Cur == &Table->Bucket[Index]) {\r
255 Assemble = Ip4CreateAssembleEntry (\r
256 IpHead->Dst,\r
257 IpHead->Src,\r
258 IpHead->Id,\r
259 IpHead->Protocol\r
260 );\r
261\r
262 if (Assemble == NULL) {\r
263 goto DROP;\r
264 }\r
265\r
e48e37fc 266 InsertHeadList (&Table->Bucket[Index], &Assemble->Link);\r
772db4bb 267 }\r
894d038a 268 //\r
269 // Assemble shouldn't be NULL here\r
270 //\r
271 ASSERT (Assemble != NULL);\r
772db4bb 272\r
273 //\r
274 // Find the point to insert the packet: before the first\r
275 // fragment with THIS.Start < CUR.Start. the previous one\r
276 // has PREV.Start <= THIS.Start < CUR.Start.\r
277 //\r
278 Head = &Assemble->Fragments;\r
279\r
280 NET_LIST_FOR_EACH (Cur, Head) {\r
281 Fragment = NET_LIST_USER_STRUCT (Cur, NET_BUF, List);\r
282\r
283 if (This->Start < IP4_GET_CLIP_INFO (Fragment)->Start) {\r
284 break;\r
285 }\r
286 }\r
287\r
288 //\r
289 // Check whether the current fragment overlaps with the previous one.\r
290 // It holds that: PREV.Start <= THIS.Start < THIS.End. Only need to\r
291 // check whether THIS.Start < PREV.End for overlap. If two fragments\r
292 // overlaps, trim the overlapped part off THIS fragment.\r
293 //\r
294 if ((Prev = Cur->ForwardLink) != Head) {\r
295 Fragment = NET_LIST_USER_STRUCT (Prev, NET_BUF, List);\r
296 Node = IP4_GET_CLIP_INFO (Fragment);\r
297\r
298 if (This->Start < Node->End) {\r
299 if (This->End <= Node->End) {\r
300 NetbufFree (Packet);\r
301 return NULL;\r
302 }\r
303\r
304 Ip4TrimPacket (Packet, Node->End, This->End);\r
305 }\r
306 }\r
307\r
308 //\r
309 // Insert the fragment into the packet. The fragment may be removed\r
310 // from the list by the following checks.\r
311 //\r
312 NetListInsertBefore (Cur, &Packet->List);\r
313\r
314 //\r
315 // Check the packets after the insert point. It holds that:\r
316 // THIS.Start <= NODE.Start < NODE.End. The equality holds\r
317 // if PREV and NEXT are continuous. THIS fragment may fill\r
318 // several holes. Remove the completely overlapped fragments\r
319 //\r
320 while (Cur != Head) {\r
321 Fragment = NET_LIST_USER_STRUCT (Cur, NET_BUF, List);\r
322 Node = IP4_GET_CLIP_INFO (Fragment);\r
323\r
324 //\r
325 // Remove fragments completely overlapped by this fragment\r
326 //\r
327 if (Node->End <= This->End) {\r
328 Cur = Cur->ForwardLink;\r
329\r
e48e37fc 330 RemoveEntryList (&Fragment->List);\r
772db4bb 331 Assemble->CurLen -= Node->Length;\r
332\r
333 NetbufFree (Fragment);\r
334 continue;\r
335 }\r
336\r
337 //\r
338 // The conditions are: THIS.Start <= NODE.Start, and THIS.End <\r
339 // NODE.End. Two fragments overlaps if NODE.Start < THIS.End.\r
340 // If two fragments start at the same offset, remove THIS fragment\r
341 // because ((THIS.Start == NODE.Start) && (THIS.End < NODE.End)).\r
342 //\r
343 if (Node->Start < This->End) {\r
344 if (This->Start == Node->Start) {\r
e48e37fc 345 RemoveEntryList (&Packet->List);\r
772db4bb 346 goto DROP;\r
347 }\r
348\r
349 Ip4TrimPacket (Packet, This->Start, Node->Start);\r
350 }\r
351\r
352 break;\r
353 }\r
354\r
355 //\r
356 // Update the assemble info: increase the current length. If it is\r
357 // the frist fragment, update the packet's IP head and per packet\r
358 // info. If it is the last fragment, update the total length.\r
359 //\r
360 Assemble->CurLen += This->Length;\r
361\r
362 if (This->Start == 0) {\r
363 //\r
364 // Once the first fragment is enqueued, it can't be removed\r
365 // from the fragment list. So, Assemble->Head always point\r
366 // to valid memory area.\r
367 //\r
368 ASSERT (Assemble->Head == NULL);\r
369\r
370 Assemble->Head = IpHead;\r
371 Assemble->Info = IP4_GET_CLIP_INFO (Packet);\r
372 }\r
373\r
374 //\r
375 // Don't update the length more than once.\r
376 //\r
377 if (IP4_LAST_FRAGMENT (IpHead->Fragment) && (Assemble->TotalLen == 0)) {\r
378 Assemble->TotalLen = This->End;\r
379 }\r
380\r
381 //\r
382 // Deliver the whole packet if all the fragments received.\r
383 // All fragments received if:\r
96e1079f 384 // 1. received the last one, so, the total length is know\r
772db4bb 385 // 2. received all the data. If the last fragment on the\r
386 // queue ends at the total length, all data is received.\r
387 //\r
388 if ((Assemble->TotalLen != 0) && (Assemble->CurLen >= Assemble->TotalLen)) {\r
389\r
e48e37fc 390 RemoveEntryList (&Assemble->Link);\r
772db4bb 391\r
392 //\r
393 // If the packet is properly formated, the last fragment's End\r
394 // equals to the packet's total length. Otherwise, the packet\r
395 // is a fake, drop it now.\r
396 //\r
397 Fragment = NET_LIST_USER_STRUCT (Head->BackLink, NET_BUF, List);\r
398\r
399 if (IP4_GET_CLIP_INFO (Fragment)->End != Assemble->TotalLen) {\r
400 Ip4FreeAssembleEntry (Assemble);\r
401 return NULL;\r
402 }\r
403\r
404 //\r
405 // Wrap the packet in a net buffer then deliver it up\r
406 //\r
407 NewPacket = NetbufFromBufList (\r
408 &Assemble->Fragments,\r
409 0,\r
410 0,\r
411 Ip4OnFreeFragments,\r
412 Assemble\r
413 );\r
414\r
415 if (NewPacket == NULL) {\r
416 Ip4FreeAssembleEntry (Assemble);\r
417 return NULL;\r
418 }\r
419\r
f6b7393c 420 NewPacket->Ip.Ip4 = Assemble->Head;\r
687a2e5f 421 CopyMem (IP4_GET_CLIP_INFO (NewPacket), Assemble->Info, sizeof (*IP4_GET_CLIP_INFO (NewPacket)));\r
772db4bb 422 return NewPacket;\r
423 }\r
424\r
425 return NULL;\r
426\r
427DROP:\r
428 NetbufFree (Packet);\r
429 return NULL;\r
430}\r
431\r
432\r
433/**\r
434 The IP4 input routine. It is called by the IP4_INTERFACE when a\r
435 IP4 fragment is received from MNP.\r
436\r
3e8c18da 437 @param[in] Ip4Instance The IP4 child that request the receive, most like\r
772db4bb 438 it is NULL.\r
3e8c18da 439 @param[in] Packet The IP4 packet received.\r
440 @param[in] IoStatus The return status of receive request.\r
441 @param[in] Flag The link layer flag for the packet received, such\r
772db4bb 442 as multicast.\r
3e8c18da 443 @param[in] Context The IP4 service instance that own the MNP.\r
772db4bb 444\r
445**/\r
446VOID\r
447Ip4AccpetFrame (\r
448 IN IP4_PROTOCOL *Ip4Instance,\r
449 IN NET_BUF *Packet,\r
450 IN EFI_STATUS IoStatus,\r
451 IN UINT32 Flag,\r
452 IN VOID *Context\r
453 )\r
454{\r
455 IP4_SERVICE *IpSb;\r
456 IP4_CLIP_INFO *Info;\r
457 IP4_HEAD *Head;\r
458 UINT32 HeadLen;\r
459 UINT32 OptionLen;\r
460 UINT32 TotalLen;\r
461 UINT16 Checksum;\r
462\r
463 IpSb = (IP4_SERVICE *) Context;\r
464\r
465 if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DESTORY)) {\r
466 goto DROP;\r
467 }\r
468\r
469 //\r
96e1079f 470 // Check that the IP4 header is correctly formatted\r
772db4bb 471 //\r
472 if (Packet->TotalSize < IP4_MIN_HEADLEN) {\r
473 goto RESTART;\r
474 }\r
475\r
476 Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);\r
477 HeadLen = (Head->HeadLen << 2);\r
478 TotalLen = NTOHS (Head->TotalLen);\r
479\r
480 //\r
481 // Mnp may deliver frame trailer sequence up, trim it off.\r
482 //\r
483 if (TotalLen < Packet->TotalSize) {\r
484 NetbufTrim (Packet, Packet->TotalSize - TotalLen, FALSE);\r
485 }\r
486\r
487 if ((Head->Ver != 4) || (HeadLen < IP4_MIN_HEADLEN) ||\r
488 (TotalLen < HeadLen) || (TotalLen != Packet->TotalSize)) {\r
489 goto RESTART;\r
490 }\r
491\r
492 //\r
493 // Some OS may send IP packets without checksum.\r
494 //\r
687a2e5f 495 Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Head, HeadLen));\r
772db4bb 496\r
497 if ((Head->Checksum != 0) && (Checksum != 0)) {\r
498 goto RESTART;\r
499 }\r
500\r
501 //\r
502 // Convert the IP header to host byte order, then get the per packet info.\r
503 //\r
f6b7393c 504 Packet->Ip.Ip4 = Ip4NtohHead (Head);\r
772db4bb 505\r
506 Info = IP4_GET_CLIP_INFO (Packet);\r
507 Info->LinkFlag = Flag;\r
508 Info->CastType = Ip4GetHostCast (IpSb, Head->Dst, Head->Src);\r
509 Info->Start = (Head->Fragment & IP4_HEAD_OFFSET_MASK) << 3;\r
510 Info->Length = Head->TotalLen - HeadLen;\r
511 Info->End = Info->Start + Info->Length;\r
512 Info->Status = EFI_SUCCESS;\r
513\r
514 //\r
515 // The packet is destinated to us if the CastType is non-zero.\r
516 //\r
517 if ((Info->CastType == 0) || (Info->End > IP4_MAX_PACKET_SIZE)) {\r
518 goto RESTART;\r
519 }\r
520\r
521 //\r
522 // Validate the options. Don't call the Ip4OptionIsValid if\r
523 // there is no option to save some CPU process.\r
524 //\r
525 OptionLen = HeadLen - IP4_MIN_HEADLEN;\r
526\r
527 if ((OptionLen > 0) && !Ip4OptionIsValid ((UINT8 *) (Head + 1), OptionLen, TRUE)) {\r
528 goto RESTART;\r
529 }\r
530\r
531 //\r
532 // Trim the head off, after this point, the packet is headless.\r
533 // and Packet->TotalLen == Info->Length.\r
534 //\r
535 NetbufTrim (Packet, HeadLen, TRUE);\r
536\r
537 //\r
538 // Reassemble the packet if this is a fragment. The packet is a\r
539 // fragment if its head has MF (more fragment) set, or it starts\r
540 // at non-zero byte.\r
541 //\r
b2c0a175 542 if (((Head->Fragment & IP4_HEAD_MF_MASK) != 0) || (Info->Start != 0)) {\r
772db4bb 543 //\r
544 // Drop the fragment if DF is set but it is fragmented. Gateway\r
545 // need to send a type 4 destination unreache ICMP message here.\r
546 //\r
b2c0a175 547 if ((Head->Fragment & IP4_HEAD_DF_MASK) != 0) {\r
772db4bb 548 goto RESTART;\r
549 }\r
550\r
551 //\r
552 // The length of all but the last fragments is in the unit of 8 bytes.\r
553 //\r
b2c0a175 554 if (((Head->Fragment & IP4_HEAD_MF_MASK) != 0) && (Info->Length % 8 != 0)) {\r
772db4bb 555 goto RESTART;\r
556 }\r
557\r
558 Packet = Ip4Reassemble (&IpSb->Assemble, Packet);\r
559\r
560 //\r
561 // Packet assembly isn't complete, start receive more packet.\r
562 //\r
563 if (Packet == NULL) {\r
564 goto RESTART;\r
565 }\r
566 }\r
567\r
568 //\r
569 // Packet may have been changed. Head, HeadLen, TotalLen, and\r
570 // info must be reloaded bofore use. The ownership of the packet\r
571 // is transfered to the packet process logic.\r
572 //\r
f6b7393c 573 Head = Packet->Ip.Ip4;\r
772db4bb 574 IP4_GET_CLIP_INFO (Packet)->Status = EFI_SUCCESS;\r
575\r
576 switch (Head->Protocol) {\r
f6b7393c 577 case EFI_IP_PROTO_ICMP:\r
772db4bb 578 Ip4IcmpHandle (IpSb, Head, Packet);\r
579 break;\r
580\r
581 case IP4_PROTO_IGMP:\r
582 Ip4IgmpHandle (IpSb, Head, Packet);\r
583 break;\r
584\r
585 default:\r
586 Ip4Demultiplex (IpSb, Head, Packet);\r
587 }\r
588\r
589 Packet = NULL;\r
590\r
36ee91ca 591 //\r
592 // Dispatch the DPCs queued by the NotifyFunction of the rx token's events\r
593 // which are signaled with received data.\r
594 //\r
d8d26fb2 595 DispatchDpc ();\r
36ee91ca 596\r
772db4bb 597RESTART:\r
598 Ip4ReceiveFrame (IpSb->DefaultInterface, NULL, Ip4AccpetFrame, IpSb);\r
599\r
600DROP:\r
601 if (Packet != NULL) {\r
602 NetbufFree (Packet);\r
603 }\r
604\r
605 return ;\r
606}\r
607\r
608\r
609/**\r
610 Check whether this IP child accepts the packet.\r
611\r
3e8c18da 612 @param[in] IpInstance The IP child to check\r
613 @param[in] Head The IP header of the packet\r
614 @param[in] Packet The data of the packet\r
772db4bb 615\r
96e1079f 616 @retval TRUE If the child wants to receive the packet.\r
617 @retval FALSE Otherwise.\r
772db4bb 618\r
619**/\r
620BOOLEAN\r
621Ip4InstanceFrameAcceptable (\r
622 IN IP4_PROTOCOL *IpInstance,\r
623 IN IP4_HEAD *Head,\r
624 IN NET_BUF *Packet\r
625 )\r
626{\r
627 IP4_ICMP_ERROR_HEAD Icmp;\r
628 EFI_IP4_CONFIG_DATA *Config;\r
629 IP4_CLIP_INFO *Info;\r
630 UINT16 Proto;\r
631 UINT32 Index;\r
632\r
633 Config = &IpInstance->ConfigData;\r
634\r
635 //\r
636 // Dirty trick for the Tiano UEFI network stack implmentation. If\r
637 // ReceiveTimeout == -1, the receive of the packet for this instance\r
96e1079f 638 // is disabled. The UEFI spec don't have such capability. We add\r
772db4bb 639 // this to improve the performance because IP will make a copy of\r
640 // the received packet for each accepting instance. Some IP instances\r
641 // used by UDP/TCP only send packets, they don't wants to receive.\r
642 //\r
643 if (Config->ReceiveTimeout == (UINT32)(-1)) {\r
644 return FALSE;\r
645 }\r
646\r
647 if (Config->AcceptPromiscuous) {\r
648 return TRUE;\r
649 }\r
650\r
651 //\r
652 // Use protocol from the IP header embedded in the ICMP error\r
653 // message to filter, instead of ICMP itself. ICMP handle will\r
654 // can Ip4Demultiplex to deliver ICMP errors.\r
655 //\r
656 Proto = Head->Protocol;\r
657\r
f6b7393c 658 if (Proto == EFI_IP_PROTO_ICMP) {\r
772db4bb 659 NetbufCopy (Packet, 0, sizeof (Icmp.Head), (UINT8 *) &Icmp.Head);\r
660\r
661 if (mIcmpClass[Icmp.Head.Type].IcmpClass == ICMP_ERROR_MESSAGE) {\r
662 if (!Config->AcceptIcmpErrors) {\r
663 return FALSE;\r
664 }\r
665\r
666 NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);\r
667 Proto = Icmp.IpHead.Protocol;\r
668 }\r
669 }\r
670\r
671 //\r
672 // Match the protocol\r
673 //\r
674 if (!Config->AcceptAnyProtocol && (Proto != Config->DefaultProtocol)) {\r
675 return FALSE;\r
676 }\r
677\r
678 //\r
679 // Check for broadcast, the caller has computed the packet's\r
680 // cast type for this child's interface.\r
681 //\r
682 Info = IP4_GET_CLIP_INFO (Packet);\r
683\r
684 if (IP4_IS_BROADCAST (Info->CastType)) {\r
685 return Config->AcceptBroadcast;\r
686 }\r
687\r
688 //\r
689 // If it is a multicast packet, check whether we are in the group.\r
690 //\r
691 if (Info->CastType == IP4_MULTICAST) {\r
692 //\r
693 // Receive the multicast if the instance wants to receive all packets.\r
694 //\r
695 if (!IpInstance->ConfigData.UseDefaultAddress && (IpInstance->Interface->Ip == 0)) {\r
696 return TRUE;\r
697 }\r
698\r
699 for (Index = 0; Index < IpInstance->GroupCount; Index++) {\r
700 if (IpInstance->Groups[Index] == HTONL (Head->Dst)) {\r
701 break;\r
702 }\r
703 }\r
704\r
705 return (BOOLEAN)(Index < IpInstance->GroupCount);\r
706 }\r
707\r
708 return TRUE;\r
709}\r
710\r
711\r
712/**\r
713 Enqueue a shared copy of the packet to the IP4 child if the\r
714 packet is acceptable to it. Here the data of the packet is\r
715 shared, but the net buffer isn't.\r
716\r
3e8c18da 717 @param[in] IpInstance The IP4 child to enqueue the packet to\r
718 @param[in] Head The IP header of the received packet\r
719 @param[in] Packet The data of the received packet\r
772db4bb 720\r
721 @retval EFI_NOT_STARTED The IP child hasn't been configured.\r
722 @retval EFI_INVALID_PARAMETER The child doesn't want to receive the packet\r
723 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resource\r
724 @retval EFI_SUCCESS A shared copy the packet is enqueued to the child.\r
725\r
726**/\r
727EFI_STATUS\r
728Ip4InstanceEnquePacket (\r
729 IN IP4_PROTOCOL *IpInstance,\r
730 IN IP4_HEAD *Head,\r
731 IN NET_BUF *Packet\r
732 )\r
733{\r
734 IP4_CLIP_INFO *Info;\r
735 NET_BUF *Clone;\r
736\r
737 //\r
738 // Check whether the packet is acceptable to this instance.\r
739 //\r
740 if (IpInstance->State != IP4_STATE_CONFIGED) {\r
741 return EFI_NOT_STARTED;\r
742 }\r
743\r
744 if (!Ip4InstanceFrameAcceptable (IpInstance, Head, Packet)) {\r
745 return EFI_INVALID_PARAMETER;\r
746 }\r
747\r
748 //\r
749 // Enque a shared copy of the packet.\r
750 //\r
751 Clone = NetbufClone (Packet);\r
752\r
753 if (Clone == NULL) {\r
754 return EFI_OUT_OF_RESOURCES;\r
755 }\r
756\r
757 //\r
758 // Set the receive time out for the assembled packet. If it expires,\r
759 // packet will be removed from the queue.\r
760 //\r
761 Info = IP4_GET_CLIP_INFO (Clone);\r
762 Info->Life = IP4_US_TO_SEC (IpInstance->ConfigData.ReceiveTimeout);\r
763\r
e48e37fc 764 InsertTailList (&IpInstance->Received, &Clone->List);\r
772db4bb 765 return EFI_SUCCESS;\r
766}\r
767\r
768\r
769/**\r
770 The signal handle of IP4's recycle event. It is called back\r
771 when the upper layer release the packet.\r
772\r
3e8c18da 773 @param Event The IP4's recycle event.\r
774 @param Context The context of the handle, which is a\r
775 IP4_RXDATA_WRAP\r
772db4bb 776\r
777**/\r
772db4bb 778VOID\r
779EFIAPI\r
780Ip4OnRecyclePacket (\r
781 IN EFI_EVENT Event,\r
782 IN VOID *Context\r
783 )\r
784{\r
785 IP4_RXDATA_WRAP *Wrap;\r
786\r
787 Wrap = (IP4_RXDATA_WRAP *) Context;\r
788\r
e48e37fc 789 EfiAcquireLockOrFail (&Wrap->IpInstance->RecycleLock);\r
790 RemoveEntryList (&Wrap->Link);\r
791 EfiReleaseLock (&Wrap->IpInstance->RecycleLock);\r
772db4bb 792\r
793 ASSERT (!NET_BUF_SHARED (Wrap->Packet));\r
794 NetbufFree (Wrap->Packet);\r
795\r
796 gBS->CloseEvent (Wrap->RxData.RecycleSignal);\r
e48e37fc 797 gBS->FreePool (Wrap);\r
772db4bb 798}\r
799\r
800\r
801/**\r
802 Wrap the received packet to a IP4_RXDATA_WRAP, which will be\r
803 delivered to the upper layer. Each IP4 child that accepts the\r
804 packet will get a not-shared copy of the packet which is wrapped\r
805 in the IP4_RXDATA_WRAP. The IP4_RXDATA_WRAP->RxData is passed\r
806 to the upper layer. Upper layer will signal the recycle event in\r
807 it when it is done with the packet.\r
808\r
3e8c18da 809 @param[in] IpInstance The IP4 child to receive the packet\r
810 @param[in] Packet The packet to deliver up.\r
772db4bb 811\r
3e8c18da 812 @retval Wrap if warp the packet succeed.\r
813 @retval NULL failed to wrap the packet .\r
772db4bb 814\r
815**/\r
816IP4_RXDATA_WRAP *\r
817Ip4WrapRxData (\r
818 IN IP4_PROTOCOL *IpInstance,\r
819 IN NET_BUF *Packet\r
820 )\r
821{\r
822 IP4_RXDATA_WRAP *Wrap;\r
823 EFI_IP4_RECEIVE_DATA *RxData;\r
824 EFI_STATUS Status;\r
825\r
e48e37fc 826 Wrap = AllocatePool (IP4_RXDATA_WRAP_SIZE (Packet->BlockOpNum));\r
772db4bb 827\r
828 if (Wrap == NULL) {\r
829 return NULL;\r
830 }\r
831\r
e48e37fc 832 InitializeListHead (&Wrap->Link);\r
772db4bb 833\r
834 Wrap->IpInstance = IpInstance;\r
835 Wrap->Packet = Packet;\r
836 RxData = &Wrap->RxData;\r
837\r
e48e37fc 838 ZeroMem (&RxData->TimeStamp, sizeof (EFI_TIME));\r
772db4bb 839\r
840 Status = gBS->CreateEvent (\r
841 EVT_NOTIFY_SIGNAL,\r
e48e37fc 842 TPL_NOTIFY,\r
772db4bb 843 Ip4OnRecyclePacket,\r
844 Wrap,\r
845 &RxData->RecycleSignal\r
846 );\r
847\r
848 if (EFI_ERROR (Status)) {\r
e48e37fc 849 gBS->FreePool (Wrap);\r
772db4bb 850 return NULL;\r
851 }\r
852\r
f6b7393c 853 ASSERT (Packet->Ip.Ip4 != NULL);\r
772db4bb 854\r
855 //\r
856 // The application expects a network byte order header.\r
857 //\r
f6b7393c 858 RxData->HeaderLength = (Packet->Ip.Ip4->HeadLen << 2);\r
859 RxData->Header = (EFI_IP4_HEADER *) Ip4NtohHead (Packet->Ip.Ip4);\r
772db4bb 860\r
861 RxData->OptionsLength = RxData->HeaderLength - IP4_MIN_HEADLEN;\r
862 RxData->Options = NULL;\r
863\r
864 if (RxData->OptionsLength != 0) {\r
865 RxData->Options = (VOID *) (RxData->Header + 1);\r
866 }\r
867\r
868 RxData->DataLength = Packet->TotalSize;\r
869\r
870 //\r
871 // Build the fragment table to be delivered up.\r
872 //\r
873 RxData->FragmentCount = Packet->BlockOpNum;\r
874 NetbufBuildExt (Packet, (NET_FRAGMENT *) RxData->FragmentTable, &RxData->FragmentCount);\r
875\r
876 return Wrap;\r
877}\r
878\r
879\r
880/**\r
881 Deliver the received packets to upper layer if there are both received\r
882 requests and enqueued packets. If the enqueued packet is shared, it will\r
883 duplicate it to a non-shared packet, release the shared packet, then\r
884 deliver the non-shared packet up.\r
885\r
3e8c18da 886 @param[in] IpInstance The IP child to deliver the packet up.\r
772db4bb 887\r
888 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the\r
889 packets.\r
890 @retval EFI_SUCCESS All the enqueued packets that can be delivered\r
891 are delivered up.\r
892\r
893**/\r
894EFI_STATUS\r
895Ip4InstanceDeliverPacket (\r
896 IN IP4_PROTOCOL *IpInstance\r
897 )\r
898{\r
899 EFI_IP4_COMPLETION_TOKEN *Token;\r
900 IP4_RXDATA_WRAP *Wrap;\r
901 NET_BUF *Packet;\r
902 NET_BUF *Dup;\r
903 UINT8 *Head;\r
904\r
905 //\r
906 // Deliver a packet if there are both a packet and a receive token.\r
907 //\r
e48e37fc 908 while (!IsListEmpty (&IpInstance->Received) &&\r
772db4bb 909 !NetMapIsEmpty (&IpInstance->RxTokens)) {\r
910\r
911 Packet = NET_LIST_HEAD (&IpInstance->Received, NET_BUF, List);\r
912\r
913 if (!NET_BUF_SHARED (Packet)) {\r
914 //\r
915 // If this is the only instance that wants the packet, wrap it up.\r
916 //\r
917 Wrap = Ip4WrapRxData (IpInstance, Packet);\r
918\r
919 if (Wrap == NULL) {\r
920 return EFI_OUT_OF_RESOURCES;\r
921 }\r
922\r
e48e37fc 923 RemoveEntryList (&Packet->List);\r
772db4bb 924\r
925 } else {\r
926 //\r
927 // Create a duplicated packet if this packet is shared\r
928 //\r
929 Dup = NetbufDuplicate (Packet, NULL, IP4_MAX_HEADLEN);\r
930\r
931 if (Dup == NULL) {\r
932 return EFI_OUT_OF_RESOURCES;\r
933 }\r
934\r
935 //\r
936 // Copy the IP head over. The packet to deliver up is\r
937 // headless. Trim the head off after copy. The IP head\r
938 // may be not continuous before the data.\r
939 //\r
940 Head = NetbufAllocSpace (Dup, IP4_MAX_HEADLEN, NET_BUF_HEAD);\r
f6b7393c 941 Dup->Ip.Ip4 = (IP4_HEAD *) Head;\r
772db4bb 942\r
f6b7393c 943 CopyMem (Head, Packet->Ip.Ip4, Packet->Ip.Ip4->HeadLen << 2);\r
772db4bb 944 NetbufTrim (Dup, IP4_MAX_HEADLEN, TRUE);\r
945\r
946 Wrap = Ip4WrapRxData (IpInstance, Dup);\r
947\r
948 if (Wrap == NULL) {\r
949 NetbufFree (Dup);\r
950 return EFI_OUT_OF_RESOURCES;\r
951 }\r
952\r
e48e37fc 953 RemoveEntryList (&Packet->List);\r
772db4bb 954 NetbufFree (Packet);\r
955\r
956 Packet = Dup;\r
957 }\r
958\r
959 //\r
960 // Insert it into the delivered packet, then get a user's\r
961 // receive token, pass the wrapped packet up.\r
962 //\r
e48e37fc 963 EfiAcquireLockOrFail (&IpInstance->RecycleLock);\r
964 InsertHeadList (&IpInstance->Delivered, &Wrap->Link);\r
965 EfiReleaseLock (&IpInstance->RecycleLock);\r
772db4bb 966\r
967 Token = NetMapRemoveHead (&IpInstance->RxTokens, NULL);\r
968 Token->Status = IP4_GET_CLIP_INFO (Packet)->Status;\r
969 Token->Packet.RxData = &Wrap->RxData;\r
970\r
971 gBS->SignalEvent (Token->Event);\r
972 }\r
973\r
974 return EFI_SUCCESS;\r
975}\r
976\r
977\r
978/**\r
979 Enqueue a received packet to all the IP children that share\r
980 the same interface.\r
981\r
3e8c18da 982 @param[in] IpSb The IP4 service instance that receive the packet\r
983 @param[in] Head The header of the received packet\r
984 @param[in] Packet The data of the received packet\r
985 @param[in] IpIf The interface to enqueue the packet to\r
772db4bb 986\r
987 @return The number of the IP4 children that accepts the packet\r
988\r
989**/\r
990INTN\r
991Ip4InterfaceEnquePacket (\r
992 IN IP4_SERVICE *IpSb,\r
993 IN IP4_HEAD *Head,\r
994 IN NET_BUF *Packet,\r
995 IN IP4_INTERFACE *IpIf\r
996 )\r
997{\r
998 IP4_PROTOCOL *IpInstance;\r
999 IP4_CLIP_INFO *Info;\r
e48e37fc 1000 LIST_ENTRY *Entry;\r
772db4bb 1001 INTN Enqueued;\r
1002 INTN LocalType;\r
1003 INTN SavedType;\r
1004\r
1005 //\r
1006 // First, check that the packet is acceptable to this interface\r
1007 // and find the local cast type for the interface. A packet sent\r
1008 // to say 192.168.1.1 should NOT be delliever to 10.0.0.1 unless\r
1009 // promiscuous receiving.\r
1010 //\r
1011 LocalType = 0;\r
1012 Info = IP4_GET_CLIP_INFO (Packet);\r
1013\r
1014 if ((Info->CastType == IP4_MULTICAST) || (Info->CastType == IP4_LOCAL_BROADCAST)) {\r
1015 //\r
1016 // If the CastType is multicast, don't need to filter against\r
1017 // the group address here, Ip4InstanceFrameAcceptable will do\r
1018 // that later.\r
1019 //\r
1020 LocalType = Info->CastType;\r
1021\r
1022 } else {\r
1023 //\r
1024 // Check the destination againist local IP. If the station\r
1025 // address is 0.0.0.0, it means receiving all the IP destined\r
1026 // to local non-zero IP. Otherwise, it is necessary to compare\r
1027 // the destination to the interface's IP address.\r
1028 //\r
1029 if (IpIf->Ip == IP4_ALLZERO_ADDRESS) {\r
1030 LocalType = IP4_LOCAL_HOST;\r
1031\r
1032 } else {\r
1033 LocalType = Ip4GetNetCast (Head->Dst, IpIf);\r
1034\r
1035 if ((LocalType == 0) && IpIf->PromiscRecv) {\r
1036 LocalType = IP4_PROMISCUOUS;\r
1037 }\r
1038 }\r
1039 }\r
1040\r
1041 if (LocalType == 0) {\r
1042 return 0;\r
1043 }\r
1044\r
1045 //\r
1046 // Iterate through the ip instances on the interface, enqueue\r
1047 // the packet if filter passed. Save the original cast type,\r
1048 // and pass the local cast type to the IP children on the\r
1049 // interface. The global cast type will be restored later.\r
1050 //\r
1051 SavedType = Info->CastType;\r
1052 Info->CastType = LocalType;\r
1053\r
1054 Enqueued = 0;\r
1055\r
1056 NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {\r
1057 IpInstance = NET_LIST_USER_STRUCT (Entry, IP4_PROTOCOL, AddrLink);\r
1058 NET_CHECK_SIGNATURE (IpInstance, IP4_PROTOCOL_SIGNATURE);\r
1059\r
1060 if (Ip4InstanceEnquePacket (IpInstance, Head, Packet) == EFI_SUCCESS) {\r
1061 Enqueued++;\r
1062 }\r
1063 }\r
1064\r
1065 Info->CastType = SavedType;\r
1066 return Enqueued;\r
1067}\r
1068\r
1069\r
1070/**\r
1071 Deliver the packet for each IP4 child on the interface.\r
1072\r
3e8c18da 1073 @param[in] IpSb The IP4 service instance that received the packet\r
1074 @param[in] IpIf The IP4 interface to deliver the packet.\r
772db4bb 1075\r
1076 @retval EFI_SUCCESS It always returns EFI_SUCCESS now\r
1077\r
1078**/\r
1079EFI_STATUS\r
1080Ip4InterfaceDeliverPacket (\r
1081 IN IP4_SERVICE *IpSb,\r
1082 IN IP4_INTERFACE *IpIf\r
1083 )\r
1084{\r
1085 IP4_PROTOCOL *Ip4Instance;\r
e48e37fc 1086 LIST_ENTRY *Entry;\r
772db4bb 1087\r
1088 NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {\r
1089 Ip4Instance = NET_LIST_USER_STRUCT (Entry, IP4_PROTOCOL, AddrLink);\r
1090 Ip4InstanceDeliverPacket (Ip4Instance);\r
1091 }\r
1092\r
1093 return EFI_SUCCESS;\r
1094}\r
1095\r
1096\r
1097/**\r
1098 Demultiple the packet. the packet delivery is processed in two\r
1099 passes. The first pass will enque a shared copy of the packet\r
1100 to each IP4 child that accepts the packet. The second pass will\r
1101 deliver a non-shared copy of the packet to each IP4 child that\r
1102 has pending receive requests. Data is copied if more than one\r
96e1079f 1103 child wants to consume the packet because each IP child needs\r
772db4bb 1104 its own copy of the packet to make changes.\r
1105\r
3e8c18da 1106 @param[in] IpSb The IP4 service instance that received the packet\r
1107 @param[in] Head The header of the received packet\r
1108 @param[in] Packet The data of the received packet\r
772db4bb 1109\r
1110 @retval EFI_NOT_FOUND No IP child accepts the packet\r
1111 @retval EFI_SUCCESS The packet is enqueued or delivered to some IP\r
1112 children.\r
1113\r
1114**/\r
1115EFI_STATUS\r
1116Ip4Demultiplex (\r
1117 IN IP4_SERVICE *IpSb,\r
1118 IN IP4_HEAD *Head,\r
1119 IN NET_BUF *Packet\r
1120 )\r
1121{\r
e48e37fc 1122 LIST_ENTRY *Entry;\r
772db4bb 1123 IP4_INTERFACE *IpIf;\r
1124 INTN Enqueued;\r
1125\r
1126 //\r
1127 // Two pass delivery: first, enque a shared copy of the packet\r
1128 // to each instance that accept the packet.\r
1129 //\r
1130 Enqueued = 0;\r
1131\r
1132 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {\r
1133 IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);\r
1134\r
1135 if (IpIf->Configured) {\r
1136 Enqueued += Ip4InterfaceEnquePacket (IpSb, Head, Packet, IpIf);\r
1137 }\r
1138 }\r
1139\r
1140 //\r
1141 // Second: deliver a duplicate of the packet to each instance.\r
1142 // Release the local reference first, so that the last instance\r
1143 // getting the packet will not copy the data.\r
1144 //\r
1145 NetbufFree (Packet);\r
1146\r
1147 if (Enqueued == 0) {\r
1148 return EFI_NOT_FOUND;\r
1149 }\r
1150\r
1151 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {\r
1152 IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);\r
1153\r
1154 if (IpIf->Configured) {\r
1155 Ip4InterfaceDeliverPacket (IpSb, IpIf);\r
1156 }\r
1157 }\r
1158\r
1159 return EFI_SUCCESS;\r
1160}\r
1161\r
1162\r
1163/**\r
1164 Timeout the fragment and enqueued packets.\r
1165\r
3e8c18da 1166 @param[in] IpSb The IP4 service instance to timeout\r
772db4bb 1167\r
1168**/\r
1169VOID\r
1170Ip4PacketTimerTicking (\r
1171 IN IP4_SERVICE *IpSb\r
1172 )\r
1173{\r
e48e37fc 1174 LIST_ENTRY *InstanceEntry;\r
1175 LIST_ENTRY *Entry;\r
1176 LIST_ENTRY *Next;\r
772db4bb 1177 IP4_PROTOCOL *IpInstance;\r
1178 IP4_ASSEMBLE_ENTRY *Assemble;\r
1179 NET_BUF *Packet;\r
1180 IP4_CLIP_INFO *Info;\r
1181 UINT32 Index;\r
1182\r
1183 //\r
1184 // First, time out the fragments. The packet's life is counting down\r
1185 // once the first-arrived fragment was received.\r
1186 //\r
1187 for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {\r
1188 NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpSb->Assemble.Bucket[Index]) {\r
1189 Assemble = NET_LIST_USER_STRUCT (Entry, IP4_ASSEMBLE_ENTRY, Link);\r
1190\r
1191 if ((Assemble->Life > 0) && (--Assemble->Life == 0)) {\r
e48e37fc 1192 RemoveEntryList (Entry);\r
772db4bb 1193 Ip4FreeAssembleEntry (Assemble);\r
1194 }\r
1195 }\r
1196 }\r
1197\r
1198 NET_LIST_FOR_EACH (InstanceEntry, &IpSb->Children) {\r
1199 IpInstance = NET_LIST_USER_STRUCT (InstanceEntry, IP4_PROTOCOL, Link);\r
1200\r
1201 //\r
1202 // Second, time out the assembled packets enqueued on each IP child.\r
1203 //\r
1204 NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpInstance->Received) {\r
1205 Packet = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);\r
1206 Info = IP4_GET_CLIP_INFO (Packet);\r
1207\r
1208 if ((Info->Life > 0) && (--Info->Life == 0)) {\r
e48e37fc 1209 RemoveEntryList (Entry);\r
772db4bb 1210 NetbufFree (Packet);\r
1211 }\r
1212 }\r
1213\r
1214 //\r
1215 // Third: time out the transmitted packets.\r
1216 //\r
1217 NetMapIterate (&IpInstance->TxTokens, Ip4SentPacketTicking, NULL);\r
1218 }\r
1219}\r