39 if (Assemble ==
NULL) {
49 Assemble->Protocol = Protocol;
50 Assemble->TotalLen = 0;
52 Assemble->Head =
NULL;
53 Assemble->Info =
NULL;
54 Assemble->Life = IP4_FRAGMENT_LIFE;
74 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Assemble->Fragments) {
75 Fragment = NET_LIST_USER_STRUCT (Entry,
NET_BUF, List);
98 for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {
120 for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {
121 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Table->Bucket[Index]) {
149 Info = IP4_GET_CLIP_INFO (Packet);
151 ASSERT (Info->Start + Info->Length == Info->End);
152 ASSERT ((Info->Start < End) && (Start < Info->End));
154 if (Info->Start < Start) {
155 Len = Start - Info->Start;
157 NetbufTrim (Packet, (UINT32)Len, NET_BUF_HEAD);
162 if (End < Info->End) {
163 Len = End - Info->End;
165 NetbufTrim (Packet, (UINT32)Len, NET_BUF_TAIL);
220 IpHead = Packet->Ip.Ip4;
221 This = IP4_GET_CLIP_INFO (Packet);
223 ASSERT (IpHead !=
NULL);
229 Index = IP4_ASSEMBLE_HASH (IpHead->Dst, IpHead->Src, IpHead->Id, IpHead->Protocol);
231 NET_LIST_FOR_EACH (Cur, &Table->Bucket[Index]) {
234 if ((Assemble->Dst == IpHead->Dst) && (Assemble->Src == IpHead->Src) &&
235 (Assemble->Id == IpHead->Id) && (Assemble->Protocol == IpHead->Protocol))
244 if (Cur == &Table->Bucket[Index]) {
252 if (Assemble ==
NULL) {
262 ASSERT (Assemble !=
NULL);
269 Head = &Assemble->Fragments;
271 NET_LIST_FOR_EACH (Cur, Head) {
272 Fragment = NET_LIST_USER_STRUCT (Cur,
NET_BUF, List);
274 if (This->Start < IP4_GET_CLIP_INFO (Fragment)->Start) {
285 if ((Prev = Cur->BackLink) != Head) {
286 Fragment = NET_LIST_USER_STRUCT (Prev,
NET_BUF, List);
287 Node = IP4_GET_CLIP_INFO (Fragment);
289 if (This->Start < Node->End) {
290 if (This->End <= Node->End) {
311 while (Cur != Head) {
312 Fragment = NET_LIST_USER_STRUCT (Cur,
NET_BUF, List);
313 Node = IP4_GET_CLIP_INFO (Fragment);
318 if (Node->End <= This->End) {
319 Cur = Cur->ForwardLink;
322 Assemble->CurLen -= Node->Length;
334 if (Node->Start < This->End) {
335 if (This->Start == Node->Start) {
351 Assemble->CurLen += This->Length;
353 if (This->Start == 0) {
359 ASSERT (Assemble->Head ==
NULL);
361 Assemble->Head = IpHead;
362 Assemble->Info = IP4_GET_CLIP_INFO (Packet);
368 if (IP4_LAST_FRAGMENT (IpHead->Fragment) && (Assemble->TotalLen == 0)) {
369 Assemble->TotalLen = This->End;
379 if ((Assemble->TotalLen != 0) && (Assemble->CurLen >= Assemble->TotalLen)) {
387 Fragment = NET_LIST_USER_STRUCT (Head->BackLink,
NET_BUF, List);
389 if (IP4_GET_CLIP_INFO (Fragment)->End != Assemble->TotalLen) {
398 &Assemble->Fragments,
405 if (NewPacket ==
NULL) {
410 NewPacket->Ip.Ip4 = Assemble->Head;
412 ASSERT (Assemble->Info !=
NULL);
415 IP4_GET_CLIP_INFO (NewPacket),
417 sizeof (*IP4_GET_CLIP_INFO (NewPacket))
447 if (Wrap->IpSecRecycleSignal !=
NULL) {
448 gBS->SignalEvent (Wrap->IpSecRecycleSignal);
486 IN OUT UINT8 **Options,
487 IN OUT UINT32 *OptionsLen,
494 UINT32 FragmentCount;
495 UINT32 OriginalFragmentCount;
505 if (!mIpSec2Installed) {
509 ASSERT (mIpSec !=
NULL);
514 FragmentTable =
NULL;
516 FragmentCount = Packet->BlockOpNum;
523 if (mIpSec->DisabledFlag) {
527 IpSb->MaxPacketSize = IpSb->OldMaxPacketSize;
541 if (FragmentTable ==
NULL) {
542 Status = EFI_OUT_OF_RESOURCES;
551 OriginalFragmentTable = FragmentTable;
552 OriginalFragmentCount = FragmentCount;
554 if (EFI_ERROR (Status)) {
564 Status = mIpSec->ProcessExt (
582 if (EFI_ERROR (Status)) {
587 if ((OriginalFragmentTable == FragmentTable) && (OriginalFragmentCount == FragmentCount)) {
601 TxWrap->IpSecRecycleSignal = RecycleEvent;
610 if (TxWrap->Packet ==
NULL) {
615 TxWrap->Packet = *Netbuf;
616 Status = EFI_OUT_OF_RESOURCES;
624 *Netbuf = TxWrap->Packet;
628 if (IpSecWrap ==
NULL) {
629 Status = EFI_OUT_OF_RESOURCES;
630 gBS->SignalEvent (RecycleEvent);
634 IpSecWrap->IpSecRecycleSignal = RecycleEvent;
635 IpSecWrap->Packet = Packet;
645 if (Packet ==
NULL) {
646 Packet = IpSecWrap->Packet;
647 gBS->SignalEvent (RecycleEvent);
649 Status = EFI_OUT_OF_RESOURCES;
659 IP4_GET_CLIP_INFO (Packet),
660 IP4_GET_CLIP_INFO (IpSecWrap->Packet),
706 HeadLen = (Head->HeadLen << 2);
707 TotalLen = NTOHS (Head->TotalLen);
712 if (TotalLen < (*Packet)->TotalSize) {
716 if ((Head->Ver != 4) || (HeadLen < IP4_MIN_HEADLEN) ||
717 (TotalLen < HeadLen) || (TotalLen != (*Packet)->TotalSize))
719 return EFI_INVALID_PARAMETER;
727 if ((Head->Checksum != 0) && (Checksum != 0)) {
728 return EFI_INVALID_PARAMETER;
736 Info = IP4_GET_CLIP_INFO (*Packet);
737 Info->LinkFlag = Flag;
739 Info->Start = (Head->Fragment & IP4_HEAD_OFFSET_MASK) << 3;
740 Info->Length = Head->TotalLen - HeadLen;
741 Info->End = Info->Start + Info->Length;
747 if ((Info->CastType == 0) || (Info->End > IP4_MAX_PACKET_SIZE)) {
748 return EFI_INVALID_PARAMETER;
757 return EFI_INVALID_PARAMETER;
771 if (((Head->Fragment & IP4_HEAD_MF_MASK) != 0) || (Info->Start != 0)) {
776 if ((Head->Fragment & IP4_HEAD_DF_MASK) != 0) {
777 return EFI_INVALID_PARAMETER;
783 if (((Head->Fragment & IP4_HEAD_MF_MASK) != 0) && (Info->Length % 8 != 0)) {
784 return EFI_INVALID_PARAMETER;
792 if (*Packet ==
NULL) {
793 return EFI_INVALID_PARAMETER;
817 if (Packet->TotalSize < IP4_MIN_HEADLEN) {
856 if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DESTROY)) {
865 ASSERT (Head !=
NULL);
866 OptionLen = (Head->HeadLen << 2) - IP4_MIN_HEADLEN;
868 Option = (UINT8 *)(Head + 1);
883 if (EFI_ERROR (Status)) {
901 if (EFI_ERROR (Status)) {
919 ASSERT (Head !=
NULL);
928 if (EFI_ERROR (Status)) {
933 ASSERT (Packet !=
NULL);
934 Head = Packet->Ip.Ip4;
937 switch (Head->Protocol) {
938 case EFI_IP_PROTO_ICMP:
962 if (Packet !=
NULL) {
993 Config = &IpInstance->ConfigData;
1016 Proto = Head->Protocol;
1019 NetbufCopy (Packet, 0,
sizeof (Icmp.Head), (UINT8 *)&Icmp.Head);
1021 if (mIcmpClass[Icmp.Head.Type].IcmpClass == ICMP_ERROR_MESSAGE) {
1026 NetbufCopy (Packet, 0,
sizeof (Icmp), (UINT8 *)&Icmp);
1027 Proto = Icmp.IpHead.Protocol;
1042 Info = IP4_GET_CLIP_INFO (Packet);
1044 if (IP4_IS_BROADCAST (Info->CastType)) {
1051 if (Info->CastType == IP4_MULTICAST) {
1055 if (!IpInstance->ConfigData.UseDefaultAddress && (IpInstance->Interface->Ip == 0)) {
1059 for (Index = 0; Index < IpInstance->GroupCount; Index++) {
1060 if (IpInstance->Groups[Index] == HTONL (Head->Dst)) {
1065 return (BOOLEAN)(Index < IpInstance->GroupCount);
1099 if (IpInstance->State != IP4_STATE_CONFIGED) {
1100 return EFI_NOT_STARTED;
1104 return EFI_INVALID_PARAMETER;
1112 if (Clone ==
NULL) {
1113 return EFI_OUT_OF_RESOURCES;
1120 Info = IP4_GET_CLIP_INFO (Clone);
1121 Info->Life =
IP4_US_TO_SEC (IpInstance->ConfigData.ReceiveTimeout);
1151 ASSERT (!NET_BUF_SHARED (Wrap->Packet));
1154 gBS->CloseEvent (Wrap->RxData.RecycleSignal);
1184 Wrap =
AllocatePool (IP4_RXDATA_WRAP_SIZE (Packet->BlockOpNum));
1192 Wrap->IpInstance = IpInstance;
1193 Wrap->Packet = Packet;
1194 RxData = &Wrap->RxData;
1198 Status =
gBS->CreateEvent (
1203 &RxData->RecycleSignal
1206 if (EFI_ERROR (Status)) {
1211 ASSERT (Packet->Ip.Ip4 !=
NULL);
1213 ASSERT (IpInstance !=
NULL);
1214 RawData = IpInstance->ConfigData.RawData;
1220 RxData->HeaderLength = (Packet->Ip.Ip4->HeadLen << 2);
1222 RxData->OptionsLength = RxData->HeaderLength - IP4_MIN_HEADLEN;
1223 RxData->Options =
NULL;
1225 if (RxData->OptionsLength != 0) {
1226 RxData->Options = (VOID *)(RxData->Header + 1);
1230 RxData->DataLength = Packet->TotalSize;
1235 RxData->FragmentCount = Packet->BlockOpNum;
1273 Packet = NET_LIST_HEAD (&IpInstance->Received,
NET_BUF, List);
1275 if (!NET_BUF_SHARED (Packet)) {
1282 return EFI_OUT_OF_RESOURCES;
1290 if (IpInstance->ConfigData.RawData) {
1293 HeadLen = IP4_MAX_HEADLEN;
1299 return EFI_OUT_OF_RESOURCES;
1302 if (!IpInstance->ConfigData.RawData) {
1309 ASSERT (Head !=
NULL);
1313 CopyMem (Head, Packet->Ip.Ip4, Packet->Ip.Ip4->HeadLen << 2);
1321 return EFI_OUT_OF_RESOURCES;
1339 Token->
Status = IP4_GET_CLIP_INFO (Packet)->Status;
1340 Token->Packet.
RxData = &Wrap->RxData;
1368 IN UINT32 OptionLen,
1386 Info = IP4_GET_CLIP_INFO (Packet);
1388 if ((Info->CastType == IP4_MULTICAST) || (Info->CastType == IP4_LOCAL_BROADCAST)) {
1394 LocalType = Info->CastType;
1402 if (IpIf->Ip == IP4_ALLZERO_ADDRESS) {
1403 LocalType = IP4_LOCAL_HOST;
1407 if ((LocalType == 0) && IpIf->PromiscRecv) {
1408 LocalType = IP4_PROMISCUOUS;
1413 if (LocalType == 0) {
1423 SavedType = Info->CastType;
1424 Info->CastType = LocalType;
1428 NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
1429 IpInstance = NET_LIST_USER_STRUCT (Entry,
IP4_PROTOCOL, AddrLink);
1430 NET_CHECK_SIGNATURE (IpInstance, IP4_PROTOCOL_SIGNATURE);
1435 if ((IpInstance->ConfigData.
RawData) && (Option !=
NULL) && (OptionLen != 0)) {
1444 Info->CastType = SavedType;
1466 NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
1467 Ip4Instance = NET_LIST_USER_STRUCT (Entry,
IP4_PROTOCOL, AddrLink);
1513 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
1516 if (IpIf->Configured) {
1535 if (Enqueued == 0) {
1536 return EFI_NOT_FOUND;
1539 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
1542 if (IpIf->Configured) {
1574 for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {
1575 NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpSb->Assemble.Bucket[Index]) {
1578 if ((Assemble->Life > 0) && (--Assemble->Life == 0)) {
1585 NET_LIST_FOR_EACH (InstanceEntry, &IpSb->Children) {
1586 IpInstance = NET_LIST_USER_STRUCT (InstanceEntry,
IP4_PROTOCOL, Link);
1591 NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpInstance->Received) {
1592 Packet = NET_LIST_USER_STRUCT (Entry,
NET_BUF, List);
1593 Info = IP4_GET_CLIP_INFO (Packet);
1595 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)
INTN Ip4GetHostCast(IN IP4_SERVICE *IpSb, IN IP4_ADDR Dst, IN IP4_ADDR Src)
INTN Ip4GetNetCast(IN IP4_ADDR IpAddr, IN IP4_INTERFACE *IpIf)
IP4_HEAD * Ip4NtohHead(IN IP4_HEAD *Head)
#define IP4_US_TO_SEC(Us)
EFI_STATUS Ip4IcmpHandle(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet)
EFI_STATUS Ip4ReceiveFrame(IN IP4_INTERFACE *Interface, IN IP4_PROTOCOL *IpInstance OPTIONAL, IN IP4_FRAME_CALLBACK CallBack, IN VOID *Context)
EFI_STATUS Ip4IgmpHandle(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet)
VOID EFIAPI Ip4FreeTxToken(IN VOID *Context)
EFI_STATUS EFIAPI Ip4SentPacketTicking(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
BOOLEAN Ip4OptionIsValid(IN UINT8 *Option, IN UINT32 OptionLen, IN BOOLEAN Rcvd)
EFI_STATUS Ip4PrependHead(IN OUT NET_BUF *Packet, IN IP4_HEAD *Head, IN UINT8 *Option, IN UINT32 OptLen)
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)
UINT16 EFIAPI NetblockChecksum(IN UINT8 *Bulk, IN UINT32 Len)
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
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)
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_IP4_RECEIVE_DATA * RxData
BOOLEAN AcceptPromiscuous
BOOLEAN AcceptAnyProtocol