35 if (Assemble ==
NULL) {
39 IP6_COPY_ADDRESS (&Assemble->Dst, Dst);
40 IP6_COPY_ADDRESS (&Assemble->Src, Src);
46 Assemble->TotalLen = 0;
48 Assemble->Head =
NULL;
49 Assemble->Info =
NULL;
50 Assemble->Packet =
NULL;
70 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Assemble->Fragments) {
71 Fragment = NET_LIST_USER_STRUCT (Entry,
NET_BUF, List);
77 if (Assemble->Packet !=
NULL) {
120 Info = IP6_GET_CLIP_INFO (Packet);
122 ASSERT (Info->Start + Info->Length == Info->End);
123 ASSERT ((Info->Start < End) && (Start < Info->End));
125 if (Info->Start < Start) {
126 Len = Start - Info->Start;
128 NetbufTrim (Packet, (UINT32)Len, NET_BUF_HEAD);
129 Info->Start = (UINT32)Start;
130 Info->Length -= (UINT32)Len;
133 if (End < Info->End) {
134 Len = End - Info->End;
136 NetbufTrim (Packet, (UINT32)Len, NET_BUF_TAIL);
137 Info->End = (UINT32)End;
138 Info->Length -= (UINT32)Len;
177 UINT16 UnFragmentLen;
180 Head = Packet->Ip.Ip6;
181 This = IP6_GET_CLIP_INFO (Packet);
183 ASSERT (Head !=
NULL);
189 Index = IP6_ASSEMBLE_HASH (&Head->DestinationAddress, &Head->SourceAddress, This->Id);
191 NET_LIST_FOR_EACH (Cur, &Table->Bucket[Index]) {
194 if ((Entry->Id == This->Id) &&
195 EFI_IP6_EQUAL (&Entry->Src, &Head->SourceAddress) &&
196 EFI_IP6_EQUAL (&Entry->Dst, &Head->DestinationAddress)
207 if (Assemble ==
NULL) {
209 &Head->DestinationAddress,
210 &Head->SourceAddress,
214 if (Assemble ==
NULL) {
226 ListHead = &Assemble->Fragments;
228 NET_LIST_FOR_EACH (Cur, ListHead) {
229 Fragment = NET_LIST_USER_STRUCT (Cur,
NET_BUF, List);
231 if (This->Start < IP6_GET_CLIP_INFO (Fragment)->Start) {
242 if ((Prev = Cur->BackLink) != ListHead) {
243 Fragment = NET_LIST_USER_STRUCT (Prev,
NET_BUF, List);
244 Node = IP6_GET_CLIP_INFO (Fragment);
246 if (This->Start < Node->End) {
247 if (This->End <= Node->End) {
270 while (Cur != ListHead) {
271 Fragment = NET_LIST_USER_STRUCT (Cur,
NET_BUF, List);
272 Node = IP6_GET_CLIP_INFO (Fragment);
277 if (Node->End <= This->End) {
278 Cur = Cur->ForwardLink;
281 Assemble->CurLen -= Node->Length;
293 if (Node->Start < This->End) {
294 if (This->Start == Node->Start) {
310 Assemble->CurLen += This->Length;
312 if (This->Start == 0) {
318 if ((Assemble->Head !=
NULL) || (Assemble->Packet !=
NULL)) {
326 if (Duplicate ==
NULL) {
334 ASSERT (DupHead !=
NULL);
336 Assemble->Packet = Duplicate;
341 UnFragmentLen = (UINT16)(This->HeadLen - sizeof (
EFI_IP6_HEADER));
342 if (UnFragmentLen == 0) {
346 ASSERT (Head->NextHeader == IP6_FRAGMENT);
347 Head->NextHeader = This->NextHeader;
354 if (NextHeader ==
NULL) {
358 *NextHeader = This->NextHeader;
361 Assemble->Head = Head;
362 Assemble->Info = IP6_GET_CLIP_INFO (Packet);
368 if ((This->LastFrag != 0) && (Assemble->TotalLen == 0)) {
369 Assemble->TotalLen = This->End;
379 if ((Assemble->TotalLen != 0) && (Assemble->CurLen >= Assemble->TotalLen)) {
387 Fragment = NET_LIST_USER_STRUCT (ListHead->BackLink,
NET_BUF, List);
388 if (IP6_GET_CLIP_INFO (Fragment)->End != (
INTN)Assemble->TotalLen) {
393 Fragment = NET_LIST_HEAD (ListHead,
NET_BUF, List);
394 This = Assemble->Info;
402 ASSERT (TmpPacket !=
NULL);
404 NET_LIST_FOR_EACH (Cur, ListHead) {
408 Fragment = NET_LIST_USER_STRUCT (Cur,
NET_BUF, List);
418 &Assemble->Fragments,
425 if (NewPacket ==
NULL) {
430 NewPacket->Ip.Ip6 = Assemble->Head;
461 if (Wrap->IpSecRecycleSignal !=
NULL) {
462 gBS->SignalEvent (Wrap->IpSecRecycleSignal);
500 IN OUT UINT8 *LastHead,
502 IN OUT UINT8 **ExtHdrs,
503 IN OUT UINT32 *ExtHdrsLen,
510 UINT32 FragmentCount;
511 UINT32 OriginalFragmentCount;
523 if (!mIpSec2Installed) {
527 ASSERT (mIpSec !=
NULL);
532 FragmentTable =
NULL;
536 FragmentCount = Packet->BlockOpNum;
542 if (mIpSec->DisabledFlag) {
546 IpSb->MaxPacketSize = IpSb->OldMaxPacketSize;
558 if (IP6_IS_MULTICAST (&(*Head)->DestinationAddress) || IP6_IS_MULTICAST (&(*Head)->SourceAddress)) {
567 if (FragmentTable ==
NULL) {
568 Status = EFI_OUT_OF_RESOURCES;
573 OriginalFragmentTable = FragmentTable;
574 OriginalFragmentCount = FragmentCount;
576 if (EFI_ERROR (Status)) {
586 Status = mIpSec->ProcessExt (
604 if (EFI_ERROR (Status)) {
609 if ((OriginalFragmentCount == FragmentCount) && (OriginalFragmentTable == FragmentTable)) {
623 TxWrap->IpSecRecycleSignal = RecycleEvent;
632 if (TxWrap->Packet ==
NULL) {
633 TxWrap->Packet = *Netbuf;
634 Status = EFI_OUT_OF_RESOURCES;
639 IP6_GET_CLIP_INFO (TxWrap->Packet),
640 IP6_GET_CLIP_INFO (Packet),
645 *Netbuf = TxWrap->Packet;
649 if (IpSecWrap ==
NULL) {
650 Status = EFI_OUT_OF_RESOURCES;
651 gBS->SignalEvent (RecycleEvent);
655 IpSecWrap->IpSecRecycleSignal = RecycleEvent;
656 IpSecWrap->Packet = Packet;
666 if (Packet ==
NULL) {
667 Packet = IpSecWrap->Packet;
668 gBS->SignalEvent (RecycleEvent);
670 Status = EFI_OUT_OF_RESOURCES;
680 if (PacketHead ==
NULL) {
682 Status = EFI_OUT_OF_RESOURCES;
688 Packet->Ip.Ip6 = PacketHead;
690 if (*ExtHdrs !=
NULL) {
691 Buf = (UINT8 *)(PacketHead + 1);
692 CopyMem (Buf, *ExtHdrs, *ExtHdrsLen);
697 IP6_GET_CLIP_INFO (Packet),
698 IP6_GET_CLIP_INFO (IpSecWrap->Packet),
737 OUT UINT8 **LastHead,
738 OUT UINT32 *ExtHdrsLen,
739 OUT UINT32 *UnFragmentLen,
740 OUT BOOLEAN *Fragmented,
746 UINT32 FormerHeadOffset;
749 UINT16 FragmentOffset;
758 if ((*Packet)->TotalSize < IP6_MIN_HEADLEN) {
759 return EFI_INVALID_PARAMETER;
767 return EFI_INVALID_PARAMETER;
773 if (((*Head)->Version != 6) || (IP6_IS_MULTICAST (&(*Head)->SourceAddress))) {
774 return EFI_INVALID_PARAMETER;
781 Loopback.Addr[15] = 0x1;
785 return EFI_INVALID_PARAMETER;
796 Info = IP6_GET_CLIP_INFO (*Packet);
797 Info->LinkFlag = Flag;
800 if (IpSb->MnpConfigData.EnablePromiscuousReceive) {
801 Info->CastType = Ip6Promiscuous;
805 Info->CastType = Ip6Unicast;
806 }
else if (IP6_IS_MULTICAST (&(*Head)->DestinationAddress)) {
808 Info->CastType = Ip6Multicast;
815 if (Info->CastType == 0) {
816 return EFI_INVALID_PARAMETER;
819 PayloadLen = (*Head)->PayloadLength;
822 Info->Length = PayloadLen;
823 Info->End = Info->Start + Info->Length;
826 Info->LastFrag =
FALSE;
833 if (TotalLen < (*Packet)->TotalSize) {
837 if (TotalLen != (*Packet)->TotalSize) {
838 return EFI_INVALID_PARAMETER;
844 if (PayloadLen != 0) {
846 if (*Payload ==
NULL) {
847 return EFI_INVALID_PARAMETER;
856 &(*Head)->NextHeader,
867 return EFI_INVALID_PARAMETER;
877 if (FragmentHead ==
NULL) {
878 return EFI_INVALID_PARAMETER;
881 FragmentOffset = NTOHS (FragmentHead->FragmentOffset);
883 if ((FragmentOffset & 0x1) == 0) {
884 Info->LastFrag =
TRUE;
887 FragmentOffset &= (~0x1);
892 if (FragmentOffset == 0) {
893 Info->NextHeader = FragmentHead->NextHeader;
896 Info->HeadLen = (UINT16)HeadLen;
898 Info->Start = FragmentOffset;
899 Info->Length = TotalLen - (UINT16)HeadLen;
900 Info->End = Info->Start + Info->Length;
901 Info->Id = FragmentHead->Identification;
902 Info->FormerNextHeader = FormerHeadOffset;
907 if ((Info->LastFrag == 0) && (Info->Length % 8 != 0)) {
908 return EFI_INVALID_PARAMETER;
915 if (*Packet ==
NULL) {
916 return EFI_INVALID_PARAMETER;
922 *Head = (*Packet)->Ip.Ip6;
923 PayloadLen = (*Head)->PayloadLength;
924 if (PayloadLen != 0) {
925 if (*Payload !=
NULL) {
930 if (*Payload ==
NULL) {
931 return EFI_INVALID_PARAMETER;
940 &(*Head)->NextHeader,
951 return EFI_INVALID_PARAMETER;
987 UINT32 UnFragmentLen;
994 NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
1002 if (EFI_ERROR (IoStatus) || (IpSb->State == IP6_SERVICE_DESTROY)) {
1020 if (EFI_ERROR (Status)) {
1039 if (EFI_ERROR (Status)) {
1059 if (EFI_ERROR (Status)) {
1067 if (Packet ==
NULL) {
1075 Head = Packet->Ip.Ip6;
1078 switch (*LastHead) {
1095 if (Payload !=
NULL) {
1102 if (Packet !=
NULL) {
1123 for (Index = 0; Index < IP6_ASSEMLE_HASH_SIZE; Index++) {
1145 for (Index = 0; Index < IP6_ASSEMLE_HASH_SIZE; Index++) {
1146 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Table->Bucket[Index]) {
1178 ASSERT (!NET_BUF_SHARED (Wrap->Packet));
1209 Wrap =
AllocatePool (IP6_RXDATA_WRAP_SIZE (Packet->BlockOpNum));
1217 Wrap->IpInstance = IpInstance;
1218 Wrap->Packet = Packet;
1219 RxData = &Wrap->RxData;
1223 Status =
gBS->CreateEvent (
1231 if (EFI_ERROR (Status)) {
1236 ASSERT (Packet->Ip.Ip6 !=
NULL);
1278 UINT16 ErrMsgPayloadLen;
1279 UINT8 *ErrMsgPayload;
1281 Config = &IpInstance->ConfigData;
1306 IpInstance->Service,
1310 (UINT32)Head->PayloadLength,
1327 NetbufCopy (Packet, 0,
sizeof (Icmp), (UINT8 *)&Icmp);
1329 if (Icmp.Head.Type <= ICMP_V6_ERROR_MAX) {
1337 ErrMsgPayloadLen = NTOHS (Icmp.IpHead.PayloadLength);
1343 &Icmp.IpHead.NextHeader,
1370 Info = IP6_GET_CLIP_INFO (Packet);
1375 if (Info->CastType == Ip6Multicast) {
1383 for (Index = 0; Index < IpInstance->GroupCount; Index++) {
1384 if (EFI_IP6_EQUAL (IpInstance->GroupList + Index, &Head->DestinationAddress)) {
1389 return (BOOLEAN)(Index < IpInstance->GroupCount);
1423 if (IpInstance->State != IP6_STATE_CONFIGED) {
1424 return EFI_NOT_STARTED;
1428 return EFI_INVALID_PARAMETER;
1436 if (Clone ==
NULL) {
1437 return EFI_OUT_OF_RESOURCES;
1444 Info = IP6_GET_CLIP_INFO (Clone);
1445 Info->Life = IP6_US_TO_SEC (IpInstance->ConfigData.ReceiveTimeout);
1480 Packet = NET_LIST_HEAD (&IpInstance->Received,
NET_BUF, List);
1482 if (!NET_BUF_SHARED (Packet)) {
1489 return EFI_OUT_OF_RESOURCES;
1500 return EFI_OUT_OF_RESOURCES;
1509 ASSERT (Head !=
NULL);
1519 return EFI_OUT_OF_RESOURCES;
1537 Token->
Status = IP6_GET_CLIP_INFO (Packet)->Status;
1538 Token->Packet.
RxData = &Wrap->RxData;
1578 Info = IP6_GET_CLIP_INFO (Packet);
1580 if (IpIf->PromiscRecv) {
1581 LocalType = Ip6Promiscuous;
1583 LocalType = Info->CastType;
1592 SavedType = Info->CastType;
1593 Info->CastType = (UINT32)LocalType;
1597 NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
1598 IpInstance = NET_LIST_USER_STRUCT (Entry,
IP6_PROTOCOL, AddrLink);
1599 NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE);
1606 Info->CastType = (UINT32)SavedType;
1626 NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
1627 IpInstance = NET_LIST_USER_STRUCT (Entry,
IP6_PROTOCOL, AddrLink);
1667 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
1670 if (IpIf->Configured) {
1683 if (Enqueued == 0) {
1684 return EFI_NOT_FOUND;
1687 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
1690 if (IpIf->Configured) {
1723 ASSERT (Wrap !=
NULL);
1725 if ((Wrap->Life > 0) && (--Wrap->Life == 0)) {
1726 Ip6CancelPacket (Wrap->IpInstance->Interface, Wrap->Packet, EFI_ABORTED);
1756 for (Index = 0; Index < IP6_ASSEMLE_HASH_SIZE; Index++) {
1757 NET_LIST_FOR_EACH_SAFE (Entry, Next, &(IpSb->Assemble.Bucket[Index])) {
1760 if ((Assemble->Life > 0) && (--Assemble->Life == 0)) {
1766 if ((Assemble->Packet !=
NULL) &&
1767 !IP6_IS_MULTICAST (&Assemble->Head->DestinationAddress))
1773 &Assemble->Head->SourceAddress,
1774 ICMP_V6_TIME_EXCEEDED,
1775 ICMP_V6_TIMEOUT_REASSEMBLE,
1792 NET_LIST_FOR_EACH (InstanceEntry, &IpSb->Children) {
1793 IpInstance = NET_LIST_USER_STRUCT (InstanceEntry,
IP6_PROTOCOL, Link);
1798 NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpInstance->Received) {
1799 Packet = NET_LIST_USER_STRUCT (Entry,
NET_BUF, List);
1800 Info = IP6_GET_CLIP_INFO (Packet);
1802 if ((Info->Life > 0) && (--Info->Life == 0)) {
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertHeadList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI DispatchDpc(VOID)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
struct _EFI_IP6_HEADER EFI_IP6_HEADER
EFI_IP6_HEADER * Ip6NtohHead(IN OUT EFI_IP6_HEADER *Head)
BOOLEAN Ip6IsOneOfSetAddress(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *Address, OUT IP6_INTERFACE **Interface OPTIONAL, OUT IP6_ADDRESS_INFO **AddressInfo OPTIONAL)
EFI_STATUS Ip6SendIcmpError(IN IP6_SERVICE *IpSb, IN NET_BUF *Packet, IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL, IN EFI_IPv6_ADDRESS *DestinationAddress, IN UINT8 Type, IN UINT8 Code, IN UINT32 *Pointer OPTIONAL)
EFI_STATUS Ip6IcmpHandle(IN IP6_SERVICE *IpSb, IN EFI_IP6_HEADER *Head, IN NET_BUF *Packet)
EFI_STATUS Ip6ReceiveFrame(IN IP6_FRAME_CALLBACK CallBack, IN IP6_SERVICE *IpSb)
VOID EFIAPI Ip6FreeTxToken(IN VOID *Context)
IP6_MLD_GROUP * Ip6FindMldEntry(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *MulticastAddr)
BOOLEAN Ip6IsExtsValid(IN IP6_SERVICE *IpSb OPTIONAL, IN NET_BUF *Packet OPTIONAL, IN UINT8 *NextHeader, IN UINT8 *ExtHdrs, IN UINT32 ExtHdrsLen, IN BOOLEAN Rcvd, OUT UINT32 *FormerHeader OPTIONAL, OUT UINT8 **LastHeader, OUT UINT32 *RealExtsLen OPTIONAL, OUT UINT32 *UnFragmentLen OPTIONAL, OUT BOOLEAN *Fragmented OPTIONAL)
VOID Ip6CancelPacket(IN IP6_INTERFACE *IpIf, IN NET_BUF *Packet, IN EFI_STATUS IoStatus)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
NET_BUF *EFIAPI NetbufClone(IN NET_BUF *Nbuf)
UINT32 EFIAPI NetbufTrim(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
EFI_STATUS EFIAPI NetbufBuildExt(IN NET_BUF *Nbuf, IN OUT NET_FRAGMENT *ExtFragment, IN OUT UINT32 *ExtNum)
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
NET_BUF *EFIAPI NetbufGetFragment(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT32 HeadSpace)
NET_BUF *EFIAPI NetbufFromExt(IN NET_FRAGMENT *ExtFragment, IN UINT32 ExtNum, IN UINT32 HeadSpace, IN UINT32 HeadLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
NET_BUF *EFIAPI NetbufFromBufList(IN LIST_ENTRY *BufList, IN UINT32 HeadSpace, IN UINT32 HeaderLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
BOOLEAN EFIAPI NetIp6IsUnspecifiedAddr(IN EFI_IPv6_ADDRESS *Ip6)
VOID NetIpSecNetbufFree(NET_BUF *Nbuf)
UINT8 *EFIAPI NetbufAllocSpace(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
NET_BUF *EFIAPI NetbufDuplicate(IN NET_BUF *Nbuf, IN OUT NET_BUF *Duplicate OPTIONAL, IN UINT32 HeadSpace)
BOOLEAN EFIAPI NetMapIsEmpty(IN NET_MAP *Map)
UINT8 *EFIAPI NetbufGetByte(IN NET_BUF *Nbuf, IN UINT32 Offset, OUT UINT32 *Index OPTIONAL)
VOID *EFIAPI NetMapRemoveHead(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
EFI_STATUS EFIAPI NetMapIterate(IN NET_MAP *Map, IN NET_MAP_CALLBACK CallBack, IN VOID *Arg OPTIONAL)
VOID EFIAPI NetListInsertBefore(IN OUT LIST_ENTRY *PostEntry, IN OUT LIST_ENTRY *NewEntry)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI EfiReleaseLock(IN EFI_LOCK *Lock)
EFI_STATUS EFIAPI EfiAcquireLockOrFail(IN EFI_LOCK *Lock)
EFI_IP6_FRAGMENT_DATA FragmentTable[1]
EFI_IP6_RECEIVE_DATA * RxData
BOOLEAN AcceptAnyProtocol
BOOLEAN AcceptPromiscuous