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